(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestValue_Subtract(t *testing.T) { |
| 41 | run := func(a, b *model.Value, exp *model.Value) func(*testing.T) { |
| 42 | return func(t *testing.T) { |
| 43 | got, err := a.Subtract(b) |
| 44 | if err != nil { |
| 45 | t.Errorf("unexpected error: %s", err) |
| 46 | return |
| 47 | } |
| 48 | eq, err := got.EqualTypeValue(exp) |
| 49 | if err != nil { |
| 50 | t.Errorf("unexpected error: %s", err) |
| 51 | return |
| 52 | } |
| 53 | if !eq { |
| 54 | t.Errorf("expected %v, got %v", exp, got) |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | t.Run("int", func(t *testing.T) { |
| 59 | t.Run("int", run(model.NewIntValue(3), model.NewIntValue(2), model.NewIntValue(1))) |
| 60 | t.Run("float", run(model.NewIntValue(3), model.NewFloatValue(2), model.NewFloatValue(1))) |
| 61 | }) |
| 62 | t.Run("float", func(t *testing.T) { |
| 63 | t.Run("int", run(model.NewFloatValue(3), model.NewIntValue(2), model.NewFloatValue(1))) |
| 64 | t.Run("float", run(model.NewFloatValue(3), model.NewFloatValue(2), model.NewFloatValue(1))) |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | func TestValue_Multiply(t *testing.T) { |
| 69 | run := func(a, b *model.Value, exp *model.Value) func(*testing.T) { |
nothing calls this directly
no test coverage detected