| 20 | } |
| 21 | |
| 22 | func TestEvalFloatPlus(t *testing.T) { |
| 23 | tests := []struct { |
| 24 | args []ast.BaseTerm |
| 25 | want ast.Constant |
| 26 | }{ |
| 27 | {[]ast.BaseTerm{}, ast.Float64(0)}, |
| 28 | {[]ast.BaseTerm{ast.Float64(1.5)}, ast.Float64(1.5)}, |
| 29 | {[]ast.BaseTerm{ast.Float64(1.5), ast.Float64(2.5)}, ast.Float64(4.0)}, |
| 30 | {[]ast.BaseTerm{ast.Number(2), ast.Float64(3.5)}, ast.Float64(5.5)}, |
| 31 | {[]ast.BaseTerm{ast.Float64(2.5), ast.Number(1)}, ast.Float64(3.5)}, |
| 32 | } |
| 33 | for _, test := range tests { |
| 34 | expr := ast.ApplyFn{symbols.FloatPlus, test.args} |
| 35 | got, err := EvalExpr(expr, ast.ConstSubstMap{}) |
| 36 | if err != nil { |
| 37 | t.Errorf("EvalExpr(%v) error: %v", expr, err) |
| 38 | continue |
| 39 | } |
| 40 | if !got.Equals(test.want) { |
| 41 | t.Errorf("EvalExpr(%v) = %v, want %v", expr, got, test.want) |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | func TestListContains(t *testing.T) { |
| 47 | tests := []struct { |