(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestBigMathValue(t *testing.T) { |
| 26 | s1 := testSchema + "\n money: int .\n" |
| 27 | setSchema(s1) |
| 28 | triples := ` _:user1 <money> "48038396025285290" .` |
| 29 | require.NoError(t, addTriplesToCluster(triples)) |
| 30 | |
| 31 | t.Run("div", func(t *testing.T) { |
| 32 | q1 := ` |
| 33 | { |
| 34 | q(func: has(money)) { |
| 35 | f as money |
| 36 | g: math(f/2) |
| 37 | } |
| 38 | }` |
| 39 | js := processQueryNoErr(t, q1) |
| 40 | require.JSONEq(t, `{"data":{"q":[ |
| 41 | {"money":48038396025285290, |
| 42 | "g":24019198012642645} |
| 43 | ]}}`, js) |
| 44 | }) |
| 45 | |
| 46 | t.Run("add", func(t *testing.T) { |
| 47 | q1 := ` |
| 48 | { |
| 49 | q(func: has(money)) { |
| 50 | f as money |
| 51 | g: math(2+f) |
| 52 | } |
| 53 | }` |
| 54 | js := processQueryNoErr(t, q1) |
| 55 | require.JSONEq(t, `{"data":{"q":[ |
| 56 | {"money":48038396025285290, |
| 57 | "g":48038396025285292} |
| 58 | ]}}`, js) |
| 59 | }) |
| 60 | |
| 61 | t.Run("sub", func(t *testing.T) { |
| 62 | q1 := ` |
| 63 | { |
| 64 | q(func: has(money)) { |
| 65 | f as money |
| 66 | g: math(f-2) |
| 67 | } |
| 68 | }` |
| 69 | |
| 70 | js := processQueryNoErr(t, q1) |
| 71 | require.JSONEq(t, `{"data":{"q":[ |
| 72 | {"money":48038396025285290, |
| 73 | "g":48038396025285288} |
| 74 | ]}}`, js) |
| 75 | }) |
| 76 | |
| 77 | t.Run("sub", func(t *testing.T) { |
| 78 | q1 := ` |
| 79 | { |
| 80 | q(func: has(money)) { |
| 81 | f as money |
| 82 | g: math(f-2) |
nothing calls this directly
no test coverage detected
searching dependent graphs…