Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Added Initial test for Compiler #20

wants to merge 4 commits into from

Conversation

vr-varad
Copy link

@vr-varad vr-varad commented Jun 26, 2024

@blenderskool I added a review test. Please let me know if its good so I can continue with other tests.
Regards

Copy link

vercel bot commented Jun 26, 2024

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.

Copy link
Owner

@blenderskool blenderskool left a 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.

@vr-varad
Copy link
Author

vr-varad commented Jun 26, 2024

@blenderskool Should I make tests for lexer, parser, semantic analyzer separatly?
and a little week in toc so can u give some data for testing?
for regular Grammar, turning machine, testing in editor?

@vr-varad
Copy link
Author

@blenderskool could u suggest some example test cases?

Copy link
Owner

@blenderskool blenderskool left a 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

Comment on lines +4 to +6
server: {
host: '0.0.0.0'
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required?

Copy link
Author

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
Comment on lines 17 to 18
"test:compiler": "vitest run compiler",
"test:editor": "vitest run editor"
Copy link
Owner

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"]));
Copy link
Owner

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 blenderskool linked an issue Jun 27, 2024 that may be closed by this pull request
@vr-varad
Copy link
Author

vr-varad commented Jul 1, 2024

@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?

@vr-varad vr-varad closed this by deleting the head repository Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit testing setup
2 participants