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

Function TestExpr_optional_chaining_nested_chains

expr_test.go:1530–1547  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1528}
1529
1530func TestExpr_optional_chaining_nested_chains(t *testing.T) {
1531 env := map[string]any{
1532 "foo": map[string]any{
1533 "id": 1,
1534 "bar": []map[string]any{
1535 1: {
1536 "baz": "baz",
1537 },
1538 },
1539 },
1540 }
1541 program, err := expr.Compile("foo?.bar[foo?.id]?.baz", expr.Env(env))
1542 require.NoError(t, err)
1543
1544 got, err := expr.Run(program, env)
1545 require.NoError(t, err)
1546 assert.Equal(t, "baz", got)
1547}
1548
1549func TestExpr_optional_chaining_array(t *testing.T) {
1550 env := map[string]any{}

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…