MCPcopy Index your code
hub / github.com/expr-lang/expr / TestOptimize_count_threshold_lte

Function TestOptimize_count_threshold_lte

optimizer/count_threshold_test.go:72–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestOptimize_count_threshold_lte(t *testing.T) {
73 tree, err := parser.Parse(`count(items, .active) <= 50`)
74 require.NoError(t, err)
75
76 err = optimizer.Optimize(&tree.Node, nil)
77 require.NoError(t, err)
78
79 // Operator should remain <=, but count should have threshold set
80 binary, ok := tree.Node.(*BinaryNode)
81 require.True(t, ok, "expected BinaryNode, got %T", tree.Node)
82 assert.Equal(t, "<=", binary.Operator)
83
84 count, ok := binary.Left.(*BuiltinNode)
85 require.True(t, ok, "expected BuiltinNode, got %T", binary.Left)
86 assert.Equal(t, "count", count.Name)
87 require.NotNil(t, count.Threshold)
88 assert.Equal(t, 51, *count.Threshold) // threshold = N + 1 for <= operator
89}
90
91func TestOptimize_count_threshold_correctness(t *testing.T) {
92 tests := []struct {

Callers

nothing calls this directly

Calls 6

ParseFunction · 0.92
NoErrorFunction · 0.92
OptimizeFunction · 0.92
TrueFunction · 0.92
EqualFunction · 0.92
NotNilFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…