From 0d0b3cc555a5bea9337986a69b475d93397eb2a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Mon, 4 Nov 2024 21:42:18 +0100 Subject: [PATCH] test(ui): add some `tailstrict` call tests --- ui-tests/pass/call.jsonnet | 24 ++++++++++++ ui-tests/pass/stdlib/trace/in_arg.jsonnet | 4 +- .../pass/stdlib/trace/in_arg.jsonnet.stderr | 37 ++++++++++++++++--- .../pass/stdlib/trace/in_arg.jsonnet.stdout | 5 ++- 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/ui-tests/pass/call.jsonnet b/ui-tests/pass/call.jsonnet index ada003f..9dad90f 100644 --- a/ui-tests/pass/call.jsonnet +++ b/ui-tests/pass/call.jsonnet @@ -74,4 +74,28 @@ std.assertEqual(f(1, error "err"), [1, 1]) && local f(x, y=error "err") = [x, x]; std.assertEqual(f(1), [1, 1]) && +local f(acc, a, b=std.repeat([null], std.length(a))) = + assert std.length(a) == std.length(b); + if std.length(a) == 0 then + acc + else + f(acc + [a[0], b[0]], a[1:], b[1:]) tailstrict; + +std.assertEqual( + f([0], std.repeat([1], 500), std.repeat([2], 500)), + [0] + std.repeat([1, 2], 500), +) && +std.assertEqual( + f(acc=[0], a=std.repeat([1], 500), b=std.repeat([2], 500)), + [0] + std.repeat([1, 2], 500), +) && +std.assertEqual( + f(acc=[0], b=std.repeat([1], 500), a=std.repeat([2], 500)), + [0] + std.repeat([2, 1], 500), +) && +std.assertEqual( + f([0], std.repeat([1], 500)), + [0] + std.repeat([1, null], 500), +) && + true diff --git a/ui-tests/pass/stdlib/trace/in_arg.jsonnet b/ui-tests/pass/stdlib/trace/in_arg.jsonnet index d11d680..c1625e8 100644 --- a/ui-tests/pass/stdlib/trace/in_arg.jsonnet +++ b/ui-tests/pass/stdlib/trace/in_arg.jsonnet @@ -1,3 +1,5 @@ local f(x) = x; +local f1() = f(std.trace("some trace", "some value")); +local f2() = f(std.trace("some trace", "some value")) tailstrict; -f(std.trace("some trace", "some value")) +[f1(), f2()] diff --git a/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stderr b/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stderr index 43fb164..f6085f9 100644 --- a/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stderr +++ b/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stderr @@ -1,18 +1,43 @@ TRACE: some trace note: while evaluating call to `trace` - --> in_arg.jsonnet:3:3 + --> in_arg.jsonnet:2:16 | -3 | f(std.trace("some trace", "some value")) - | ------------------------------------- +2 | local f1() = f(std.trace("some trace", "some value")); + | ------------------------------------- note: while evaluating variable `x` --> in_arg.jsonnet:1:14 | 1 | local f(x) = x; | - note: while evaluating call to `f` - --> in_arg.jsonnet:3:1 + --> in_arg.jsonnet:2:14 | -3 | f(std.trace("some trace", "some value")) - | ---------------------------------------- +2 | local f1() = f(std.trace("some trace", "some value")); + | ---------------------------------------- +note: while evaluating call to `f1` + --> in_arg.jsonnet:5:2 + | +5 | [f1(), f2()] + | ---- +note: while evaluating array item 0 +note: during top-level value evaluation + +TRACE: some trace +note: while evaluating call to `trace` + --> in_arg.jsonnet:3:16 + | +3 | local f2() = f(std.trace("some trace", "some value")) tailstrict; + | ------------------------------------- +note: while evaluating variable `x` + --> in_arg.jsonnet:3:14 + | +3 | local f2() = f(std.trace("some trace", "some value")) tailstrict; + | --------------------------------------------------- +note: while evaluating call to `f2` + --> in_arg.jsonnet:5:8 + | +5 | [f1(), f2()] + | ---- +note: while evaluating array item 1 note: during top-level value evaluation diff --git a/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stdout b/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stdout index 288f8fd..24e1397 100644 --- a/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stdout +++ b/ui-tests/pass/stdlib/trace/in_arg.jsonnet.stdout @@ -1 +1,4 @@ -"some value" +[ + "some value", + "some value" +]