MCPcopy Create free account
hub / github.com/expr-lang/expr / TestIssue785

Function TestIssue785

test/issues/785/issue_test.go:10–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestIssue785(t *testing.T) {
11 emptyMap := map[string]any{}
12
13 env := map[string]interface{}{
14 "empty_map": emptyMap,
15 }
16
17 {
18 code := `get(empty_map, "non_existing_key") | get("some_key") | get("another_key") | get("yet_another_key") | get("last_key")`
19
20 program, err := expr.Compile(code, expr.Env(env))
21 require.NoError(t, err)
22
23 output, err := expr.Run(program, env)
24 require.NoError(t, err)
25 require.Equal(t, nil, output)
26 }
27
28 {
29 code := `{} | get("non_existing_key") | get("some_key") | get("another_key") | get("yet_another_key") | get("last_key")`
30
31 program, err := expr.Compile(code, expr.Env(env))
32 require.NoError(t, err)
33
34 output, err := expr.Run(program, env)
35 require.NoError(t, err)
36 require.Equal(t, nil, output)
37 }
38}

Callers

nothing calls this directly

Calls 5

CompileFunction · 0.92
EnvStruct · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…