Use unwrap_err.
This commit is contained in:
@@ -21,71 +21,44 @@ fn test_assignments_bad_lhs() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("(x+y) = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("(x+y) = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToInvalidLHS(String::new())
|
||||
);
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("foo(x) = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("foo(x) = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToInvalidLHS(String::new())
|
||||
);
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("true = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("true = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToConstant(String::new())
|
||||
);
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("123 = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("123 = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToConstant(String::new())
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
{
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("x.foo() = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("x.foo() = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToInvalidLHS(String::new())
|
||||
);
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("x.foo().x.y = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("x.foo().x.y = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToInvalidLHS(String::new())
|
||||
);
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("x.y.z.foo() = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("x.y.z.foo() = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToInvalidLHS(String::new())
|
||||
);
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("x.foo()[0] = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("x.foo()[0] = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToInvalidLHS(String::new())
|
||||
);
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
assert_eq!(
|
||||
*engine
|
||||
.compile("x[y].z.foo() = 42;")
|
||||
.expect_err("should error")
|
||||
.err_type(),
|
||||
*engine.compile("x[y].z.foo() = 42;").unwrap_err().err_type(),
|
||||
ParseErrorType::AssignmentToInvalidLHS(String::new())
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user