blob: 16e7fb7c653ed07e687f2a12e59de4fb788df769 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use lambda::io::{batch_eval, eval_file, repl};
#[test]
fn interpreter_can_read_and_interpret_file() {
assert_eq!("12 foo true (x x)", eval_file("sample/test.txt"));
assert_eq!("true", eval_file("sample/test_full.txt"));
assert_eq!("1", eval_file("sample/test_normal.txt"));
assert_eq!("13", eval_file("sample/test_let.txt"));
}
#[test]
fn repl_can_read_and_interpret_input() {
let input = "(def id (lam x x))\n(id 12)";
let mut output = Vec::new();
repl(&mut input.as_bytes(), &mut output);
assert_eq!("> true\n> 12\n> ", String::from_utf8(output).unwrap());
}
#[test]
fn repl_can_read_and_interpret_input_in_batch_mode() {
let input = "(def id (lam x x))\n(id 12)";
let mut output = Vec::new();
batch_eval(&mut input.as_bytes(), &mut output);
assert_eq!("true\n12\n", String::from_utf8(output).unwrap());
}
|