(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestValue_Add(t *testing.T) { |
| 10 | run := func(a, b *model.Value, exp *model.Value) func(*testing.T) { |
| 11 | return func(t *testing.T) { |
| 12 | got, err := a.Add(b) |
| 13 | if err != nil { |
| 14 | t.Errorf("unexpected error: %s", err) |
| 15 | return |
| 16 | } |
| 17 | eq, err := got.EqualTypeValue(exp) |
| 18 | if err != nil { |
| 19 | t.Errorf("unexpected error: %s", err) |
| 20 | return |
| 21 | } |
| 22 | if !eq { |
| 23 | t.Errorf("expected %v, got %v", exp, got) |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | t.Run("int", func(t *testing.T) { |
| 28 | t.Run("int", run(model.NewIntValue(1), model.NewIntValue(2), model.NewIntValue(3))) |
| 29 | t.Run("float", run(model.NewIntValue(1), model.NewFloatValue(2), model.NewFloatValue(3))) |
| 30 | }) |
| 31 | t.Run("float", func(t *testing.T) { |
| 32 | t.Run("int", run(model.NewFloatValue(1), model.NewIntValue(2), model.NewFloatValue(3))) |
| 33 | t.Run("float", run(model.NewFloatValue(1), model.NewFloatValue(2), model.NewFloatValue(3))) |
| 34 | }) |
| 35 | t.Run("string", func(t *testing.T) { |
| 36 | t.Run("string", run(model.NewStringValue("hello"), model.NewStringValue(" world"), model.NewStringValue("hello world"))) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | func TestValue_Subtract(t *testing.T) { |
| 41 | run := func(a, b *model.Value, exp *model.Value) func(*testing.T) { |
nothing calls this directly
no test coverage detected