Add ParseError:err_type and ParseError::position.
This commit is contained in:
@@ -115,10 +115,10 @@ fn test_switch_errors() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert!(matches!(
|
||||
*engine
|
||||
engine
|
||||
.compile("switch x { _ => 123, 1 => 42 }")
|
||||
.expect_err("should error")
|
||||
.0,
|
||||
.err_type(),
|
||||
ParseErrorType::WrongSwitchDefaultCase
|
||||
));
|
||||
|
||||
@@ -179,10 +179,10 @@ fn test_switch_condition() -> Result<(), Box<EvalAltResult>> {
|
||||
);
|
||||
|
||||
assert!(matches!(
|
||||
*engine
|
||||
engine
|
||||
.compile("switch x { 1 => 123, _ if true => 42 }")
|
||||
.expect_err("should error")
|
||||
.0,
|
||||
.err_type(),
|
||||
ParseErrorType::WrongSwitchCaseCondition
|
||||
));
|
||||
|
||||
@@ -274,8 +274,9 @@ fn test_switch_ranges() -> Result<(), Box<EvalAltResult>> {
|
||||
'x'
|
||||
);
|
||||
assert!(matches!(
|
||||
*engine.compile("switch x { 10..20 => (), 20..=42 => 'a', 25..45 => 'z', 42 => 'x', 30..100 => true }")
|
||||
.expect_err("should error").0,
|
||||
engine.compile(
|
||||
"switch x { 10..20 => (), 20..=42 => 'a', 25..45 => 'z', 42 => 'x', 30..100 => true }"
|
||||
).expect_err("should error").err_type(),
|
||||
ParseErrorType::WrongSwitchIntegerCase
|
||||
));
|
||||
assert_eq!(
|
||||
|
Reference in New Issue
Block a user