-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Initial test for Compiler #20
Conversation
Someone is attempting to deploy a commit to the Akash Hamirwasia's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests for compiler should be inside the compiler
package. We should have different unit testing setups for compiler
and editor
as both are essentially 2 different modules.
The root package.json can then have commands like compiler:test
or editor:test
which runs the test of that respective module only.
@blenderskool Should I make tests for lexer, parser, semantic analyzer separatly? |
@blenderskool could u suggest some example test cases? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also change the directory name to compiler/tests/
instead of compiler/test
server: { | ||
host: '0.0.0.0' | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it just allow to test this appliaction from any device and any IP(just default)
package.json
Outdated
"test:compiler": "vitest run compiler", | ||
"test:editor": "vitest run editor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convention is module:command
in the codebase. So this should be compiler:test
and editor:test
and placed alongside the other commands of same module.
Ideally the command in root package.json should simply run the command in the respective module. So your compiler/package.json
should have a test
command which runs vitest
and the command in root package.json would look like cd compiler && pnpm run test
grammar.parse().semanticAnalysis(); | ||
const firstSets = grammar.findFirstSets(); | ||
expect(firstSets).toBeDefined(); | ||
expect(firstSets).toEqual(findFirstSets(grammar["grammar"])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right way of defining tests. It's like checking if result of function is equal to itself(which will always be true!). We should rather test for correctness of the functions by comparing the output to an output we know is correct for the given grammar.
@blenderskool Can you suggest some test cases for regular grammar to test upon or can I use the same used in cfg and do I have to test the lexers and parser separately? |
@blenderskool I added a review test. Please let me know if its good so I can continue with other tests.
Regards