|
20 | 20 | "category": "operator", |
21 | 21 | "description": "should stringify all operators", |
22 | 22 | "tests": [ |
23 | | - { "input": ["eq", ["get", "score"], 8], "output": "(.score == 8)" }, |
24 | | - { "input": ["lt", ["get", "score"], 8], "output": "(.score < 8)" }, |
25 | | - { "input": ["lte", ["get", "score"], 8], "output": "(.score <= 8)" }, |
26 | | - { "input": ["gt", ["get", "score"], 8], "output": "(.score > 8)" }, |
27 | | - { "input": ["gte", ["get", "score"], 8], "output": "(.score >= 8)" }, |
28 | | - { "input": ["ne", ["get", "score"], 8], "output": "(.score != 8)" }, |
29 | | - { "input": ["add", ["get", "score"], 8], "output": "(.score + 8)" }, |
30 | | - { "input": ["subtract", ["get", "score"], 8], "output": "(.score - 8)" }, |
31 | | - { "input": ["multiply", ["get", "score"], 8], "output": "(.score * 8)" }, |
32 | | - { "input": ["divide", ["get", "score"], 8], "output": "(.score / 8)" }, |
33 | | - { "input": ["pow", ["get", "score"], 8], "output": "(.score ^ 8)" }, |
34 | | - { "input": ["mod", ["get", "score"], 8], "output": "(.score % 8)" }, |
35 | | - { "input": ["and", ["get", "score"], 8], "output": "(.score and 8)" }, |
36 | | - { "input": ["or", ["get", "score"], 8], "output": "(.score or 8)" }, |
| 23 | + { "input": ["eq", ["get", "score"], 8], "output": ".score == 8" }, |
| 24 | + { "input": ["lt", ["get", "score"], 8], "output": ".score < 8" }, |
| 25 | + { "input": ["lte", ["get", "score"], 8], "output": ".score <= 8" }, |
| 26 | + { "input": ["gt", ["get", "score"], 8], "output": ".score > 8" }, |
| 27 | + { "input": ["gte", ["get", "score"], 8], "output": ".score >= 8" }, |
| 28 | + { "input": ["ne", ["get", "score"], 8], "output": ".score != 8" }, |
| 29 | + { "input": ["add", ["get", "score"], 8], "output": ".score + 8" }, |
| 30 | + { "input": ["subtract", ["get", "score"], 8], "output": ".score - 8" }, |
| 31 | + { "input": ["multiply", ["get", "score"], 8], "output": ".score * 8" }, |
| 32 | + { "input": ["divide", ["get", "score"], 8], "output": ".score / 8" }, |
| 33 | + { "input": ["pow", ["get", "score"], 8], "output": ".score ^ 8" }, |
| 34 | + { "input": ["mod", ["get", "score"], 8], "output": ".score % 8" }, |
| 35 | + { "input": ["and", ["get", "score"], 8], "output": ".score and 8" }, |
| 36 | + { "input": ["or", ["get", "score"], 8], "output": ".score or 8" }, |
37 | 37 | { |
38 | 38 | "input": ["in", ["get", "score"], ["array", 8, 9, 10]], |
39 | | - "output": "(.score in [8, 9, 10])" |
| 39 | + "output": ".score in [8, 9, 10]" |
40 | 40 | }, |
41 | 41 | { |
42 | 42 | "input": ["not in", ["get", "score"], ["array", 8, 9, 10]], |
43 | | - "output": "(.score not in [8, 9, 10])" |
| 43 | + "output": ".score not in [8, 9, 10]" |
44 | 44 | } |
45 | 45 | ] |
46 | 46 | }, |
| 47 | + { |
| 48 | + "category": "operator", |
| 49 | + "description": "should wrap operators in parenthesis when needed", |
| 50 | + "tests": [ |
| 51 | + { "input": ["add", 2, 3], "output": "2 + 3" }, |
| 52 | + { "input": ["multiply", ["add", 1, 2], 3], "output": "(1 + 2) * 3" }, |
| 53 | + { "input": ["add", ["add", 1, 2], 3], "output": "1 + 2 + 3" }, |
| 54 | + { "input": ["add", ["multiply", 1, 2], 3], "output": "1 * 2 + 3" } |
| 55 | + ] |
| 56 | + }, |
47 | 57 | { |
48 | 58 | "category": "operator", |
49 | 59 | "description": "should stringify a custom operator", |
50 | 60 | "options": { |
51 | 61 | "operators": [{ "eq": "==", "aboutEq": "~=" }] |
52 | 62 | }, |
53 | 63 | "tests": [ |
54 | | - { "input": ["aboutEq", 2, 3], "output": "(2 ~= 3)" }, |
| 64 | + { "input": ["aboutEq", 2, 3], "output": "2 ~= 3" }, |
55 | 65 | { "input": ["filter", ["aboutEq", 2, 3]], "output": "filter(2 ~= 3)" }, |
56 | | - { "input": ["object", { "result": ["aboutEq", 2, 3] }], "output": "{ result: (2 ~= 3) }" }, |
57 | | - { "input": ["eq", 2, 3], "output": "(2 == 3)" } |
| 66 | + { "input": ["object", { "result": ["aboutEq", 2, 3] }], "output": "{ result: 2 ~= 3 }" }, |
| 67 | + { "input": ["eq", 2, 3], "output": "2 == 3" } |
58 | 68 | ] |
59 | 69 | }, |
60 | 70 | { |
|
246 | 256 | }, |
247 | 257 | { |
248 | 258 | "input": ["filter", ["and", ["gte", ["get", "age"], 23], ["lte", ["get", "age"], 27]]], |
249 | | - "output": "filter((.age >= 23) and (.age <= 27))" |
| 259 | + "output": "filter(.age >= 23 and .age <= 27)" |
250 | 260 | }, |
251 | 261 | { |
252 | 262 | "input": [ |
|
0 commit comments