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

Function TestOptimize_count_threshold_gt

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

Source from the content-addressed store, hash-verified

13)
14
15func TestOptimize_count_threshold_gt(t *testing.T) {
16 tree, err := parser.Parse(`count(items, .active) > 100`)
17 require.NoError(t, err)
18
19 err = optimizer.Optimize(&tree.Node, nil)
20 require.NoError(t, err)
21
22 // Operator should remain >, but count should have threshold set
23 binary, ok := tree.Node.(*BinaryNode)
24 require.True(t, ok, "expected BinaryNode, got %T", tree.Node)
25 assert.Equal(t, ">", binary.Operator)
26
27 count, ok := binary.Left.(*BuiltinNode)
28 require.True(t, ok, "expected BuiltinNode, got %T", binary.Left)
29 assert.Equal(t, "count", count.Name)
30 require.NotNil(t, count.Threshold)
31 assert.Equal(t, 101, *count.Threshold) // threshold = N + 1 for > operator
32}
33
34func TestOptimize_count_threshold_gte(t *testing.T) {
35 tree, err := parser.Parse(`count(items, .active) >= 50`)

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…