()
| 37 | ) |
| 38 | |
| 39 | func init() { |
| 40 | paramA := types.NewTypeParamType("A") |
| 41 | paramB := types.NewTypeParamType("B") |
| 42 | listOfA := types.NewListType(paramA) |
| 43 | mapOfAB := types.NewMapType(paramA, paramB) |
| 44 | |
| 45 | stdTypes = []*decls.VariableDecl{ |
| 46 | decls.TypeVariable(types.BoolType), |
| 47 | decls.TypeVariable(types.BytesType), |
| 48 | decls.TypeVariable(types.DoubleType), |
| 49 | decls.TypeVariable(types.DurationType), |
| 50 | decls.TypeVariable(types.IntType), |
| 51 | decls.TypeVariable(listOfA), |
| 52 | decls.TypeVariable(mapOfAB), |
| 53 | decls.TypeVariable(types.NullType), |
| 54 | decls.TypeVariable(types.StringType), |
| 55 | decls.TypeVariable(types.TimestampType), |
| 56 | decls.TypeVariable(types.TypeType), |
| 57 | decls.TypeVariable(types.UintType), |
| 58 | } |
| 59 | |
| 60 | stdFunctions = []*decls.FunctionDecl{ |
| 61 | // Logical operators. Special-cased within the interpreter. |
| 62 | // Note, the singleton binding prevents extensions from overriding the operator behavior. |
| 63 | function(operators.Conditional, |
| 64 | decls.FunctionDocs( |
| 65 | `The ternary operator tests a boolean predicate and returns the left-hand side `+ |
| 66 | `(truthy) expression if true, or the right-hand side (falsy) expression if false`), |
| 67 | decls.Overload(overloads.Conditional, argTypes(types.BoolType, paramA, paramA), paramA, |
| 68 | decls.OverloadIsNonStrict(), |
| 69 | decls.OverloadExamples( |
| 70 | `'hello'.contains('lo') ? 'hi' : 'bye' // 'hi'`, |
| 71 | `32 % 3 == 0 ? 'divisible' : 'not divisible' // 'not divisible'`)), |
| 72 | decls.SingletonFunctionBinding(noFunctionOverrides)), |
| 73 | |
| 74 | function(operators.LogicalAnd, |
| 75 | decls.FunctionDocs( |
| 76 | `logically AND two boolean values. Errors and unknown values`, |
| 77 | `are valid inputs and will not halt evaluation.`), |
| 78 | decls.Overload(overloads.LogicalAnd, argTypes(types.BoolType, types.BoolType), types.BoolType, |
| 79 | decls.OverloadIsNonStrict(), |
| 80 | decls.OverloadExamples( |
| 81 | `true && true // true`, |
| 82 | `true && false // false`, |
| 83 | `error && true // error`, |
| 84 | `error && false // false`)), |
| 85 | decls.SingletonBinaryBinding(noBinaryOverrides)), |
| 86 | |
| 87 | function(operators.LogicalOr, |
| 88 | decls.FunctionDocs( |
| 89 | `logically OR two boolean values. Errors and unknown values`, |
| 90 | `are valid inputs and will not halt evaluation.`), |
| 91 | decls.Overload(overloads.LogicalOr, argTypes(types.BoolType, types.BoolType), types.BoolType, |
| 92 | decls.OverloadIsNonStrict(), |
| 93 | decls.OverloadExamples( |
| 94 | `true || false // true`, |
| 95 | `false || false // false`, |
| 96 | `error || true // true`, |
nothing calls this directly
no test coverage detected