Skip to content

Commit

Permalink
Add binary operator ensure tests
Browse files Browse the repository at this point in the history
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
1 parent 2737bbe commit ca7aff7
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit ca7aff7

Please sign in to comment.