diff options
| author | Arnaud Bailly <arnaud.bailly@iohk.io> | 2025-01-25 10:45:41 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud.bailly@iohk.io> | 2025-01-25 10:45:41 +0100 |
| commit | 7752d73216578d5961751b5d0535088d384b4aa6 (patch) | |
| tree | 786e46fe1276e93ade0a48398cd4c9ac13081707 /lambda-calcul/rust/tests | |
| parent | d6f68e919db51d366c8ca3c1509bea12aa81d692 (diff) | |
| download | lambda-nantes-7752d73216578d5961751b5d0535088d384b4aa6.tar.gz | |
Move λ-calcul workshop code to subdirectory
Diffstat (limited to 'lambda-calcul/rust/tests')
| -rw-r--r-- | lambda-calcul/rust/tests/interpret_test.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lambda-calcul/rust/tests/interpret_test.rs b/lambda-calcul/rust/tests/interpret_test.rs new file mode 100644 index 0000000..16e7fb7 --- /dev/null +++ b/lambda-calcul/rust/tests/interpret_test.rs @@ -0,0 +1,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()); +} |
