From bb1adbb05b1a9e6071869cf34a871a0ac49734b0 Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 6 Sep 2022 16:34:10 +0200 Subject: test(tvix/eval): add test for mutually recursive let bindings This test shows that let bindings' dependencies can form a cyclical graph, so we need to use thunking to break this cycle. Change-Id: I2a4de71fd7024f3d3d1166154784139a82f39411 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6495 Tested-by: BuildkiteCI Reviewed-by: tazjin Reviewed-by: sterni --- .../eval-okay-mutually-recursive-let-binding.exp | 1 + .../eval-okay-mutually-recursive-let-binding.nix | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.nix (limited to 'tvix/eval') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.exp new file mode 100644 index 000000000000..edca9baca9c0 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.exp @@ -0,0 +1 @@ +{ a = 1; b = 2; c = 3; } diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.nix new file mode 100644 index 000000000000..1b3feda432ef --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-mutually-recursive-let-binding.nix @@ -0,0 +1,14 @@ +let + a = { + a = 3; + b = b.b; + }; + + b = { + a = a.a - 2; + b = 2; + c = a.c or 3; + }; +in + +a // b -- cgit 1.4.1