| 35 | } |
| 36 | |
| 37 | func TestOperator_interface(t *testing.T) { |
| 38 | env := mock.Env{} |
| 39 | |
| 40 | code := `Foo == "Foo.String" && "Foo.String" == Foo && Time != Foo && Time == Time` |
| 41 | |
| 42 | program, err := expr.Compile( |
| 43 | code, |
| 44 | expr.Env(mock.Env{}), |
| 45 | expr.Operator("==", "StringerStringEqual", "StringStringerEqual", "StringerStringerEqual"), |
| 46 | expr.Operator("!=", "NotStringerStringEqual", "NotStringStringerEqual", "NotStringerStringerEqual"), |
| 47 | ) |
| 48 | require.NoError(t, err) |
| 49 | |
| 50 | output, err := expr.Run(program, env) |
| 51 | require.NoError(t, err) |
| 52 | require.Equal(t, true, output) |
| 53 | } |
| 54 | |
| 55 | type Value struct { |
| 56 | Int int |