Fix strip definition

Co-authored-by: Tom Fenech <tomjwfenech@gmail.com>
This commit is contained in:
Yiannis 2021-05-19 13:57:47 +02:00 committed by GitHub
parent bead95bfa6
commit ce76155e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -78,9 +78,9 @@ func prepareStdlib(g *typeGraph) {
"findSubstr": g.newSimpleFuncType(arrayOfNumber, "pat", "str"), "findSubstr": g.newSimpleFuncType(arrayOfNumber, "pat", "str"),
"startsWith": g.newSimpleFuncType(boolType, "a", "b"), "startsWith": g.newSimpleFuncType(boolType, "a", "b"),
"endsWith": g.newSimpleFuncType(boolType, "a", "b"), "endsWith": g.newSimpleFuncType(boolType, "a", "b"),
"stripChars": g.newSimpleFuncType(stringType, "chars"), "stripChars": g.newSimpleFuncType(stringType, "str", "chars"),
"lstripChars": g.newSimpleFuncType(stringType, "chars"), "lstripChars": g.newSimpleFuncType(stringType, "str", "chars"),
"rstripChars": g.newSimpleFuncType(stringType, "chars"), "rstripChars": g.newSimpleFuncType(stringType, "str", "chars"),
"split": g.newSimpleFuncType(arrayOfString, "str", "c"), "split": g.newSimpleFuncType(arrayOfString, "str", "c"),
"splitLimit": g.newSimpleFuncType(arrayOfString, "str", "c", "maxsplits"), "splitLimit": g.newSimpleFuncType(arrayOfString, "str", "c", "maxsplits"),
"strReplace": g.newSimpleFuncType(stringType, "str", "from", "to"), "strReplace": g.newSimpleFuncType(stringType, "str", "from", "to"),

View File

@ -96,6 +96,7 @@
"length": 0, "length": 0,
"lines": "a\nb\nc\n", "lines": "a\nb\nc\n",
"log": 1.6094379124341003, "log": 1.6094379124341003,
"lstripChars": "bbbbcccc",
"makeArray": [ "makeArray": [
0, 0,
1, 1,
@ -155,6 +156,7 @@
5 5
], ],
"repeat": "foofoofoo", "repeat": "foofoofoo",
"rstripChars": "aaabbbb",
"set": [ "set": [
[ [
1, 1,
@ -238,6 +240,7 @@
"a", "a",
"h" "h"
], ],
"stripChars": "bbbb",
"substr": "s", "substr": "s",
"tan": -3.3805150062465854, "tan": -3.3805150062465854,
"thisFile": "testdata/stdlib_smoke_test", "thisFile": "testdata/stdlib_smoke_test",

View File

@ -61,6 +61,9 @@
findSubstr: std.findSubstr(pat="test", str="test test"), findSubstr: std.findSubstr(pat="test", str="test test"),
startsWith: std.startsWith(a="jsonnet", b="json"), startsWith: std.startsWith(a="jsonnet", b="json"),
endsWith: std.endsWith(a="jsonnet", b="sonnet"), endsWith: std.endsWith(a="jsonnet", b="sonnet"),
stripChars: std.stripChars(str="aaabbbbcccc", chars="ac"),
lstripChars: std.lstripChars(str="aaabbbbcccc", chars="a"),
rstripChars: std.rstripChars(str="aaabbbbcccc", chars="c"),
split: std.split(str="a,b,c", c=","), split: std.split(str="a,b,c", c=","),
splitLimit: std.splitLimit(str="a,b,c", c=",", maxsplits=1), splitLimit: std.splitLimit(str="a,b,c", c=",", maxsplits=1),
strReplace: std.strReplace(str="aaa", from="aa", to="bb"), strReplace: std.strReplace(str="aaa", from="aa", to="bb"),