MCPcopy
hub / github.com/expr-lang/expr / TestOptimize_constant_folding_with_floats

Function TestOptimize_constant_folding_with_floats

optimizer/fold_test.go:29–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27}
28
29func TestOptimize_constant_folding_with_floats(t *testing.T) {
30 tree, err := parser.Parse(`1 + 2.0 * ((1.0 * 2) / 2) - 0`)
31 require.NoError(t, err)
32
33 err = optimizer.Optimize(&tree.Node, nil)
34 require.NoError(t, err)
35
36 expected := &ast.FloatNode{Value: 3.0}
37
38 assert.Equal(t, ast.Dump(expected), ast.Dump(tree.Node))
39 assert.Equal(t, reflect.Float64, tree.Node.Type().Kind())
40}
41
42func TestOptimize_constant_folding_with_bools(t *testing.T) {
43 tree, err := parser.Parse(`(true and false) or (true or false) or (false and false) or (true and (true == false))`)

Callers

nothing calls this directly

Calls 6

ParseFunction · 0.92
NoErrorFunction · 0.92
OptimizeFunction · 0.92
EqualFunction · 0.92
DumpFunction · 0.92
TypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…