From d1064802ec82ebbafb60e240eb5245aa6f8faddb 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 27dd2b1..da0560a 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