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

Function TestArrayComparison

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

Source from the content-addressed store, hash-verified

2649}
2650
2651func 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
2677func TestIssue_570(t *testing.T) {
2678 type Student struct {

Callers

nothing calls this directly

Calls 6

CompileFunction · 0.92
EnvStruct · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…