Fix unit tests

This commit is contained in:
Alex Bethel 2021-06-07 17:35:49 -05:00
parent aedeeb2512
commit b6a4ecba29

View file

@ -361,7 +361,7 @@ mod tests {
#[test]
fn basic_expression_test() {
// Check that 2 + 2 = 4.
let mut env = ExecEnv::new();
let env = ExecEnv::new();
assert_eq!(
env.eval_expr(&Expr {
kind: ExprKind::BinOp {
@ -386,7 +386,7 @@ mod tests {
fn type_errors() {
// The sum of an integer and a boolean results in a type
// error.
let mut env = ExecEnv::new();
let env = ExecEnv::new();
assert!(matches!(
env.eval_expr(&Expr {
kind: ExprKind::BinOp {
@ -413,7 +413,7 @@ mod tests {
fn overflow_should_not_panic() {
// Integer overflow should throw a recoverable error instead
// of panicking.
let mut env = ExecEnv::new();
let env = ExecEnv::new();
assert!(matches!(
env.eval_expr(&Expr {
kind: ExprKind::BinOp {
@ -447,7 +447,7 @@ mod tests {
kind: ExprKind::Literal(Value::Int(0)),
span: 0..0,
}),
kind: crate::ast::BinOpKind::Add,
kind: crate::ast::BinOpKind::Divide,
},
span: 0..0
}),
@ -467,10 +467,11 @@ mod tests {
// We can assume there won't be any syntax errors in the
// interpreter tests.
let ast = parser.init().unwrap();
env.eval_items(&ast)
env.eval_stmts(&ast)
}
#[test]
#[ignore = "doesn't make sense anymore due to separation of statements & expressions"]
fn variable_decl_and_assignment() {
// Declaring and reading from a variable.
assert_eq!(
@ -490,6 +491,7 @@ mod tests {
}
#[test]
#[ignore = "doesn't make sense anymore due to separation of statements & expressions"]
fn variable_persistence() {
// Global variables should persist between invocations of
// ExecEnv::eval_items().
@ -499,6 +501,7 @@ mod tests {
}
#[test]
#[ignore = "doesn't make sense anymore due to separation of statements & expressions"]
fn scope_visibility_rules() {
// Declaration and assignment of variables declared in an `if`
// statement should have no effect on those declared outside