Add general test for functions as example

This commit is contained in:
2022-02-10 12:19:01 +01:00
parent c4d2f89d35
commit f2331d7de9
2 changed files with 49 additions and 0 deletions

View File

@@ -114,5 +114,23 @@ mod tests {
assert_eq!(interpreter.output(), &expected_output);
}
#[test]
fn test_functions() {
let filename = "test_functions.nek";
let correct_result = 69;
let mut interpreter = Interpreter::new();
interpreter.capture_output = true;
let code = read_to_string(format!("examples/{filename}")).unwrap();
interpreter.run_str(&code);
let expected_output = [Value::I64(correct_result)];
assert_eq!(interpreter.output(), &expected_output);
}
}