From 01765c3717579dc985f4b6c15a5b0b2fcf1dc4da Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Sat, 6 Jul 2024 11:04:21 -0400 Subject: [PATCH] test(tvix/cli): Add some additional REPL tests A couple of already-passing tests covering REPL behavior Change-Id: Ie21f4abf68ab12827fd15128a8ef810cd8592d07 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11959 Reviewed-by: flokli Tested-by: BuildkiteCI Autosubmit: aspen --- tvix/cli/tests/repl.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tvix/cli/tests/repl.rs b/tvix/cli/tests/repl.rs index 8d49e7771..a14f4bff7 100644 --- a/tvix/cli/tests/repl.rs +++ b/tvix/cli/tests/repl.rs @@ -25,3 +25,45 @@ test_repl!(simple_expr_eval() { => 1 :: int "#]]; }); + +test_repl!(multiline_input() { + "{ x = 1; " => expect![[""]]; + "y = 2; }" => expect![[r#" + => { x = 1; y = 2; } :: set + "#]]; +}); + +test_repl!(bind_literal() { + "x = 1" => expect![[""]]; + "x" => expect![[r#" + => 1 :: int + "#]]; +}); + +test_repl!(bind_lazy() { + "x = { z = 1; }" => expect![[""]]; + "x" => expect![[r#" + => { z = 1; } :: set + "#]]; + "x.z" => expect![[r#" + => 1 :: int + "#]]; + "x.z" => expect![[r#" + => 1 :: int + "#]]; +}); + +test_repl!(deep_print() { + "builtins.map (x: x + 1) [ 1 2 3 ]" => expect![[r#" + => [ ] :: list + "#]]; + ":p builtins.map (x: x + 1) [ 1 2 3 ]" => expect![[r#" + => [ 2 3 4 ] :: list + "#]]; +}); + +test_repl!(explain() { + ":d { x = 1; y = [ 2 3 4 ]; }" => expect![[r#" + => a 2-item attribute set + "#]]; +});