|
165 | 165 | "category": "operator", |
166 | 166 | "description": "should parse operators and and or with more than two arguments", |
167 | 167 | "tests": [ |
168 | | - { |
169 | | - "input": "1 and 2 and 3", |
170 | | - "output": ["and", ["and", 1, 2], 3] |
171 | | - }, |
172 | | - { |
173 | | - "input": "1 or 2 or 3", |
174 | | - "output": ["or", ["or", 1, 2], 3] |
175 | | - }, |
176 | | - { |
177 | | - "input": "1 or 2 or 3 or 4", |
178 | | - "output": ["or", ["or", ["or", 1, 2], 3], 4] |
179 | | - } |
| 168 | + { "input": "1 and 2 and 3", "output": ["and", 1, 2, 3] }, |
| 169 | + { "input": "1 or 2 or 3", "output": ["or", 1, 2, 3] }, |
| 170 | + { "input": "1 ^ 2 ^ 3", "output": ["pow", 1, 2, 3] }, |
| 171 | + { "input": "1 * 2 * 3", "output": ["multiply", 1, 2, 3] }, |
| 172 | + { "input": "1 / 2 / 3", "output": ["divide", 1, 2, 3] }, |
| 173 | + { "input": "1 + 2 + 3", "output": ["add", 1, 2, 3] }, |
| 174 | + { "input": "1 - 2 - 3", "output": ["subtract", 1, 2, 3] }, |
| 175 | + { "input": "1 % 2 % 3", "output": ["mod", 1, 2, 3] } |
180 | 176 | ] |
181 | 177 | }, |
182 | 178 | { |
183 | 179 | "category": "operator", |
184 | 180 | "description": "should parse operators with the same precedence", |
185 | 181 | "tests": [ |
186 | | - { "input": "2 * 3 * 4", "output": ["multiply", ["multiply", 2, 3], 4] }, |
187 | | - { "input": "2 / 3 / 4", "output": ["divide", ["divide", 2, 3], 4] }, |
188 | 182 | { "input": "2 * 3 / 4", "output": ["divide", ["multiply", 2, 3], 4] }, |
189 | 183 | { "input": "2 / 3 * 4", "output": ["multiply", ["divide", 2, 3], 4] }, |
190 | 184 | { "input": "2 * 3 % 4", "output": ["mod", ["multiply", 2, 3], 4] }, |
191 | 185 | { "input": "2 % 3 * 4", "output": ["multiply", ["mod", 2, 3], 4] }, |
192 | | - { "input": "2 + 3 + 4", "output": ["add", ["add", 2, 3], 4] }, |
193 | | - { "input": "2 - 3 - 4", "output": ["subtract", ["subtract", 2, 3], 4] }, |
194 | 186 | { "input": "2 + 3 - 4", "output": ["subtract", ["add", 2, 3], 4] }, |
195 | | - { "input": "2 - 3 + 4", "output": ["add", ["subtract", 2, 3], 4] }, |
196 | | - { "input": "2 > 3 > 4", "output": ["gt", ["gt", 2, 3], 4] }, |
197 | | - { "input": "2 >= 3 >= 4", "output": ["gte", ["gte", 2, 3], 4] }, |
198 | | - { "input": "2 < 3 < 4", "output": ["lt", ["lt", 2, 3], 4] }, |
199 | | - { "input": "2 <= 3 <= 4", "output": ["lte", ["lte", 2, 3], 4] }, |
200 | | - { "input": "2 in 3 in 4", "output": ["in", ["in", 2, 3], 4] }, |
201 | | - { "input": "2 not in 3 not in 4", "output": ["not in", ["not in", 2, 3], 4] }, |
202 | | - { "input": "2 > 3 >= 4", "output": ["gte", ["gt", 2, 3], 4] }, |
203 | | - { "input": "2 >= 3 > 4", "output": ["gt", ["gte", 2, 3], 4] }, |
204 | | - { "input": "2 > 3 < 4", "output": ["lt", ["gt", 2, 3], 4] }, |
205 | | - { "input": "2 < 3 > 4", "output": ["gt", ["lt", 2, 3], 4] }, |
206 | | - { "input": "2 > 3 <= 4", "output": ["lte", ["gt", 2, 3], 4] }, |
207 | | - { "input": "2 <= 3 > 4", "output": ["gt", ["lte", 2, 3], 4] }, |
208 | | - { "input": "2 > .a in .b", "output": ["in", ["gt", 2, ["get", "a"]], ["get", "b"]] }, |
209 | | - { "input": ".a in .b > 2", "output": ["gt", ["in", ["get", "a"], ["get", "b"]], 2] }, |
210 | | - { |
211 | | - "input": "2 > .a not in .b", |
212 | | - "output": ["not in", ["gt", 2, ["get", "a"]], ["get", "b"]] |
213 | | - }, |
214 | | - { |
215 | | - "input": ".a not in .b > 2", |
216 | | - "output": ["gt", ["not in", ["get", "a"], ["get", "b"]], 2] |
217 | | - }, |
218 | | - { "input": "2 == 3 == 4", "output": ["eq", ["eq", 2, 3], 4] }, |
219 | | - { "input": "2 != 3 != 4", "output": ["ne", ["ne", 2, 3], 4] }, |
220 | | - { "input": "2 == 3 != 4", "output": ["ne", ["eq", 2, 3], 4] }, |
221 | | - { "input": "2 != 3 == 4", "output": ["eq", ["ne", 2, 3], 4] } |
| 187 | + { "input": "2 - 3 + 4", "output": ["add", ["subtract", 2, 3], 4] } |
222 | 188 | ] |
223 | 189 | }, |
224 | 190 | { |
|
0 commit comments