-
Notifications
You must be signed in to change notification settings - Fork 0
Add tests for postfix expression variants #137
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
Open
leynos
wants to merge
9
commits into
main
Choose a base branch
from
codex/add-tests-for-new-expr-variants
base: main
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.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0b6d369
Add tests for postfix expression variants
leynos 1478ed0
Refine postfix expression tests
leynos 8fb9ece
Label postfix expression test cases
leynos 2738f2f
Label postfix error test cases
leynos 3b89f62
Label expression error test cases
leynos 3e0046c
test: move unclosed call error to integration
leynos eff5e1d
test: humanise postfix error tokens
leynos c80ac2c
test: replace token ids in error expectations
leynos 68fb44b
Format test utility imports for readability
leynos 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
Some comments aren't visible on the classic Files Changed page.
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //! Integration tests for postfix expressions. | ||
| //! | ||
| //! These tests cover method calls, field accesses, tuple indexing, and bit | ||
| //! slice expressions through the public `parse_expression` API. | ||
|
|
||
| use ddlint::parser::ast::Expr; | ||
| use ddlint::parser::expression::parse_expression; | ||
| use ddlint::test_util::{ | ||
| assert_delimiter_error, assert_parse_error, bit_slice, field_access, lit_num, method_call, | ||
| tuple_index, var, | ||
| }; | ||
| use rstest::rstest; | ||
|
|
||
| #[rstest] | ||
| #[case::method_call("foo.bar(x)", method_call(var("foo"), "bar", vec![var("x")]))] | ||
| #[case::field_access("foo.bar", field_access(var("foo"), "bar"))] | ||
| #[case::bit_slice("e[1,0]", bit_slice(var("e"), lit_num("1"), lit_num("0")))] | ||
| #[case::tuple_index("t.0", tuple_index(var("t"), "0"))] | ||
| #[case::multi_arg_call("foo.bar(1, 2)", method_call(var("foo"), "bar", vec![lit_num("1"), lit_num("2")]))] | ||
| #[case::chained_postfix("foo.bar().baz[1,0]", bit_slice(field_access(method_call(var("foo"), "bar", vec![]), "baz"), lit_num("1"), lit_num("0")))] | ||
| fn parses_postfix_expressions(#[case] src: &str, #[case] expected: Expr) { | ||
| let expr = parse_expression(src).unwrap_or_else(|e| panic!("source {src:?} errors: {e:?}")); | ||
| assert_eq!(expr, expected); | ||
| } | ||
|
|
||
| #[rstest] | ||
| #[case::unclosed_call("foo.bar(", "invalid expression", 8, 8, true)] | ||
| fn postfix_expression_errors( | ||
| #[case] src: &str, | ||
| #[case] msg: &str, | ||
| #[case] start: usize, | ||
| #[case] end: usize, | ||
| #[case] unclosed: bool, | ||
| ) { | ||
| let Err(errors) = parse_expression(src) else { | ||
| panic!("expected error"); | ||
| }; | ||
| if unclosed { | ||
| assert_delimiter_error(&errors, msg, start, end); | ||
| } else { | ||
| assert_parse_error(&errors, msg, start, end); | ||
| } | ||
| } |
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
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
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
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.
🧹 Nitpick (assertive)
Speed up token normalisation and widen coverage (optional)
Avoid rebuilding mappings per call and extend coverage to common punctuation.
Add a module‑level constant and reuse it:
Add near the top of the module:
🤖 Prompt for AI Agents