(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestMapValues(t *testing.T) { |
| 13 | t.Run("multiply int values", testCase{ |
| 14 | inFn: func() *model.Value { |
| 15 | res := model.NewMapValue() |
| 16 | _ = res.SetMapKey("a", model.NewIntValue(1)) |
| 17 | _ = res.SetMapKey("b", model.NewIntValue(2)) |
| 18 | _ = res.SetMapKey("c", model.NewIntValue(3)) |
| 19 | return res |
| 20 | }, |
| 21 | s: `mapValues($this * 2)`, |
| 22 | outFn: func() *model.Value { |
| 23 | res := model.NewMapValue() |
| 24 | _ = res.SetMapKey("a", model.NewIntValue(2)) |
| 25 | _ = res.SetMapKey("b", model.NewIntValue(4)) |
| 26 | _ = res.SetMapKey("c", model.NewIntValue(6)) |
| 27 | return res |
| 28 | }, |
| 29 | }.run) |
| 30 | |
| 31 | t.Run("add to int values", testCase{ |
| 32 | inFn: func() *model.Value { |
| 33 | res := model.NewMapValue() |
| 34 | _ = res.SetMapKey("x", model.NewIntValue(10)) |
| 35 | _ = res.SetMapKey("y", model.NewIntValue(20)) |
| 36 | return res |
| 37 | }, |
| 38 | s: `mapValues($this + 1)`, |
| 39 | outFn: func() *model.Value { |
| 40 | res := model.NewMapValue() |
| 41 | _ = res.SetMapKey("x", model.NewIntValue(11)) |
| 42 | _ = res.SetMapKey("y", model.NewIntValue(21)) |
| 43 | return res |
| 44 | }, |
| 45 | }.run) |
| 46 | |
| 47 | t.Run("boolean expression", testCase{ |
| 48 | inFn: func() *model.Value { |
| 49 | res := model.NewMapValue() |
| 50 | _ = res.SetMapKey("a", model.NewIntValue(3)) |
| 51 | _ = res.SetMapKey("b", model.NewIntValue(8)) |
| 52 | return res |
| 53 | }, |
| 54 | s: `mapValues($this > 5)`, |
| 55 | outFn: func() *model.Value { |
| 56 | res := model.NewMapValue() |
| 57 | _ = res.SetMapKey("a", model.NewBoolValue(false)) |
| 58 | _ = res.SetMapKey("b", model.NewBoolValue(true)) |
| 59 | return res |
| 60 | }, |
| 61 | }.run) |
| 62 | |
| 63 | t.Run("empty map", testCase{ |
| 64 | inFn: func() *model.Value { |
| 65 | return model.NewMapValue() |
| 66 | }, |
| 67 | s: `mapValues($this * 2)`, |
| 68 | outFn: func() *model.Value { |
| 69 | return model.NewMapValue() |
nothing calls this directly
no test coverage detected