Refine position display in error messages.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use rhai::{Engine, EvalAltResult, INT};
|
||||
use rhai::{Engine, EvalAltResult, ParseError, ParseErrorType, INT};
|
||||
|
||||
#[test]
|
||||
fn test_loop() -> Result<(), Box<EvalAltResult>> {
|
||||
@@ -26,5 +26,15 @@ fn test_loop() -> Result<(), Box<EvalAltResult>> {
|
||||
21
|
||||
);
|
||||
|
||||
assert!(matches!(
|
||||
engine.compile("let x = 0; break;").expect_err("should error"),
|
||||
ParseError(x, _) if *x == ParseErrorType::LoopBreak
|
||||
));
|
||||
|
||||
assert!(matches!(
|
||||
engine.compile("let x = 0; if x > 0 { continue; }").expect_err("should error"),
|
||||
ParseError(x, _) if *x == ParseErrorType::LoopBreak
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user