-
Notifications
You must be signed in to change notification settings - Fork 57
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
base: main
Are you sure you want to change the base?
Conversation
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. |
@katat Thanks for clarification. |
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 I think you can create a new test set, similar to the |
The snapshot test cases from examples folder (arithmetic.no, array.no etc) will produce an ambiguity as I mentioned above. There are |
Yes, it should only cover the generic functions that involve MAST generation.
Not sure If I understood this. The discrepancy is due to the order of the MAST functions. That doesn't mean there is a discrepancy from the MAST. When it comes to comparison, I would suggest checking the monomorphized functions / instantiated function in a narrowed context, that would be easier to find the root causes if there are any discrepancies. For example, it would be easier to isolate the snapshot test per generic feature, such as generic array:
In other words, in the snapshot test, it should check if the MAST of instantiated function from this generic function is as expected. |
} | ||
|
||
#[test] | ||
fn test_generic_builtin_bits() { |
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 test fails here At a first glance use std::btts yields this error.
failures:
---- tests::snapshots::mast::test_generic_builtin_bits stdout ----
[src/mast/mod.rs:590:13] module = Absolute(
UserRepo {
user: "std",
repo: "bits",
},
)
[src/mast/mod.rs:591:13] &fn_name.value = "to_bits"
thread 'tests::snapshots::mast::test_generic_builtin_bits' panicked at src/mast/mod.rs:596:18:
function not found
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Basically, I have performed snapshot testing for all fields of |
Closes #200