-
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.repeat
as built-in
- Loading branch information
Showing
21 changed files
with
120 additions
and
21 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -744,6 +744,7 @@ pub(super) enum BuiltInFunc { | |
Foldl, | ||
Foldr, | ||
Range, | ||
Repeat, | ||
Slice, | ||
Join, | ||
Reverse, | ||
|
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
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
4 changes: 2 additions & 2 deletions
4
ui-tests/fail/stdlib/manifestToml/manifest_function.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
4 changes: 2 additions & 2 deletions
4
ui-tests/fail/stdlib/manifestToml/manifest_null.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
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.repeat(null, 0) |
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.repeat` is expected to be string or array, got null | ||
note: while evaluating call to `repeat` | ||
--> invalid_arg_1.jsonnet:1:1 | ||
| | ||
1 | std.repeat(null, 0) | ||
| ------------------- | ||
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.repeat("", 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.repeat` is expected to be number, got null | ||
note: while evaluating call to `repeat` | ||
--> invalid_arg_2.jsonnet:1:1 | ||
| | ||
1 | std.repeat("", 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.repeat("", 1.5) |
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: invalid count value 1.5 | ||
note: while evaluating call to `repeat` | ||
--> non_integer_count.jsonnet:1:1 | ||
| | ||
1 | std.repeat("", 1.5) | ||
| ------------------- | ||
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,27 @@ | ||
std.assertEqual(std.repeat("", 0), "") && | ||
std.assertEqual(std.repeat("", 1), "") && | ||
std.assertEqual(std.repeat("", 2), "") && | ||
std.assertEqual(std.repeat("", 1000), "") && | ||
std.assertEqual(std.repeat("a", 0), "") && | ||
std.assertEqual(std.repeat("a", 1), "a") && | ||
std.assertEqual(std.repeat("a", 2), "aa") && | ||
std.assertEqual(std.repeat("a", 5), "aaaaa") && | ||
std.assertEqual(std.repeat("ab", 0), "") && | ||
std.assertEqual(std.repeat("ab", 1), "ab") && | ||
std.assertEqual(std.repeat("ab", 2), "abab") && | ||
std.assertEqual(std.repeat("ab", 5), "ababababab") && | ||
|
||
std.assertEqual(std.repeat([], 0), []) && | ||
std.assertEqual(std.repeat([], 1), []) && | ||
std.assertEqual(std.repeat([], 2), []) && | ||
std.assertEqual(std.repeat([], 1000), []) && | ||
std.assertEqual(std.repeat([1], 0), []) && | ||
std.assertEqual(std.repeat([1], 1), [1]) && | ||
std.assertEqual(std.repeat([1], 2), [1, 1]) && | ||
std.assertEqual(std.repeat([1], 5), [1, 1, 1, 1, 1]) && | ||
std.assertEqual(std.repeat(["a", "b"], 0), []) && | ||
std.assertEqual(std.repeat(["a", "b"], 1), ["a", "b"]) && | ||
std.assertEqual(std.repeat(["a", "b"], 2), ["a", "b", "a", "b"]) && | ||
std.assertEqual(std.repeat(["a", "b"], 5), ["a", "b", "a", "b", "a", "b", "a", "b", "a", "b"]) && | ||
|
||
true |