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

Function TestIssue346

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

Source from the content-addressed store, hash-verified

2007}
2008
2009func TestIssue346(t *testing.T) {
2010 code := `Foo[0].Bar`
2011
2012 env := map[string]any{
2013 "Foo": Issue346Array{
2014 {Bar: "bar"},
2015 },
2016 }
2017 program, err := expr.Compile(code, expr.Env(env))
2018 require.NoError(t, err)
2019
2020 output, err := expr.Run(program, env)
2021 require.NoError(t, err)
2022 require.Equal(t, "bar", output)
2023}
2024
2025func TestCompile_allow_to_use_interface_to_get_an_element_from_map(t *testing.T) {
2026 code := `{"value": "ok"}[vars.key]`

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…