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

Test monomorphized AST #240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

cyberbono3
Copy link

Closes #200

@katat
Copy link
Collaborator

katat commented Dec 4, 2024

hmm, I think the issue is to add tests to compare the AST during monomorphization phase (MAST). It is useful to review the effects on the generated MAST nodes if there are changes to the logic in MAST pipeline.

There is some tool like https://github.com/mitsuhiko/insta?tab=readme-ov-file to do the job. But I think we should be able to structure the snapshot tests small enough, so the generated AST string can be compared in a manageable way.

@cyberbono3
Copy link
Author

@katat Thanks for clarification. test_simple_mast yields some ambiguity in MAST snapshots. Every new snapshot generates new functions description: "functions":[["std/bits/nth_bit", "functions":[["std/builtins/log"
You can reproduce it by cargo insta test --review

@katat
Copy link
Collaborator

katat commented Dec 10, 2024

Ah, it is because the resulted MAST can have the same set of the functions but in different order. The whole MAST contains all the stdlib and builtin functions.

For this kind of test, we should only snapshot the functions in concern, such as the generic examples test_generic_*. The snapshot test for MAST is to check if the monomorphization done properly for the generic features.

I think you can create a new test set, similar to the negative_tests.rs, for snapshot tests for MAST generation. For the generic feature examples to test snapshot, you can copy the code from the examples folder. Ideally, each snapshot test one generic feature that is already covered in the examples folder.

@cyberbono3
Copy link
Author

cyberbono3 commented Dec 13, 2024

For this kind of test, we should only snapshot the functions in concern, such as the generic examples test_generic_*. The snapshot test for MAST is to check if the monomorphization done properly for the generic features.
For the generic feature examples to test snapshot, you can copy the code from the examples folder

The snapshot test cases from examples folder (arithmetic.no, array.no etc) will produce an ambiguity as I mentioned above.

There are test_generic_ test cases presented n src/negative_tests.rs and in src/tests/examples.rs.
I assume, you would like to make snapshot tests for MAST generation for test cases test_generic_ listed in src/tests/examples.rs Right?

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.

Test monomorphized AST
2 participants