Skip to content

Commit 4fc6235

Browse files
committed
Add optimize float folds test
1 parent b26d4b7 commit 4fc6235

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

optimizer/optimizer_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ func TestOptimize_constant_folding(t *testing.T) {
2828
assert.Equal(t, ast.Dump(expected), ast.Dump(tree.Node))
2929
}
3030

31+
func TestOptimize_constant_folding_with_floats(t *testing.T) {
32+
tree, err := parser.Parse(`1 + 2.0 * ((1.0 * 2) / 2) - 0`)
33+
require.NoError(t, err)
34+
35+
err = optimizer.Optimize(&tree.Node, nil)
36+
require.NoError(t, err)
37+
38+
expected := &ast.FloatNode{Value: 3.0}
39+
40+
assert.Equal(t, ast.Dump(expected), ast.Dump(tree.Node))
41+
}
42+
3143
func TestOptimize_in_array(t *testing.T) {
3244
config := conf.New(map[string]int{"v": 0})
3345

0 commit comments

Comments
 (0)