mirror of
https://github.com/google/go-jsonnet.git
synced 2025-09-28 08:51:01 +02:00
parent
6140a2f75a
commit
31d71aaccd
@ -31,11 +31,21 @@ func prepareStdlib(g *typeGraph) {
|
||||
"length": g.newSimpleFuncType(numberType, "x"),
|
||||
"objectHas": g.newSimpleFuncType(boolType, "o", "f"),
|
||||
"objectFields": g.newSimpleFuncType(arrayOfString, "o"),
|
||||
"objectValues": g.newSimpleFuncType(anyArrayType, "o"),
|
||||
"objectHasAll": g.newSimpleFuncType(boolType, "o", "f"),
|
||||
"objectFieldsAll": g.newSimpleFuncType(arrayOfString, "o"),
|
||||
"objectValuesAll": g.newSimpleFuncType(anyArrayType, "o"),
|
||||
"prune": g.newSimpleFuncType(anyObjectType, "a"),
|
||||
"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
|
||||
"abs": 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
|
||||
],
|
||||
"format": "test blah 42",
|
||||
"isArray": true,
|
||||
"isBoolean": true,
|
||||
"isFunction": true,
|
||||
"isNumber": true,
|
||||
"isObject": true,
|
||||
"isString": true,
|
||||
"join": "a,b,c",
|
||||
"length": 0,
|
||||
"lines": "a\nb\nc\n",
|
||||
@ -115,8 +121,11 @@
|
||||
"mergePatch": { },
|
||||
"min": 2,
|
||||
"objectFields": [ ],
|
||||
"objectFieldsAll": [ ],
|
||||
"objectHas": false,
|
||||
"objectHasAll": false,
|
||||
"objectValues": [ ],
|
||||
"objectValuesAll": [ ],
|
||||
"parseHex": 3735928559,
|
||||
"parseInt": 42,
|
||||
"parseJson": {
|
||||
|
11
testdata/stdlib_smoke_test.jsonnet
vendored
11
testdata/stdlib_smoke_test.jsonnet
vendored
@ -15,10 +15,21 @@
|
||||
length: std.length(x=[]),
|
||||
objectHas: std.objectHas(o={}, f="fieldname"),
|
||||
objectFields: std.objectFields(o={}),
|
||||
objectValues: std.objectValues(o={}),
|
||||
objectHasAll: std.objectHasAll(o={}, f="fieldname"),
|
||||
objectFieldsAll: std.objectFieldsAll(o={}),
|
||||
objectValuesAll: std.objectValuesAll(o={}),
|
||||
prune: std.prune(a={x: null, y: [null, "42"]}),
|
||||
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
|
||||
abs: std.abs(n=-42),
|
||||
sign: std.sign(n=17),
|
||||
|
Loading…
x
Reference in New Issue
Block a user