| 1 | { |
| 2 | "tests": [ |
| 3 | { |
| 4 | "name": "existence, without segments", |
| 5 | "selector": "$[?@]", |
| 6 | "document": {"a": 1, "b": null}, |
| 7 | "results": [ |
| 8 | [1, null], |
| 9 | [null, 1] |
| 10 | ] |
| 11 | }, |
| 12 | { |
| 13 | "name": "existence", |
| 14 | "selector" : "$[[email protected]]", |
| 15 | "document" : [{"a": "b", "d": "e"}, {"b":"c", "d": "f"}], |
| 16 | "result": [ |
| 17 | {"a": "b", "d": "e"} |
| 18 | ] |
| 19 | }, |
| 20 | { |
| 21 | "name": "existence, present with null", |
| 22 | "selector" : "$[[email protected]]", |
| 23 | "document" : [{"a": null, "d": "e"}, {"b":"c", "d": "f"}], |
| 24 | "result": [ |
| 25 | {"a": null, "d": "e"} |
| 26 | ] |
| 27 | }, |
| 28 | { |
| 29 | "name": "equals string, single quotes", |
| 30 | "selector" : "$[[email protected]=='b']", |
| 31 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 32 | "result": [ |
| 33 | {"a": "b", "d": "e"} |
| 34 | ] |
| 35 | }, |
| 36 | { |
| 37 | "name": "equals numeric string, single quotes", |
| 38 | "selector" : "$[[email protected]=='1']", |
| 39 | "document" : [{"a": "1", "d": "e"}, {"a":1, "d": "f"}], |
| 40 | "result": [ |
| 41 | {"a": "1", "d": "e"} |
| 42 | ] |
| 43 | }, |
| 44 | { |
| 45 | "name": "equals string, double quotes", |
| 46 | "selector" : "$[[email protected]==\"b\"]", |
| 47 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 48 | "result": [ |
| 49 | {"a": "b", "d": "e"} |
| 50 | ] |
| 51 | }, |
| 52 | { |
| 53 | "name": "equals numeric string, double quotes", |
| 54 | "selector" : "$[[email protected]==\"1\"]", |
| 55 | "document" : [{"a": "1", "d": "e"}, {"a":1, "d": "f"}], |
| 56 | "result": [ |
| 57 | {"a": "1", "d": "e"} |
| 58 | ] |
| 59 | }, |
| 60 | { |
| 61 | "name": "equals number", |
| 62 | "selector" : "$[[email protected]==1]", |
| 63 | "document" : [{"a": 1, "d": "e"}, {"a":"c", "d": "f"}, {"a":2, "d": "f"}, {"a":"1", "d": "f"}], |
| 64 | "result": [ |
| 65 | {"a": 1, "d": "e"} |
| 66 | ] |
| 67 | }, |
| 68 | { |
| 69 | "name": "equals null", |
| 70 | "selector" : "$[[email protected]==null]", |
| 71 | "document" : [{"a": null, "d": "e"}, {"a":"c", "d": "f"}], |
| 72 | "result": [ |
| 73 | {"a": null, "d": "e"} |
| 74 | ] |
| 75 | }, |
| 76 | { |
| 77 | "name": "equals null, absent from data", |
| 78 | "selector" : "$[[email protected]==null]", |
| 79 | "document" : [{"d": "e"}, {"a":"c", "d": "f"}], |
| 80 | "result": [ |
| 81 | ] |
| 82 | }, |
| 83 | { |
| 84 | "name": "equals true", |
| 85 | "selector" : "$[[email protected]==true]", |
| 86 | "document" : [{"a": true, "d": "e"}, {"a":"c", "d": "f"}], |
| 87 | "result": [ |
| 88 | {"a": true, "d": "e"} |
| 89 | ] |
| 90 | }, |
| 91 | { |
| 92 | "name": "equals false", |
| 93 | "selector" : "$[[email protected]==false]", |
| 94 | "document" : [{"a": false, "d": "e"}, {"a":"c", "d": "f"}], |
| 95 | "result": [ |
| 96 | {"a": false, "d": "e"} |
| 97 | ] |
| 98 | }, |
| 99 | { |
| 100 | "name": "equals self", |
| 101 | "selector" : "$[?@==@]", |
| 102 | "document" : [1, null, true, {"a": "b"}, [false]], |
| 103 | "result": [ |
| 104 | 1, |
| 105 | null, |
| 106 | true, |
| 107 | {"a": "b"}, |
| 108 | [false] |
| 109 | ] |
| 110 | }, |
| 111 | { |
| 112 | "name": "deep equality, arrays", |
| 113 | "selector" : "$[[email protected][email protected]]", |
| 114 | "document" : [ |
| 115 | {"a": false, "b": [1, 2]}, |
| 116 | {"a": [[1, [2]]], "b": [[1, [2]]]}, |
| 117 | {"a": [[1, [2]]], "b": [[[2], 1]]}, |
| 118 | {"a": [[1, [2]]], "b": [[1, 2]]} |
| 119 | ], |
| 120 | "result": [ |
| 121 | {"a": [[1, [2]]], "b": [[1, [2]]]} |
| 122 | ] |
| 123 | }, |
| 124 | { |
| 125 | "name": "deep equality, objects", |
| 126 | "selector" : "$[[email protected][email protected]]", |
| 127 | "document" : [ |
| 128 | {"a": false, "b": {"x": 1, "y": {"z": 1}}}, |
| 129 | {"a": {"x": 1, "y": {"z": 1}}, "b": {"x": 1, "y": {"z": 1}}}, |
| 130 | {"a": {"x": 1, "y": {"z": 1}}, "b": {"y": {"z": 1}, "x": 1}}, |
| 131 | {"a": {"x": 1, "y": {"z": 1}}, "b": {"x": 1}}, |
| 132 | {"a": {"x": 1, "y": {"z": 1}}, "b": {"x": 1, "y": {"z": 2}}} |
| 133 | ], |
| 134 | "result": [ |
| 135 | {"a": {"x": 1, "y": {"z": 1}}, "b": {"x": 1, "y": {"z": 1}}}, |
| 136 | {"a": {"x": 1, "y": {"z": 1}}, "b": {"y": {"z": 1}, "x": 1}} |
| 137 | ] |
| 138 | }, |
| 139 | { |
| 140 | "name": "not-equals string, single quotes", |
| 141 | "selector" : "$[[email protected]!='b']", |
| 142 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 143 | "result": [ |
| 144 | {"a":"c", "d": "f"} |
| 145 | ] |
| 146 | }, |
| 147 | { |
| 148 | "name": "not-equals numeric string, single quotes", |
| 149 | "selector" : "$[[email protected]!='1']", |
| 150 | "document" : [{"a": "1", "d": "e"}, {"a":1, "d": "f"}], |
| 151 | "result": [ |
| 152 | {"a":1, "d": "f"} |
| 153 | ] |
| 154 | }, |
| 155 | { |
| 156 | "name": "not-equals string, single quotes, different type", |
| 157 | "selector" : "$[[email protected]!='b']", |
| 158 | "document" : [{"a": "b", "d": "e"}, {"a":1, "d": "f"}], |
| 159 | "result": [ |
| 160 | {"a":1, "d": "f"} |
| 161 | ] |
| 162 | }, |
| 163 | { |
| 164 | "name": "not-equals string, double quotes", |
| 165 | "selector" : "$[[email protected]!=\"b\"]", |
| 166 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 167 | "result": [ |
| 168 | {"a":"c", "d": "f"} |
| 169 | ] |
| 170 | }, |
| 171 | { |
| 172 | "name": "not-equals numeric string, double quotes", |
| 173 | "selector" : "$[[email protected]!=\"1\"]", |
| 174 | "document" : [{"a": "1", "d": "e"}, {"a":1, "d": "f"}], |
| 175 | "result": [ |
| 176 | {"a":1, "d": "f"} |
| 177 | ] |
| 178 | }, |
| 179 | { |
| 180 | "name": "not-equals string, double quotes, different types", |
| 181 | "selector" : "$[[email protected]!=\"b\"]", |
| 182 | "document" : [{"a": "b", "d": "e"}, {"a":1, "d": "f"}], |
| 183 | "result": [ |
| 184 | {"a":1, "d": "f"} |
| 185 | ] |
| 186 | }, |
| 187 | { |
| 188 | "name": "not-equals number", |
| 189 | "selector" : "$[[email protected]!=1]", |
| 190 | "document" : [{"a": 1, "d": "e"}, {"a":2, "d": "f"}, {"a":"1", "d": "f"}], |
| 191 | "result": [ |
| 192 | {"a":2, "d": "f"}, |
| 193 | {"a":"1", "d": "f"} |
| 194 | ] |
| 195 | }, |
| 196 | { |
| 197 | "name": "not-equals number, different types", |
| 198 | "selector" : "$[[email protected]!=1]", |
| 199 | "document" : [{"a": 1, "d": "e"}, {"a":"c", "d": "f"}], |
| 200 | "result": [ |
| 201 | {"a":"c", "d": "f"} |
| 202 | ] |
| 203 | }, |
| 204 | { |
| 205 | "name": "not-equals null", |
| 206 | "selector" : "$[[email protected]!=null]", |
| 207 | "document" : [{"a": null, "d": "e"}, {"a":"c", "d": "f"}], |
| 208 | "result": [ |
| 209 | {"a":"c", "d": "f"} |
| 210 | ] |
| 211 | }, |
| 212 | { |
| 213 | "name": "not-equals null, absent from data", |
| 214 | "selector" : "$[[email protected]!=null]", |
| 215 | "document" : [{"d": "e"}, {"a":"c", "d": "f"}], |
| 216 | "result": [ |
| 217 | {"d": "e"}, |
| 218 | {"a":"c", "d": "f"} |
| 219 | ] |
| 220 | }, |
| 221 | { |
| 222 | "name": "not-equals true", |
| 223 | "selector" : "$[[email protected]!=true]", |
| 224 | "document" : [{"a": true, "d": "e"}, {"a":"c", "d": "f"}], |
| 225 | "result": [ |
| 226 | {"a":"c", "d": "f"} |
| 227 | ] |
| 228 | }, |
| 229 | { |
| 230 | "name": "not-equals false", |
| 231 | "selector" : "$[[email protected]!=false]", |
| 232 | "document" : [{"a": false, "d": "e"}, {"a":"c", "d": "f"}], |
| 233 | "result": [ |
| 234 | {"a":"c", "d": "f"} |
| 235 | ] |
| 236 | }, |
| 237 | { |
| 238 | "name": "less than string, single quotes", |
| 239 | "selector" : "$[[email protected]<'c']", |
| 240 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 241 | "result": [ |
| 242 | {"a": "b", "d": "e"} |
| 243 | ] |
| 244 | }, |
| 245 | { |
| 246 | "name": "less than string, double quotes", |
| 247 | "selector" : "$[[email protected]<\"c\"]", |
| 248 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 249 | "result": [ |
| 250 | {"a": "b", "d": "e"} |
| 251 | ] |
| 252 | }, |
| 253 | { |
| 254 | "name": "less than number", |
| 255 | "selector" : "$[[email protected]<10]", |
| 256 | "document" : [{"a": 1, "d": "e"}, {"a": 10, "d": "e"}, {"a":"c", "d": "f"}, {"a":20, "d": "f"}], |
| 257 | "result": [ |
| 258 | {"a": 1, "d": "e"} |
| 259 | ] |
| 260 | }, |
| 261 | { |
| 262 | "name": "less than null", |
| 263 | "selector" : "$[[email protected]<null]", |
| 264 | "document" : [{"a": null, "d": "e"}, {"a":"c", "d": "f"}], |
| 265 | "result": [ ] |
| 266 | }, |
| 267 | { |
| 268 | "name": "less than true", |
| 269 | "selector" : "$[[email protected]<true]", |
| 270 | "document" : [{"a": true, "d": "e"}, {"a":"c", "d": "f"}], |
| 271 | "result": [ ] |
| 272 | }, |
| 273 | { |
| 274 | "name": "less than false", |
| 275 | "selector" : "$[[email protected]<false]", |
| 276 | "document" : [{"a": false, "d": "e"}, {"a":"c", "d": "f"}], |
| 277 | "result": [ ] |
| 278 | }, |
| 279 | { |
| 280 | "name": "less than or equal to string, single quotes", |
| 281 | "selector" : "$[[email protected]<='c']", |
| 282 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 283 | "result": [ |
| 284 | {"a": "b", "d": "e"}, |
| 285 | {"a":"c", "d": "f"} |
| 286 | ] |
| 287 | }, |
| 288 | { |
| 289 | "name": "less than or equal to string, double quotes", |
| 290 | "selector" : "$[[email protected]<=\"c\"]", |
| 291 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}], |
| 292 | "result": [ |
| 293 | {"a": "b", "d": "e"}, |
| 294 | {"a":"c", "d": "f"} |
| 295 | ] |
| 296 | }, |
| 297 | { |
| 298 | "name": "less than or equal to number", |
| 299 | "selector" : "$[[email protected]<=10]", |
| 300 | "document" : [{"a": 1, "d": "e"}, {"a": 10, "d": "e"}, {"a":"c", "d": "f"}, {"a":20, "d": "f"}], |
| 301 | "result": [ |
| 302 | {"a": 1, "d": "e"}, |
| 303 | {"a": 10, "d": "e"} |
| 304 | ] |
| 305 | }, |
| 306 | { |
| 307 | "name": "less than or equal to null", |
| 308 | "selector" : "$[[email protected]<=null]", |
| 309 | "document" : [{"a": null, "d": "e"}, {"a":"c", "d": "f"}], |
| 310 | "result": [ |
| 311 | {"a": null, "d": "e"} |
| 312 | ] |
| 313 | }, |
| 314 | { |
| 315 | "name": "less than or equal to true", |
| 316 | "selector" : "$[[email protected]<=true]", |
| 317 | "document" : [{"a": true, "d": "e"}, {"a":"c", "d": "f"}], |
| 318 | "result": [ |
| 319 | {"a": true, "d": "e"} |
| 320 | ] |
| 321 | }, |
| 322 | { |
| 323 | "name": "less than or equal to false", |
| 324 | "selector" : "$[[email protected]<=false]", |
| 325 | "document" : [{"a": false, "d": "e"}, {"a":"c", "d": "f"}], |
| 326 | "result": [ |
| 327 | {"a": false, "d": "e"} |
| 328 | ] |
| 329 | }, |
| 330 | { |
| 331 | "name": "greater than string, single quotes", |
| 332 | "selector" : "$[[email protected]>'c']", |
| 333 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}, {"a":"d", "d": "f"}], |
| 334 | "result": [ |
| 335 | {"a":"d", "d": "f"} |
| 336 | ] |
| 337 | }, |
| 338 | { |
| 339 | "name": "greater than string, double quotes", |
| 340 | "selector" : "$[[email protected]>\"c\"]", |
| 341 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}, {"a":"d", "d": "f"}], |
| 342 | "result": [ |
| 343 | {"a":"d", "d": "f"} |
| 344 | ] |
| 345 | }, |
| 346 | { |
| 347 | "name": "greater than number", |
| 348 | "selector" : "$[[email protected]>10]", |
| 349 | "document" : [{"a": 1, "d": "e"}, {"a": 10, "d": "e"}, {"a":"c", "d": "f"}, {"a":20, "d": "f"}], |
| 350 | "result": [ |
| 351 | {"a":20, "d": "f"} |
| 352 | ] |
| 353 | }, |
| 354 | { |
| 355 | "name": "greater than null", |
| 356 | "selector" : "$[[email protected]>null]", |
| 357 | "document" : [{"a": null, "d": "e"}, {"a":"c", "d": "f"}], |
| 358 | "result": [ ] |
| 359 | }, |
| 360 | { |
| 361 | "name": "greater than true", |
| 362 | "selector" : "$[[email protected]>true]", |
| 363 | "document" : [{"a": true, "d": "e"}, {"a":"c", "d": "f"}], |
| 364 | "result": [ ] |
| 365 | }, |
| 366 | { |
| 367 | "name": "greater than false", |
| 368 | "selector" : "$[[email protected]>false]", |
| 369 | "document" : [{"a": false, "d": "e"}, {"a":"c", "d": "f"}], |
| 370 | "result": [ ] |
| 371 | }, |
| 372 | { |
| 373 | "name": "greater than or equal to string, single quotes", |
| 374 | "selector" : "$[[email protected]>='c']", |
| 375 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}, {"a":"d", "d": "f"}], |
| 376 | "result": [ |
| 377 | {"a":"c", "d": "f"}, |
| 378 | {"a":"d", "d": "f"} |
| 379 | ] |
| 380 | }, |
| 381 | { |
| 382 | "name": "greater than or equal to string, double quotes", |
| 383 | "selector" : "$[[email protected]>=\"c\"]", |
| 384 | "document" : [{"a": "b", "d": "e"}, {"a":"c", "d": "f"}, {"a":"d", "d": "f"}], |
| 385 | "result": [ |
| 386 | {"a":"c", "d": "f"}, |
| 387 | {"a":"d", "d": "f"} |
| 388 | ] |
| 389 | }, |
| 390 | { |
| 391 | "name": "greater than or equal to number", |
| 392 | "selector" : "$[[email protected]>=10]", |
| 393 | "document" : [{"a": 1, "d": "e"}, {"a": 10, "d": "e"}, {"a":"c", "d": "f"}, {"a":20, "d": "f"}], |
| 394 | "result": [ |
| 395 | {"a": 10, "d": "e"}, |
| 396 | {"a":20, "d": "f"} |
| 397 | ] |
| 398 | }, |
| 399 | { |
| 400 | "name": "greater than or equal to null", |
| 401 | "selector" : "$[[email protected]>=null]", |
| 402 | "document" : [{"a": null, "d": "e"}, {"a":"c", "d": "f"}], |
| 403 | "result": [ |
| 404 | {"a": null, "d": "e"} |
| 405 | ] |
| 406 | }, |
| 407 | { |
| 408 | "name": "greater than or equal to true", |
| 409 | "selector" : "$[[email protected]>=true]", |
| 410 | "document" : [{"a": true, "d": "e"}, {"a":"c", "d": "f"}], |
| 411 | "result": [ |
| 412 | {"a": true, "d": "e"} |
| 413 | ] |
| 414 | }, |
| 415 | { |
| 416 | "name": "greater than or equal to false", |
| 417 | "selector" : "$[[email protected]>=false]", |
| 418 | "document" : [{"a": false, "d": "e"}, {"a":"c", "d": "f"}], |
| 419 | "result": [ |
| 420 | {"a": false, "d": "e"} |
| 421 | ] |
| 422 | }, |
| 423 | { |
| 424 | "name": "exists and not-equals null, absent from data", |
| 425 | "selector" : "$[[email protected]&&@.a!=null]", |
| 426 | "document" : [{"d": "e"}, {"a":"c", "d": "f"}], |
| 427 | "result": [ |
| 428 | {"a":"c", "d": "f"} |
| 429 | ] |
| 430 | }, |
| 431 | { |
| 432 | "name": "exists and exists, data false", |
| 433 | "selector" : "$[[email protected]&&@.b]", |
| 434 | "document" : [{"a": false, "b": false}, {"b": false}, {"c": false}], |
| 435 | "result": [ |
| 436 | {"a": false, "b": false} |
| 437 | ] |
| 438 | }, |
| 439 | { |
| 440 | "name": "exists or exists, data false", |
| 441 | "selector" : "$[[email protected]||@.b]", |
| 442 | "document" : [{"a": false, "b": false}, {"b": false}, {"c": false}], |
| 443 | "result": [ |
| 444 | {"a": false, "b": false}, |
| 445 | {"b": false} |
| 446 | ] |
| 447 | }, |
| 448 | { |
| 449 | "name": "and", |
| 450 | "selector" : "$[[email protected]>0&&@.a<10]", |
| 451 | "document" : [{"a": -10, "d": "e"}, {"a":5, "d": "f"}, {"a":20, "d": "f"}], |
| 452 | "result": [ |
| 453 | {"a":5, "d": "f"} |
| 454 | ] |
| 455 | }, |
| 456 | { |
| 457 | "name": "or", |
| 458 | "selector" : "$[[email protected]=='b'||@.a=='d']", |
| 459 | "document" : [{"a": "a", "d": "e"}, {"a":"b", "d": "f"}, {"a":"c", "d": "f"}, {"a":"d", "d": "f"}], |
| 460 | "result": [ |
| 461 | {"a":"b", "d": "f"}, |
| 462 | {"a":"d", "d": "f"} |
| 463 | ] |
| 464 | }, |
| 465 | { |
| 466 | "name": "not expression", |
| 467 | "selector" : "$[?!(@.a=='b')]", |
| 468 | "document" : [{"a": "a", "d": "e"}, {"a":"b", "d": "f"}, {"a":"d", "d": "f"}], |
| 469 | "result": [ |
| 470 | {"a": "a", "d": "e"}, |
| 471 | {"a": "d", "d": "f"} |
| 472 | ] |
| 473 | }, |
| 474 | { |
| 475 | "name": "not exists", |
| 476 | "selector" : "$[[email protected]]", |
| 477 | "document" : [{"a": "a", "d": "e"}, {"d": "f"}, {"a":"d", "d": "f"}], |
| 478 | "result": [ |
| 479 | {"d": "f"} |
| 480 | ] |
| 481 | }, |
| 482 | { |
| 483 | "name": "not exists, data null", |
| 484 | "selector" : "$[[email protected]]", |
| 485 | "document" : [{"a": null, "d": "e"}, {"d": "f"}, {"a":"d", "d": "f"}], |
| 486 | "result": [ |
| 487 | {"d": "f"} |
| 488 | ] |
| 489 | }, |
| 490 | { |
| 491 | "name": "non-singular existence, wildcard", |
| 492 | "selector" : "$[?@.*]", |
| 493 | "document" : [1, [], [2], {}, {"a": 3}], |
| 494 | "result": [ |
| 495 | [2], |
| 496 | {"a": 3} |
| 497 | ] |
| 498 | }, |
| 499 | { |
| 500 | "name": "non-singular existence, multiple", |
| 501 | "selector" : "$[?@[0, 0, 'a']]", |
| 502 | "document" : [1, [], [2], [2, 3], {"a": 3}, {"b": 4}, {"a": 3, "b": 4}], |
| 503 | "result": [ |
| 504 | [2], |
| 505 | [2, 3], |
| 506 | {"a": 3}, |
| 507 | {"a": 3, "b": 4} |
| 508 | ] |
| 509 | }, |
| 510 | { |
| 511 | "name": "non-singular existence, slice", |
| 512 | "selector" : "$[?@[0:2]]", |
| 513 | "document" : [1, [], [2], [2, 3, 4], {}, {"a": 3}], |
| 514 | "result": [ |
| 515 | [2], |
| 516 | [2, 3, 4] |
| 517 | ] |
| 518 | }, |
| 519 | { |
| 520 | "name": "non-singular existence, negated", |
| 521 | "selector" : "$[?!@.*]", |
| 522 | "document" : [1, [], [2], {}, {"a": 3}], |
| 523 | "result": [ |
| 524 | 1, |
| 525 | [], |
| 526 | {} |
| 527 | ] |
| 528 | }, |
| 529 | { |
| 530 | "name": "non-singular query in comparison, slice", |
| 531 | "selector" : "$[?@[0:0]==0]", |
| 532 | "invalid_selector": true |
| 533 | }, |
| 534 | { |
| 535 | "name": "non-singular query in comparison, all children", |
| 536 | "selector" : "$[?@[*]==0]", |
| 537 | "invalid_selector": true |
| 538 | }, |
| 539 | { |
| 540 | "name": "non-singular query in comparison, descendants", |
| 541 | "selector" : "$[[email protected]==0]", |
| 542 | "invalid_selector": true |
| 543 | }, |
| 544 | { |
| 545 | "name": "non-singular query in comparison, combined", |
| 546 | "selector" : "$[[email protected][*].a==0]", |
| 547 | "invalid_selector": true |
| 548 | }, |
| 549 | { |
| 550 | "name": "nested", |
| 551 | "selector": "$[?@[?@>1]]", |
| 552 | "document": [[0], [0, 1], [0, 1, 2], [42]], |
| 553 | "result": [ |
| 554 | [0, 1, 2], |
| 555 | [42] |
| 556 | ] |
| 557 | }, |
| 558 | { |
| 559 | "name": "name segment on primitive, selects nothing", |
| 560 | "selector": "$[[email protected] == 1]", |
| 561 | "document": {"a": 1}, |
| 562 | "result": [] |
| 563 | }, |
| 564 | { |
| 565 | "name": "name segment on array, selects nothing", |
| 566 | "selector": "$[?@['0'] == 5]", |
| 567 | "document": [[5, 6]], |
| 568 | "result": [] |
| 569 | }, |
| 570 | { |
| 571 | "name": "index segment on object, selects nothing", |
| 572 | "selector": "$[?@[0] == 5]", |
| 573 | "document": [{"0": 5}], |
| 574 | "result": [] |
| 575 | }, |
| 576 | { |
| 577 | "name": "relative non-singular query, index, equal", |
| 578 | "selector": "$[?(@[0, 0]==42)]", |
| 579 | "invalid_selector": true |
| 580 | }, |
| 581 | { |
| 582 | "name": "relative non-singular query, index, not equal", |
| 583 | "selector": "$[?(@[0, 0]!=42)]", |
| 584 | "invalid_selector": true |
| 585 | }, |
| 586 | { |
| 587 | "name": "relative non-singular query, index, less-or-equal", |
| 588 | "selector": "$[?(@[0, 0]<=42)]", |
| 589 | "invalid_selector": true |
| 590 | }, |
| 591 | { |
| 592 | "name": "relative non-singular query, name, equal", |
| 593 | "selector": "$[?(@['a', 'a']==42)]", |
| 594 | "invalid_selector": true |
| 595 | }, |
| 596 | { |
| 597 | "name": "relative non-singular query, name, not equal", |
| 598 | "selector": "$[?(@['a', 'a']!=42)]", |
| 599 | "invalid_selector": true |
| 600 | }, |
| 601 | { |
| 602 | "name": "relative non-singular query, name, less-or-equal", |
| 603 | "selector": "$[?(@['a', 'a']<=42)]", |
| 604 | "invalid_selector": true |
| 605 | }, |
| 606 | { |
| 607 | "name": "relative non-singular query, combined, equal", |
| 608 | "selector": "$[?(@[0, '0']==42)]", |
| 609 | "invalid_selector": true |
| 610 | }, |
| 611 | { |
| 612 | "name": "relative non-singular query, combined, not equal", |
| 613 | "selector": "$[?(@[0, '0']!=42)]", |
| 614 | "invalid_selector": true |
| 615 | }, |
| 616 | { |
| 617 | "name": "relative non-singular query, combined, less-or-equal", |
| 618 | "selector": "$[?(@[0, '0']<=42)]", |
| 619 | "invalid_selector": true |
| 620 | }, |
| 621 | { |
| 622 | "name": "relative non-singular query, wildcard, equal", |
| 623 | "selector": "$[?(@.*==42)]", |
| 624 | "invalid_selector": true |
| 625 | }, |
| 626 | { |
| 627 | "name": "relative non-singular query, wildcard, not equal", |
| 628 | "selector": "$[?(@.*!=42)]", |
| 629 | "invalid_selector": true |
| 630 | }, |
| 631 | { |
| 632 | "name": "relative non-singular query, wildcard, less-or-equal", |
| 633 | "selector": "$[?(@.*<=42)]", |
| 634 | "invalid_selector": true |
| 635 | }, |
| 636 | { |
| 637 | "name": "relative non-singular query, slice, equal", |
| 638 | "selector": "$[?(@[0:0]==42)]", |
| 639 | "invalid_selector": true |
| 640 | }, |
| 641 | { |
| 642 | "name": "relative non-singular query, slice, not equal", |
| 643 | "selector": "$[?(@[0:0]!=42)]", |
| 644 | "invalid_selector": true |
| 645 | }, |
| 646 | { |
| 647 | "name": "relative non-singular query, slice, less-or-equal", |
| 648 | "selector": "$[?(@[0:0]<=42)]", |
| 649 | "invalid_selector": true |
| 650 | }, |
| 651 | { |
| 652 | "name": "absolute non-singular query, index, equal", |
| 653 | "selector": "$[?($[0, 0]==42)]", |
| 654 | "invalid_selector": true |
| 655 | }, |
| 656 | { |
| 657 | "name": "absolute non-singular query, index, not equal", |
| 658 | "selector": "$[?($[0, 0]!=42)]", |
| 659 | "invalid_selector": true |
| 660 | }, |
| 661 | { |
| 662 | "name": "absolute non-singular query, index, less-or-equal", |
| 663 | "selector": "$[?($[0, 0]<=42)]", |
| 664 | "invalid_selector": true |
| 665 | }, |
| 666 | { |
| 667 | "name": "absolute non-singular query, name, equal", |
| 668 | "selector": "$[?($['a', 'a']==42)]", |
| 669 | "invalid_selector": true |
| 670 | }, |
| 671 | { |
| 672 | "name": "absolute non-singular query, name, not equal", |
| 673 | "selector": "$[?($['a', 'a']!=42)]", |
| 674 | "invalid_selector": true |
| 675 | }, |
| 676 | { |
| 677 | "name": "absolute non-singular query, name, less-or-equal", |
| 678 | "selector": "$[?($['a', 'a']<=42)]", |
| 679 | "invalid_selector": true |
| 680 | }, |
| 681 | { |
| 682 | "name": "absolute non-singular query, combined, equal", |
| 683 | "selector": "$[?($[0, '0']==42)]", |
| 684 | "invalid_selector": true |
| 685 | }, |
| 686 | { |
| 687 | "name": "absolute non-singular query, combined, not equal", |
| 688 | "selector": "$[?($[0, '0']!=42)]", |
| 689 | "invalid_selector": true |
| 690 | }, |
| 691 | { |
| 692 | "name": "absolute non-singular query, combined, less-or-equal", |
| 693 | "selector": "$[?($[0, '0']<=42)]", |
| 694 | "invalid_selector": true |
| 695 | }, |
| 696 | { |
| 697 | "name": "absolute non-singular query, wildcard, equal", |
| 698 | "selector": "$[?($.*==42)]", |
| 699 | "invalid_selector": true |
| 700 | }, |
| 701 | { |
| 702 | "name": "absolute non-singular query, wildcard, not equal", |
| 703 | "selector": "$[?($.*!=42)]", |
| 704 | "invalid_selector": true |
| 705 | }, |
| 706 | { |
| 707 | "name": "absolute non-singular query, wildcard, less-or-equal", |
| 708 | "selector": "$[?($.*<=42)]", |
| 709 | "invalid_selector": true |
| 710 | }, |
| 711 | { |
| 712 | "name": "absolute non-singular query, slice, equal", |
| 713 | "selector": "$[?($[0:0]==42)]", |
| 714 | "invalid_selector": true |
| 715 | }, |
| 716 | { |
| 717 | "name": "absolute non-singular query, slice, not equal", |
| 718 | "selector": "$[?($[0:0]!=42)]", |
| 719 | "invalid_selector": true |
| 720 | }, |
| 721 | { |
| 722 | "name": "absolute non-singular query, slice, less-or-equal", |
| 723 | "selector": "$[?($[0:0]<=42)]", |
| 724 | "invalid_selector": true |
| 725 | }, |
| 726 | { |
| 727 | "name": "multiple selectors", |
| 728 | "selector" : "$[[email protected],[email protected]]", |
| 729 | "document" : [{"a": "b", "d": "e"}, {"b": "c", "d": "f"}], |
| 730 | "result": [ |
| 731 | {"a": "b", "d": "e"}, |
| 732 | {"b": "c", "d": "f"} |
| 733 | ] |
| 734 | }, |
| 735 | { |
| 736 | "name": "multiple selectors, comparison", |
| 737 | "selector" : "$[[email protected]=='b',[email protected]=='x']", |
| 738 | "document" : [{"a": "b", "d": "e"}, {"b": "c", "d": "f"}], |
| 739 | "result": [ |
| 740 | {"a": "b", "d": "e"} |
| 741 | ] |
| 742 | }, |
| 743 | { |
| 744 | "name": "multiple selectors, overlapping", |
| 745 | "selector" : "$[[email protected],[email protected]]", |
| 746 | "document" : [{"a": "b", "d": "e"}, {"b": "c", "d": "f"}], |
| 747 | "result": [ |
| 748 | {"a": "b", "d": "e"}, |
| 749 | {"a": "b", "d": "e"}, |
| 750 | {"b": "c", "d": "f"} |
| 751 | ] |
| 752 | }, |
| 753 | { |
| 754 | "name": "multiple selectors, filter and index", |
| 755 | "selector" : "$[[email protected],1]", |
| 756 | "document" : [{"a": "b", "d": "e"}, {"b": "c", "d": "f"}], |
| 757 | "result": [ |
| 758 | {"a": "b", "d": "e"}, |
| 759 | {"b": "c", "d": "f"} |
| 760 | ] |
| 761 | }, |
| 762 | { |
| 763 | "name": "multiple selectors, filter and wildcard", |
| 764 | "selector" : "$[[email protected],*]", |
| 765 | "document" : [{"a": "b", "d": "e"}, {"b": "c", "d": "f"}], |
| 766 | "result": [ |
| 767 | {"a": "b", "d": "e"}, |
| 768 | {"a": "b", "d": "e"}, |
| 769 | {"b": "c", "d": "f"} |
| 770 | ] |
| 771 | }, |
| 772 | { |
| 773 | "name": "multiple selectors, filter and slice", |
| 774 | "selector" : "$[[email protected],1:]", |
| 775 | "document" : [{"a": "b", "d": "e"}, {"b": "c", "d": "f"}, {"g": "h"}], |
| 776 | "result": [ |
| 777 | {"a": "b", "d": "e"}, |
| 778 | {"b": "c", "d": "f"}, |
| 779 | {"g": "h"} |
| 780 | ] |
| 781 | }, |
| 782 | { |
| 783 | "name": "multiple selectors, comparison filter, index and slice", |
| 784 | "selector" : "$[1, [email protected]=='b', 1:]", |
| 785 | "document" : [{"a": "b", "d": "e"}, {"b": "c", "d": "f"}], |
| 786 | "result": [ |
| 787 | {"b": "c", "d": "f"}, |
| 788 | {"a": "b", "d": "e"}, |
| 789 | {"b": "c", "d": "f"} |
| 790 | ] |
| 791 | }, |
| 792 | { |
| 793 | "name": "equals number, zero and negative zero", |
| 794 | "selector" : "$[[email protected]==-0]", |
| 795 | "document" : [{"a": 0, "d": "e"}, {"a":0.1, "d": "f"}, {"a":"0", "d": "g"}], |
| 796 | "result": [ |
| 797 | {"a": 0, "d": "e"} |
| 798 | ] |
| 799 | }, |
| 800 | { |
| 801 | "name": "equals number, with and without decimal fraction", |
| 802 | "selector" : "$[[email protected]==1.0]", |
| 803 | "document" : [{"a": 1, "d": "e"}, {"a":2, "d": "f"}, {"a":"1", "d": "g"}], |
| 804 | "result": [ |
| 805 | {"a": 1, "d": "e"} |
| 806 | ] |
| 807 | }, |
| 808 | { |
| 809 | "name": "equals number, exponent", |
| 810 | "selector" : "$[[email protected]==1e2]", |
| 811 | "document" : [{"a": 100, "d": "e"}, {"a":100.1, "d": "f"}, {"a":"100", "d": "g"}], |
| 812 | "result": [ |
| 813 | {"a": 100, "d": "e"} |
| 814 | ] |
| 815 | }, |
| 816 | { |
| 817 | "name": "equals number, positive exponent", |
| 818 | "selector" : "$[[email protected]==1e+2]", |
| 819 | "document" : [{"a": 100, "d": "e"}, {"a":100.1, "d": "f"}, {"a":"100", "d": "g"}], |
| 820 | "result": [ |
| 821 | {"a": 100, "d": "e"} |
| 822 | ] |
| 823 | }, |
| 824 | { |
| 825 | "name": "equals number, negative exponent", |
| 826 | "selector" : "$[[email protected]==1e-2]", |
| 827 | "document" : [{"a": 0.01, "d": "e"}, {"a":0.02, "d": "f"}, {"a":"0.01", "d": "g"}], |
| 828 | "result": [ |
| 829 | {"a": 0.01, "d": "e"} |
| 830 | ] |
| 831 | }, |
| 832 | { |
| 833 | "name": "equals number, decimal fraction", |
| 834 | "selector" : "$[[email protected]==1.1]", |
| 835 | "document" : [{"a": 1.1, "d": "e"}, {"a":1.0, "d": "f"}, {"a":"1.1", "d": "g"}], |
| 836 | "result": [ |
| 837 | {"a": 1.1, "d": "e"} |
| 838 | ] |
| 839 | }, |
| 840 | { |
| 841 | "name": "equals number, decimal fraction, no fractional digit", |
| 842 | "selector" : "$[[email protected]==1.]", |
| 843 | "invalid_selector": true |
| 844 | }, |
| 845 | { |
| 846 | "name": "equals number, decimal fraction, exponent", |
| 847 | "selector" : "$[[email protected]==1.1e2]", |
| 848 | "document" : [{"a": 110, "d": "e"}, {"a":110.1, "d": "f"}, {"a":"110", "d": "g"}], |
| 849 | "result": [ |
| 850 | {"a": 110, "d": "e"} |
| 851 | ] |
| 852 | }, |
| 853 | { |
| 854 | "name": "equals number, decimal fraction, positive exponent", |
| 855 | "selector" : "$[[email protected]==1.1e+2]", |
| 856 | "document" : [{"a": 110, "d": "e"}, {"a":110.1, "d": "f"}, {"a":"110", "d": "g"}], |
| 857 | "result": [ |
| 858 | {"a": 110, "d": "e"} |
| 859 | ] |
| 860 | }, |
| 861 | { |
| 862 | "name": "equals number, decimal fraction, negative exponent", |
| 863 | "selector" : "$[[email protected]==1.1e-2]", |
| 864 | "document" : [{"a": 0.011, "d": "e"}, {"a":0.012, "d": "f"}, {"a":"0.011", "d": "g"}], |
| 865 | "result": [ |
| 866 | {"a": 0.011, "d": "e"} |
| 867 | ] |
| 868 | }, |
| 869 | { |
| 870 | "name": "equals, special nothing", |
| 871 | "selector" : "$.values[?length(@.a) == value($..c)]", |
| 872 | "document" : { |
| 873 | "c": "cd", |
| 874 | "values": [ |
| 875 | {"a": "ab"}, |
| 876 | {"c": "d"}, |
| 877 | {"a": null} |
| 878 | ] |
| 879 | }, |
| 880 | "result": [ |
| 881 | {"c": "d"}, |
| 882 | {"a": null} |
| 883 | ] |
| 884 | }, |
| 885 | { |
| 886 | "name": "object data", |
| 887 | "selector" : "$[?@<3]", |
| 888 | "document" : { |
| 889 | "a": 1, |
| 890 | "b": 2, |
| 891 | "c": 3 |
| 892 | }, |
| 893 | "results": [ |
| 894 | [1, 2], |
| 895 | [2, 1] |
| 896 | ] |
| 897 | }, |
| 898 | { |
| 899 | "name": "and binds more tightly than or", |
| 900 | "selector" : "$[[email protected] || @.b && @.b]", |
| 901 | "document" : [{"a": 1}], |
| 902 | "result": [ |
| 903 | {"a": 1} |
| 904 | ] |
| 905 | }, |
| 906 | { |
| 907 | "name": "left to right evaluation", |
| 908 | "selector" : "$[[email protected] && @.b || @.a]", |
| 909 | "document" : [{"a": 1}], |
| 910 | "result": [ |
| 911 | {"a": 1} |
| 912 | ] |
| 913 | }, |
| 914 | { |
| 915 | "name": "group terms, left", |
| 916 | "selector" : "$[?(@.a || @.b) && @.a]", |
| 917 | "document" : [{"a": 1}], |
| 918 | "result": [ |
| 919 | {"a": 1} |
| 920 | ] |
| 921 | }, |
| 922 | { |
| 923 | "name": "group terms, right", |
| 924 | "selector" : "$[[email protected] && (@.b || @.a)]", |
| 925 | "document" : [{"a": 1}], |
| 926 | "result": [ |
| 927 | {"a": 1} |
| 928 | ] |
| 929 | }, |
| 930 | { |
| 931 | "name": "group terms, or before and", |
| 932 | "selector" : "$[?(@.a || @.b) && @.b]", |
| 933 | "document" : [{"a": 1}], |
| 934 | "result": [] |
| 935 | } |
| 936 | ] |
| 937 | } |