diff options
9 files changed, 63 insertions, 3 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-import-display.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-import-display.exp new file mode 100644 index 000000000000..15d838950e7a --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-import-display.exp @@ -0,0 +1 @@ +<PRIMOP> diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-import-display.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-import-display.nix new file mode 100644 index 000000000000..411f3cd6ef63 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-import-display.nix @@ -0,0 +1,2 @@ +# In C++ Nix 2.3 this used to be <PRIMOP-APP> +import diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-value-display.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-value-display.exp new file mode 100644 index 000000000000..c7e3fc6503a5 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-value-display.exp @@ -0,0 +1 @@ +[ null true false 42 42 "foo\t\nbar" /home/arthur [ 1 2 3 ] <LAMBDA> <PRIMOP> <PRIMOP-APP> { hello = "world"; } ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-value-display.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-value-display.nix new file mode 100644 index 000000000000..d34ed1697e77 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-value-display.nix @@ -0,0 +1,16 @@ +# Sanity check of how values are rendered by tvix vs. nix-instantiate(1). +# Ensures that we can use this test suite to compare against C++ Nix. +[ + null + true + false + 42 + 42.0 + "foo\t\nbar" + /home/arthur + [ 1 2 3 ] + (x: x) + builtins.add + (builtins.substring 0 1) + { hello = "world"; } +] diff --git a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-cycle-display-cpp-nix-2.13.exp b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-cycle-display-cpp-nix-2.13.exp new file mode 100644 index 000000000000..9c44023f02dd --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-cycle-display-cpp-nix-2.13.exp @@ -0,0 +1 @@ +[ { car = 42; cdr = «repeated»; } [ «repeated» «repeated» «repeated» ] { val = 42; wal = «repeated»; xal = «repeated»; } { tail1 = «repeated»; tail2 = «repeated»; val = 42; } { tail1 = «repeated»; tail2 = «repeated»; val = 21; } ] diff --git a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-cycle-display-cpp-nix-2.13.nix b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-cycle-display-cpp-nix-2.13.nix new file mode 100644 index 000000000000..bd3b1429cef3 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-cycle-display-cpp-nix-2.13.nix @@ -0,0 +1,34 @@ +let + linkedList = { + car = 42; + cdr = linkedList; + }; + + list = [ + linkedList + linkedList + linkedList + ]; + + set = { + val = 42; + wal = set; + xal = set; + }; + + multiTail = { + val = 42; + tail1 = multiTail; + tail2 = multiTail; + }; +in + +[ + linkedList + list + set + + # In C++ Nix 2.3 these would be displayed differently + multiTail + (let multiTail = { val = 21; tail1 = multiTail; tail2 = multiTail; }; in multiTail) +] diff --git a/tvix/eval/src/value/builtin.rs b/tvix/eval/src/value/builtin.rs index 6d08ebf9506d..b6946d786e08 100644 --- a/tvix/eval/src/value/builtin.rs +++ b/tvix/eval/src/value/builtin.rs @@ -121,9 +121,9 @@ impl Debug for Builtin { impl Display for Builtin { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if !self.0.partials.is_empty() { - f.write_str("<<primop-app>>") + f.write_str("<PRIMOP-APP>") } else { - f.write_str("<<primop>>") + f.write_str("<PRIMOP>") } } } diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 34353df3a72c..7e701d52ba25 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -758,7 +758,8 @@ impl TotalDisplay for Value { Value::Path(p) => p.display().fmt(f), Value::Attrs(attrs) => attrs.total_fmt(f, set), Value::List(list) => list.total_fmt(f, set), - Value::Closure(_) => f.write_str("lambda"), // TODO: print position + // TODO: fancy REPL display with position + Value::Closure(_) => f.write_str("<LAMBDA>"), Value::Builtin(builtin) => builtin.fmt(f), // Nix prints floats with a maximum precision of 5 digits diff --git a/tvix/verify-lang-tests/default.nix b/tvix/verify-lang-tests/default.nix index 2267ecb77d2e..ef67aeb48986 100644 --- a/tvix/verify-lang-tests/default.nix +++ b/tvix/verify-lang-tests/default.nix @@ -59,6 +59,10 @@ let "eval-okay-getattrpos-functionargs.nix" = [ nix ]; # groupBy appeared (long) after 2.3 "eval-okay-builtins-groupby-thunk.nix" = [ nix ]; + # import is no longer considered a curried primop in Nix > 2.3 + "eval-okay-import-display.nix" = [ nix ]; + # Cycle detection and formatting changed sometime after Nix 2.3 + "eval-okay-cycle-display-cpp-nix-2.13.nix" = [ nix ]; }; runCppNixLangTests = cpp-nix: |