Fix unit tests

This commit is contained in:
Alex Bethel 2021-06-15 11:29:52 -05:00
parent da9ff64486
commit d1064802ec

View file

@ -442,7 +442,7 @@ mod tests {
// Integer overflow should throw a recoverable error instead // Integer overflow should throw a recoverable error instead
// of panicking. // of panicking.
let env = ExecEnv::new(); let env = ExecEnv::new();
assert!(matches!( assert_eq!(
env.eval_expr(&Expr { env.eval_expr(&Expr {
kind: ExprKind::BinOp { kind: ExprKind::BinOp {
lhs: Box::new(Expr { lhs: Box::new(Expr {
@ -456,15 +456,13 @@ mod tests {
kind: crate::ast::BinOpKind::Add, kind: crate::ast::BinOpKind::Add,
}, },
span: 1..1 span: 1..1
}),
Err(Error {
kind: ErrorKind::ArithmeticError,
span: _,
}) })
)); .unwrap(),
Value::Int(42)
);
// And the same for divide by zero. // And the same for divide by zero.
assert!(matches!( assert_eq!(
env.eval_expr(&Expr { env.eval_expr(&Expr {
kind: ExprKind::BinOp { kind: ExprKind::BinOp {
lhs: Box::new(Expr { lhs: Box::new(Expr {
@ -478,12 +476,10 @@ mod tests {
kind: crate::ast::BinOpKind::Divide, kind: crate::ast::BinOpKind::Divide,
}, },
span: 1..1 span: 1..1
}),
Err(Error {
kind: ErrorKind::ArithmeticError,
span: _,
}) })
)); .unwrap(),
Value::Int(42)
);
} }
// From here on out, I'll use this function to parse and run // From here on out, I'll use this function to parse and run