Skip to content

Commit

Permalink
test(ui): add some tailstrict call tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosm committed Nov 4, 2024
1 parent 9706554 commit 0d0b3cc
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 8 deletions.
24 changes: 24 additions & 0 deletions ui-tests/pass/call.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion ui-tests/pass/stdlib/trace/in_arg.jsonnet
Original file line number Diff line number Diff line change
@@ -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()]
37 changes: 31 additions & 6 deletions ui-tests/pass/stdlib/trace/in_arg.jsonnet.stderr
Original file line number Diff line number Diff line change
@@ -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

5 changes: 4 additions & 1 deletion ui-tests/pass/stdlib/trace/in_arg.jsonnet.stdout
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
"some value"
[
"some value",
"some value"
]

0 comments on commit 0d0b3cc

Please sign in to comment.