mirror of
https://github.com/google/go-jsonnet.git
synced 2025-09-28 17:01:02 +02:00
parent
6140a2f75a
commit
31d71aaccd
@ -31,11 +31,21 @@ func prepareStdlib(g *typeGraph) {
|
|||||||
"length": g.newSimpleFuncType(numberType, "x"),
|
"length": g.newSimpleFuncType(numberType, "x"),
|
||||||
"objectHas": g.newSimpleFuncType(boolType, "o", "f"),
|
"objectHas": g.newSimpleFuncType(boolType, "o", "f"),
|
||||||
"objectFields": g.newSimpleFuncType(arrayOfString, "o"),
|
"objectFields": g.newSimpleFuncType(arrayOfString, "o"),
|
||||||
|
"objectValues": g.newSimpleFuncType(anyArrayType, "o"),
|
||||||
"objectHasAll": g.newSimpleFuncType(boolType, "o", "f"),
|
"objectHasAll": g.newSimpleFuncType(boolType, "o", "f"),
|
||||||
"objectFieldsAll": g.newSimpleFuncType(arrayOfString, "o"),
|
"objectFieldsAll": g.newSimpleFuncType(arrayOfString, "o"),
|
||||||
|
"objectValuesAll": g.newSimpleFuncType(anyArrayType, "o"),
|
||||||
"prune": g.newSimpleFuncType(anyObjectType, "a"),
|
"prune": g.newSimpleFuncType(anyObjectType, "a"),
|
||||||
"mapWithKey": g.newSimpleFuncType(anyObjectType, "func", "obj"),
|
"mapWithKey": g.newSimpleFuncType(anyObjectType, "func", "obj"),
|
||||||
|
|
||||||
|
// isSomething
|
||||||
|
"isArray": g.newSimpleFuncType(boolType, "v"),
|
||||||
|
"isBoolean": g.newSimpleFuncType(boolType, "v"),
|
||||||
|
"isFunction": g.newSimpleFuncType(boolType, "v"),
|
||||||
|
"isNumber": g.newSimpleFuncType(boolType, "v"),
|
||||||
|
"isObject": g.newSimpleFuncType(boolType, "v"),
|
||||||
|
"isString": g.newSimpleFuncType(boolType, "v"),
|
||||||
|
|
||||||
// Mathematical utilities
|
// Mathematical utilities
|
||||||
"abs": g.newSimpleFuncType(numberType, "n"),
|
"abs": g.newSimpleFuncType(numberType, "n"),
|
||||||
"sign": g.newSimpleFuncType(numberType, "n"),
|
"sign": g.newSimpleFuncType(numberType, "n"),
|
||||||
|
1
linter/testdata/stdlib_return_type_test.jsonnet
vendored
Normal file
1
linter/testdata/stdlib_return_type_test.jsonnet
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
!std.setMember([1, 2, 3], 1)
|
0
linter/testdata/stdlib_return_type_test.linter.golden
vendored
Normal file
0
linter/testdata/stdlib_return_type_test.linter.golden
vendored
Normal file
9
testdata/stdlib_smoke_test.golden
vendored
9
testdata/stdlib_smoke_test.golden
vendored
@ -78,6 +78,12 @@
|
|||||||
4
|
4
|
||||||
],
|
],
|
||||||
"format": "test blah 42",
|
"format": "test blah 42",
|
||||||
|
"isArray": true,
|
||||||
|
"isBoolean": true,
|
||||||
|
"isFunction": true,
|
||||||
|
"isNumber": true,
|
||||||
|
"isObject": true,
|
||||||
|
"isString": true,
|
||||||
"join": "a,b,c",
|
"join": "a,b,c",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"lines": "a\nb\nc\n",
|
"lines": "a\nb\nc\n",
|
||||||
@ -115,8 +121,11 @@
|
|||||||
"mergePatch": { },
|
"mergePatch": { },
|
||||||
"min": 2,
|
"min": 2,
|
||||||
"objectFields": [ ],
|
"objectFields": [ ],
|
||||||
|
"objectFieldsAll": [ ],
|
||||||
"objectHas": false,
|
"objectHas": false,
|
||||||
"objectHasAll": false,
|
"objectHasAll": false,
|
||||||
|
"objectValues": [ ],
|
||||||
|
"objectValuesAll": [ ],
|
||||||
"parseHex": 3735928559,
|
"parseHex": 3735928559,
|
||||||
"parseInt": 42,
|
"parseInt": 42,
|
||||||
"parseJson": {
|
"parseJson": {
|
||||||
|
11
testdata/stdlib_smoke_test.jsonnet
vendored
11
testdata/stdlib_smoke_test.jsonnet
vendored
@ -15,10 +15,21 @@
|
|||||||
length: std.length(x=[]),
|
length: std.length(x=[]),
|
||||||
objectHas: std.objectHas(o={}, f="fieldname"),
|
objectHas: std.objectHas(o={}, f="fieldname"),
|
||||||
objectFields: std.objectFields(o={}),
|
objectFields: std.objectFields(o={}),
|
||||||
|
objectValues: std.objectValues(o={}),
|
||||||
objectHasAll: std.objectHasAll(o={}, f="fieldname"),
|
objectHasAll: std.objectHasAll(o={}, f="fieldname"),
|
||||||
|
objectFieldsAll: std.objectFieldsAll(o={}),
|
||||||
|
objectValuesAll: std.objectValuesAll(o={}),
|
||||||
prune: std.prune(a={x: null, y: [null, "42"]}),
|
prune: std.prune(a={x: null, y: [null, "42"]}),
|
||||||
mapWithKey: std.mapWithKey(func=function(key, value) 42, obj={a: 17}),
|
mapWithKey: std.mapWithKey(func=function(key, value) 42, obj={a: 17}),
|
||||||
|
|
||||||
|
// isSomething
|
||||||
|
isArray: std.isArray(v=[]),
|
||||||
|
isBoolean: std.isBoolean(v=true),
|
||||||
|
isFunction: std.isFunction(v=function() 42),
|
||||||
|
isNumber: std.isNumber(v=42),
|
||||||
|
isObject: std.isObject(v={}),
|
||||||
|
isString: std.isString(v=""),
|
||||||
|
|
||||||
// Mathematical utilities
|
// Mathematical utilities
|
||||||
abs: std.abs(n=-42),
|
abs: std.abs(n=-42),
|
||||||
sign: std.sign(n=17),
|
sign: std.sign(n=17),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user