-
Notifications
You must be signed in to change notification settings - Fork 64
WIP: fix validation of passing enum as var_in_out #1521
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
Draft
leandrosansilva
wants to merge
2
commits into
PLC-lang:master
Choose a base branch
from
leandrosansilva:fix/1518_enum_in_out
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I would also check here that the pointer is an auto deref pointer, otherwise we start returing type variants for pointer types.
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.
Where would you recommend adding the unit tests? I haven't looked very deep, but I haven't figured out how properly use the
.snap
based tests.Uh oh!
There was an error while loading. Please reload this page.
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.
the .snap files are snapshot tests, we create them using Cargo Insta the way this works is you write a test that should produce some kind of string, you can find examples in the codegen tests for that
What we usually have is something like
then if we run cargo test a snapshot file (
.snap.new
) will be generated. we then runcargo insta review
and check if the snap file looks like what we expect, if it does we accept it and it will be added to the file.If we skip the
r#""#
part in the assert_insta_snapshot macro, the result will be a .snap file.In your case, i would recommend the first tests to go into
index_tests.rs
similar topou_with_rescursive_type_fails
and then you can add codegen tests to check if the argument is being passed correctly. The best place for codegen tests in this area would be theexpression_generator
tests.Codegen tests are usually a bit cryptic, so what you can also do is first write some
lit
tests. These are integration test, just copy a .st file from the tests/lit/single file and change it to fit your test. any comment with //CHECK will be evaluated. You can useprintf
to output to the terminal, that's whatCHECK
will look for.To use lit just run
cargo xtask lit
it will build the project, the standard functions and run all lit tests. You need to be in our dev container or have lit setup for that.If you don't want to run lit locally you can also just compile and run the file by hand. You just need to include the printf function (under lit/utils) to your file and compile with --linker=cc or --linker=clang so libc gets linked with your binary.