MCPcopy
hub / github.com/expr-lang/expr / TestCheck_env_keyword

Function TestCheck_env_keyword

checker/checker_test.go:1063–1090  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1061}
1062
1063func TestCheck_env_keyword(t *testing.T) {
1064 env := map[string]any{
1065 "num": 42,
1066 "str": "foo",
1067 "name": "str",
1068 }
1069
1070 tests := []struct {
1071 input string
1072 want reflect.Kind
1073 }{
1074 {`$env['str']`, reflect.String},
1075 {`$env['num']`, reflect.Int},
1076 {`$env[name]`, reflect.Interface},
1077 }
1078
1079 c := new(checker.Checker)
1080 for _, test := range tests {
1081 t.Run(test.input, func(t *testing.T) {
1082 tree, err := parser.Parse(test.input)
1083 require.NoError(t, err)
1084
1085 rtype, err := c.Check(tree, conf.New(env))
1086 require.NoError(t, err)
1087 require.True(t, rtype.Kind() == test.want, fmt.Sprintf("expected %s, got %s", test.want, rtype.Kind()))
1088 })
1089 }
1090}
1091
1092func TestCheck_builtin_without_call(t *testing.T) {
1093 tests := []struct {

Callers

nothing calls this directly

Calls 7

ParseFunction · 0.92
NoErrorFunction · 0.92
NewFunction · 0.92
TrueFunction · 0.92
RunMethod · 0.80
SprintfMethod · 0.80
CheckMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…