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