Skip to content

Commit

Permalink
Add optimize float folds test
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Nov 8, 2022
1 parent b26d4b7 commit 4fc6235
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions optimizer/optimizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ func TestOptimize_constant_folding(t *testing.T) {
assert.Equal(t, ast.Dump(expected), ast.Dump(tree.Node))
}

func TestOptimize_constant_folding_with_floats(t *testing.T) {
tree, err := parser.Parse(`1 + 2.0 * ((1.0 * 2) / 2) - 0`)
require.NoError(t, err)

err = optimizer.Optimize(&tree.Node, nil)
require.NoError(t, err)

expected := &ast.FloatNode{Value: 3.0}

assert.Equal(t, ast.Dump(expected), ast.Dump(tree.Node))
}

func TestOptimize_in_array(t *testing.T) {
config := conf.New(map[string]int{"v": 0})

Expand Down

0 comments on commit 4fc6235

Please sign in to comment.