|
163 | 163 | }, |
164 | 164 | { |
165 | 165 | "category": "operator", |
166 | | - "description": "should throw an error when using multiple operators without parenthesis", |
| 166 | + "description": "should parse operators and and or with more than two arguments", |
167 | 167 | "tests": [ |
168 | | - { "input": ".a == \"A\" and .b == \"B\"", "throws": "Unexpected part 'and .b == \"B\"'" }, |
169 | 168 | { |
170 | | - "input": "2 and 3 and 4", |
171 | | - "throws": "Unexpected part 'and 4' (pos: 8)" |
| 169 | + "input": "1 and 2 and 3", |
| 170 | + "output": ["and", ["and", 1, 2], 3] |
172 | 171 | }, |
173 | | - { "input": ".a + 2 * 3", "throws": "Unexpected part '* 3' (pos: 7)" } |
| 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 | + } |
| 180 | + ] |
| 181 | + }, |
| 182 | + { |
| 183 | + "category": "operator", |
| 184 | + "description": "should parse operators with the right precedence", |
| 185 | + "tests": [ |
| 186 | + { "input": "1 + 2 * 3", "output": ["add", 1, ["multiply", 2, 3]] }, |
| 187 | + { "input": "2 * 3 + 1", "output": ["add", ["multiply", 2, 3], 1] }, |
| 188 | + { "input": "1 * 2 / 3", "output": ["divide", ["multiply", 1, 2], 3] }, |
| 189 | + { "input": "1 + 2 - 3", "output": ["subtract", ["add", 1, 2], 3] }, |
| 190 | + { "input": "1 and 2 and 3", "output": ["and", ["and", 1, 2], 3] }, |
| 191 | + { "input": "1 and 2 or 3", "output": ["or", ["and", 1, 2], 3] }, |
| 192 | + { "input": "3 or 1 and 2", "output": ["or", 3, ["and", 1, 2]] } |
174 | 193 | ] |
175 | 194 | }, |
176 | 195 | { |
|
0 commit comments