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

Function TestPredicateCombination

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

Source from the content-addressed store, hash-verified

2616}
2617
2618func TestPredicateCombination(t *testing.T) {
2619 tests := []struct {
2620 code1 string
2621 code2 string
2622 }{
2623 {"all(1..3, {# > 0}) && all(1..3, {# < 4})", "all(1..3, {# > 0 && # < 4})"},
2624 {"all(1..3, {# > 1}) && all(1..3, {# < 4})", "all(1..3, {# > 1 && # < 4})"},
2625 {"all(1..3, {# > 0}) && all(1..3, {# < 2})", "all(1..3, {# > 0 && # < 2})"},
2626 {"all(1..3, {# > 1}) && all(1..3, {# < 2})", "all(1..3, {# > 1 && # < 2})"},
2627
2628 {"any(1..3, {# > 0}) || any(1..3, {# < 4})", "any(1..3, {# > 0 || # < 4})"},
2629 {"any(1..3, {# > 1}) || any(1..3, {# < 4})", "any(1..3, {# > 1 || # < 4})"},
2630 {"any(1..3, {# > 0}) || any(1..3, {# < 2})", "any(1..3, {# > 0 || # < 2})"},
2631 {"any(1..3, {# > 1}) || any(1..3, {# < 2})", "any(1..3, {# > 1 || # < 2})"},
2632
2633 {"none(1..3, {# > 0}) && none(1..3, {# < 4})", "none(1..3, {# > 0 || # < 4})"},
2634 {"none(1..3, {# > 1}) && none(1..3, {# < 4})", "none(1..3, {# > 1 || # < 4})"},
2635 {"none(1..3, {# > 0}) && none(1..3, {# < 2})", "none(1..3, {# > 0 || # < 2})"},
2636 {"none(1..3, {# > 1}) && none(1..3, {# < 2})", "none(1..3, {# > 1 || # < 2})"},
2637 }
2638 for _, tt := range tests {
2639 t.Run(tt.code1, func(t *testing.T) {
2640 out1, err := expr.Eval(tt.code1, nil)
2641 require.NoError(t, err)
2642
2643 out2, err := expr.Eval(tt.code2, nil)
2644 require.NoError(t, err)
2645
2646 require.Equal(t, out1, out2)
2647 })
2648 }
2649}
2650
2651func TestArrayComparison(t *testing.T) {
2652 tests := []struct {

Callers

nothing calls this directly

Calls 4

EvalFunction · 0.92
NoErrorFunction · 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…