-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change(eval): implement
std.mapWithKey
as built-in
- Loading branch information
Showing
11 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
std.mapWithKey(null, {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: first argument of `std.mapWithKey` is expected to be function, got null | ||
note: while evaluating call to `mapWithKey` | ||
--> invalid_arg_1.jsonnet:1:1 | ||
| | ||
1 | std.mapWithKey(null, {}) | ||
| ------------------------ | ||
note: during top-level value evaluation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
std.mapWithKey(function(k, v) null, null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: second argument of `std.mapWithKey` is expected to be object, got null | ||
note: while evaluating call to `mapWithKey` | ||
--> invalid_arg_2.jsonnet:1:1 | ||
| | ||
1 | std.mapWithKey(function(k, v) null, null) | ||
| ----------------------------------------- | ||
note: during top-level value evaluation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
std.mapWithKey(function(k, v) null, { assert false }) |
12 changes: 12 additions & 0 deletions
12
ui-tests/fail/stdlib/mapWithKey/object_assert_failed.jsonnet.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: assertion failed | ||
--> object_assert_failed.jsonnet:1:39 | ||
| | ||
1 | std.mapWithKey(function(k, v) null, { assert false }) | ||
| ^^^^^^^^^^^^ | ||
note: while evaluating call to `mapWithKey` | ||
--> object_assert_failed.jsonnet:1:1 | ||
| | ||
1 | std.mapWithKey(function(k, v) null, { assert false }) | ||
| ----------------------------------------------------- | ||
note: during top-level value evaluation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
std.assertEqual(std.mapWithKey(function(k, v) error "err", {}), {}) && | ||
std.assertEqual( | ||
std.mapWithKey(function(k, v) k + ":" + v, { a: 1, b: 2 }), | ||
{ a: "a:1", b: "b:2" }, | ||
) && | ||
std.assertEqual( | ||
std.mapWithKey(std.format, { "%i": 9, "%x": 10 }), | ||
{ "%i": "9", "%x": "a" }, | ||
) && | ||
std.assertEqual( | ||
std.objectFieldsAll(std.mapWithKey(function(k, v) k + ":" + v, { a: 1, b: 2, c:: 3 })), | ||
["a", "b"], | ||
) && | ||
|
||
true |