| 2649 | } |
| 2650 | |
| 2651 | func TestArrayComparison(t *testing.T) { |
| 2652 | tests := []struct { |
| 2653 | env any |
| 2654 | code string |
| 2655 | }{ |
| 2656 | {[]string{"A", "B"}, "foo == ['A', 'B']"}, |
| 2657 | {[]int{1, 2}, "foo == [1, 2]"}, |
| 2658 | {[]uint8{1, 2}, "foo == [1, 2]"}, |
| 2659 | {[]float64{1.1, 2.2}, "foo == [1.1, 2.2]"}, |
| 2660 | {[]any{"A", 1, 1.1, true}, "foo == ['A', 1, 1.1, true]"}, |
| 2661 | {[]string{"A", "B"}, "foo != [1, 2]"}, |
| 2662 | } |
| 2663 | |
| 2664 | for _, tt := range tests { |
| 2665 | t.Run(tt.code, func(t *testing.T) { |
| 2666 | env := map[string]any{"foo": tt.env} |
| 2667 | program, err := expr.Compile(tt.code, expr.Env(env)) |
| 2668 | require.NoError(t, err) |
| 2669 | |
| 2670 | out, err := expr.Run(program, env) |
| 2671 | require.NoError(t, err) |
| 2672 | require.Equal(t, true, out) |
| 2673 | }) |
| 2674 | } |
| 2675 | } |
| 2676 | |
| 2677 | func TestIssue_570(t *testing.T) { |
| 2678 | type Student struct { |