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

Fix parse error with non-literal after minus sign #373

Merged
merged 3 commits into from
May 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add binary operator ensure tests
Currently failing:

    error: unexpected token: `b`
       --> tests/test_ensure.rs:138:44
        |
    138 |     let test = || Ok(ensure!(a <= b || a - b <= 10));
        |                                            ^
        |
       ::: src/ensure.rs:319:117
        |
    319 |     (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($dot:tt $ident:tt $colons:tt $larrow:tt $lit:literal $($dup:tt)*) . $i:ident :: <- $($rest:tt)*) => {
        |                                                                                                                     ------------ while parsing argument for this `literal` macro fragment
  • Loading branch information
dtolnay committed May 18, 2024
commit ca7aff727bfd95422dfed63d12a9b499684b6d7b
13 changes: 13 additions & 0 deletions tests/test_ensure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ fn test_low_precedence_binary_operator() {
test,
"Condition failed: `while false == true && false {} < ()` (() vs ())",
);

let a = 15;
let b = 3;
let test = || Ok(ensure!(a <= b || a - b <= 10));
assert_err(test, "Condition failed: `a <= b || a - b <= 10`");
}

#[test]
fn test_high_precedence_binary_operator() {
let a = 15;
let b = 3;
let test = || Ok(ensure!(a - b <= 10));
assert_err(test, "Condition failed: `a - b <= 10` (12 vs 10)");
}

#[test]
Expand Down