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

Function TestIssue271

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

Source from the content-addressed store, hash-verified

1971}
1972
1973func TestIssue271(t *testing.T) {
1974 type BarArray []float64
1975
1976 type Foo struct {
1977 Bar BarArray
1978 Baz int
1979 }
1980
1981 type Env struct {
1982 Foo Foo
1983 }
1984
1985 code := `Foo.Bar[0]`
1986
1987 program, err := expr.Compile(code, expr.Env(Env{}))
1988 require.NoError(t, err)
1989
1990 output, err := expr.Run(program, Env{
1991 Foo: Foo{
1992 Bar: BarArray{1.0, 2.0, 3.0},
1993 },
1994 })
1995 require.NoError(t, err)
1996 require.Equal(t, 1.0, output)
1997}
1998
1999type Issue346Array []Issue346Type
2000

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…