Skip to content

Commit cd8081f

Browse files
committed
test(cel-parser): add test for arithmetic overflow error handling
1 parent 7c4d804 commit cd8081f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

cel-parser/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,4 +1854,25 @@ mod playground {
18541854
),
18551855
}
18561856
}
1857+
1858+
#[test]
1859+
fn arithmetic_overflow_error() {
1860+
use error::FormatRustcStyle;
1861+
1862+
let line = line!() + 1;
1863+
let source = r#"
1864+
1 + 1 +
1865+
2147483646 + 1
1866+
"#;
1867+
let mut seg = CELParser::new(OpLookup::new())
1868+
.parse_str(source)
1869+
.expect("parses successfully");
1870+
match seg.call0::<i32>() {
1871+
Ok(v) => panic!("expected overflow, got {v}"),
1872+
Err(e) => println!(
1873+
"{}",
1874+
e.format_rustc_style(source, file!(), line, &Renderer::styled())
1875+
),
1876+
}
1877+
}
18571878
}

0 commit comments

Comments
 (0)