Skip to content

Commit 2368f72

Browse files
committed
Add test for named array
1 parent 3da76a4 commit 2368f72

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

expr_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,32 @@ func TestIssue270(t *testing.T) {
15091509
}
15101510
}
15111511

1512+
func TestIssue271(t *testing.T) {
1513+
type BarArray []float64
1514+
1515+
type Foo struct {
1516+
Bar BarArray
1517+
Baz int
1518+
}
1519+
1520+
type Env struct {
1521+
Foo Foo
1522+
}
1523+
1524+
code := `Foo.Bar[0]`
1525+
1526+
program, err := expr.Compile(code, expr.Env(Env{}))
1527+
require.NoError(t, err)
1528+
1529+
output, err := expr.Run(program, Env{
1530+
Foo: Foo{
1531+
Bar: BarArray{1.0, 2.0, 3.0},
1532+
},
1533+
})
1534+
require.NoError(t, err)
1535+
require.Equal(t, 1.0, output)
1536+
}
1537+
15121538
// Mock types
15131539
type mockEnv struct {
15141540
Any interface{}

0 commit comments

Comments
 (0)