Use unwrap_err.

This commit is contained in:
Stephen Chung
2023-04-10 23:23:59 +08:00
parent 20c535ecd3
commit 8662ffec62
24 changed files with 100 additions and 153 deletions

View File

@@ -110,7 +110,7 @@ fn test_switch_errors() -> Result<(), Box<EvalAltResult>> {
assert!(matches!(
engine
.compile("switch x { _ => 123, 1 => 42 }")
.expect_err("should error")
.unwrap_err()
.err_type(),
ParseErrorType::WrongSwitchDefaultCase
));
@@ -174,7 +174,7 @@ fn test_switch_condition() -> Result<(), Box<EvalAltResult>> {
assert!(matches!(
engine
.compile("switch x { 1 => 123, _ if true => 42 }")
.expect_err("should error")
.unwrap_err()
.err_type(),
ParseErrorType::WrongSwitchCaseCondition
));
@@ -269,14 +269,14 @@ fn test_switch_ranges() -> Result<(), Box<EvalAltResult>> {
assert!(matches!(
engine.compile(
"switch x { 10..20 => (), 20..=42 => 'a', 25..45 => 'z', 42 => 'x', 30..100 => true }"
).expect_err("should error").err_type(),
).unwrap_err().err_type(),
ParseErrorType::WrongSwitchIntegerCase
));
#[cfg(not(feature = "no_float"))]
assert!(matches!(
engine.compile(
"switch x { 10..20 => (), 20..=42 => 'a', 25..45 => 'z', 42.0 => 'x', 30..100 => true }"
).expect_err("should error").err_type(),
).unwrap_err().err_type(),
ParseErrorType::WrongSwitchIntegerCase
));
assert_eq!(