From d0f705229032f170f18ea35c9053dcbe7f727c22 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Tue, 15 Jun 2021 11:29:52 -0500 Subject: [PATCH] Fix unit tests --- src/interpret.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/interpret.rs b/src/interpret.rs index 27dd2b1d..da0560a8 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -442,7 +442,7 @@ mod tests { // Integer overflow should throw a recoverable error instead // of panicking. let env = ExecEnv::new(); - assert!(matches!( + assert_eq!( env.eval_expr(&Expr { kind: ExprKind::BinOp { lhs: Box::new(Expr { @@ -456,15 +456,13 @@ mod tests { kind: crate::ast::BinOpKind::Add, }, span: 1..1 - }), - Err(Error { - kind: ErrorKind::ArithmeticError, - span: _, }) - )); + .unwrap(), + Value::Int(42) + ); // And the same for divide by zero. - assert!(matches!( + assert_eq!( env.eval_expr(&Expr { kind: ExprKind::BinOp { lhs: Box::new(Expr { @@ -478,12 +476,10 @@ mod tests { kind: crate::ast::BinOpKind::Divide, }, 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