|
481 | 481 | "name": "union child, single quotes, incomplete escape",
|
482 | 482 | "selector": "$['\\']",
|
483 | 483 | "invalid_selector": true
|
| 484 | + }, { |
| 485 | + "name": "union", |
| 486 | + "selector": "$[0,2]", |
| 487 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 488 | + "result": [0, 2] |
| 489 | + }, { |
| 490 | + "name": "union with whitespace", |
| 491 | + "selector": "$[ 0 , 1 ]", |
| 492 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 493 | + "result": [0, 1] |
| 494 | + }, { |
| 495 | + "name": "empty union", |
| 496 | + "selector": "$[]", |
| 497 | + "invalid_selector": true |
484 | 498 | }, {
|
485 | 499 | "name": "union array access",
|
486 | 500 | "selector": "$[0]",
|
|
524 | 538 | "name": "union array access, leading -0",
|
525 | 539 | "selector": "$[-01]",
|
526 | 540 | "invalid_selector": true
|
527 |
| - } |
| 541 | + }, { |
| 542 | + "name": "union array slice", |
| 543 | + "selector": "$[1:3]", |
| 544 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 545 | + "result": [1, 2] |
| 546 | + }, { |
| 547 | + "name": "union array slice with step", |
| 548 | + "selector": "$[1:6:2]", |
| 549 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 550 | + "result": [1, 3, 5] |
| 551 | + }, { |
| 552 | + "name": "union array slice with everything omitted, short form", |
| 553 | + "selector": "$[:]", |
| 554 | + "document": [0, 1, 2, 3], |
| 555 | + "result": [0, 1, 2, 3] |
| 556 | + }, { |
| 557 | + "name": "union array slice with everything omitted, long form", |
| 558 | + "selector": "$[::]", |
| 559 | + "document": [0, 1, 2, 3], |
| 560 | + "result": [0, 1, 2, 3] |
| 561 | + }, { |
| 562 | + "name": "union array slice with start omitted", |
| 563 | + "selector": "$[:2]", |
| 564 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 565 | + "result": [0, 1] |
| 566 | + }, { |
| 567 | + "name": "union array slice with start and end omitted", |
| 568 | + "selector": "$[::2]", |
| 569 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 570 | + "result": [0, 2, 4, 6, 8] |
| 571 | + }, { |
| 572 | + "name": "union array slice, last index", |
| 573 | + "selector": "$[-1]", |
| 574 | + "document": [0, 1, 2, 3], |
| 575 | + "result": [3] |
| 576 | + }, { |
| 577 | + "name": "union array slice, overflowed index", |
| 578 | + "selector": "$[4]", |
| 579 | + "document": [0, 1, 2, 3], |
| 580 | + "result": [] |
| 581 | + }, { |
| 582 | + "name": "union array slice, underflowed index", |
| 583 | + "selector": "$[-5]", |
| 584 | + "document": [0, 1, 2, 3], |
| 585 | + "result": [] |
| 586 | + }, { |
| 587 | + "name": "union array slice, negative step with default start and end", |
| 588 | + "selector": "$[::-1]", |
| 589 | + "document": [0, 1, 2, 3], |
| 590 | + "result": [3, 2, 1, 0] |
| 591 | + }, { |
| 592 | + "name": "union array slice, negative step with default start", |
| 593 | + "selector": "$[:0:-1]", |
| 594 | + "document": [0, 1, 2, 3], |
| 595 | + "result": [3, 2, 1] |
| 596 | + }, { |
| 597 | + "name": "union array slice, negative step with default end", |
| 598 | + "selector": "$[2::-1]", |
| 599 | + "document": [0, 1, 2, 3], |
| 600 | + "result": [2, 1, 0] |
| 601 | + }, { |
| 602 | + "name": "union array slice, larger negative step", |
| 603 | + "selector": "$[::-2]", |
| 604 | + "document": [0, 1, 2, 3], |
| 605 | + "result": [3, 1] |
| 606 | + }, { |
| 607 | + "name": "union array slice, negative range with default step", |
| 608 | + "selector": "$[-1:-3]", |
| 609 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 610 | + "result": [] |
| 611 | + }, { |
| 612 | + "name": "union array slice, negative range with negative step", |
| 613 | + "selector": "$[-1:-3:-1]", |
| 614 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 615 | + "result": [9, 8] |
| 616 | + }, { |
| 617 | + "name": "union array slice, negative range with larger negative step", |
| 618 | + "selector": "$[-1:-6:-2]", |
| 619 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 620 | + "result": [9, 7, 5] |
| 621 | + }, { |
| 622 | + "name": "union array slice, larger negative range with larger negative step", |
| 623 | + "selector": "$[-1:-7:-2]", |
| 624 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 625 | + "result": [9, 7, 5] |
| 626 | + }, { |
| 627 | + "name": "union array slice, negative from, positive to", |
| 628 | + "selector": "$[-5:7]", |
| 629 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 630 | + "result": [5, 6] |
| 631 | + }, { |
| 632 | + "name": "union array slice, negative from", |
| 633 | + "selector": "$[-2:]", |
| 634 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 635 | + "result": [8, 9] |
| 636 | + }, { |
| 637 | + "name": "union array slice, positive from, negative to", |
| 638 | + "selector": "$[1:-1]", |
| 639 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 640 | + "result": [1, 2, 3, 4, 5, 6, 7, 8] |
| 641 | + }, { |
| 642 | + "name": "union array slice, negative from, positive to, negative step", |
| 643 | + "selector": "$[-1:1:-1]", |
| 644 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 645 | + "result": [9, 8, 7, 6, 5, 4, 3, 2] |
| 646 | + }, { |
| 647 | + "name": "union array slice, positive from, negative to, negative step", |
| 648 | + "selector": "$[7:-5:-1]", |
| 649 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 650 | + "result": [7, 6] |
| 651 | + }, { |
| 652 | + "name": "union array slice, too many colons", |
| 653 | + "selector": "$[1:2:3:4]", |
| 654 | + "invalid_selector": true |
| 655 | + }, { |
| 656 | + "name": "union array slice, non-integer array index", |
| 657 | + "selector": "$[1:2:a]", |
| 658 | + "invalid_selector": true |
| 659 | + }, { |
| 660 | + "name": "union array slice, zero step", |
| 661 | + "selector": "$[1:2:0]", |
| 662 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 663 | + "result": [] |
| 664 | + }, { |
| 665 | + "name": "union array slice, empty range", |
| 666 | + "selector": "$[2:2]", |
| 667 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 668 | + "result": [] |
| 669 | + }, { |
| 670 | + "name": "union array slice, default indices with empty array", |
| 671 | + "selector": "$[:]", |
| 672 | + "document": [], |
| 673 | + "result": [] |
| 674 | + }, { |
| 675 | + "name": "union array slice, negative step with empty array", |
| 676 | + "selector": "$[::-1]", |
| 677 | + "document": [], |
| 678 | + "result": [] |
| 679 | + }, { |
| 680 | + "name": "union array slice, maximal range with positive step", |
| 681 | + "selector": "$[0:10]", |
| 682 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 683 | + "result": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
| 684 | + }, { |
| 685 | + "name": "union array slice, maximal range with negative step", |
| 686 | + "selector": "$[9:0:-1]", |
| 687 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 688 | + "result": [9, 8, 7, 6, 5, 4, 3, 2, 1] |
| 689 | + }, { |
| 690 | + "name": "union array slice, excessively large to value", |
| 691 | + "selector": "$[2:113667776004]", |
| 692 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 693 | + "result": [2, 3, 4, 5, 6, 7, 8, 9] |
| 694 | + }, { |
| 695 | + "name": "union array slice, excessively small from value", |
| 696 | + "selector": "$[-113667776004:1]", |
| 697 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 698 | + "result": [0] |
| 699 | + }, { |
| 700 | + "name": "union array slice, excessively large from value with negative step", |
| 701 | + "selector": "$[113667776004:0:-1]", |
| 702 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 703 | + "result": [9, 8, 7, 6, 5, 4, 3, 2, 1] |
| 704 | + }, { |
| 705 | + "name": "union array slice, excessively small to value with negative step", |
| 706 | + "selector": "$[3:-113667776004:-1]", |
| 707 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 708 | + "result": [3, 2, 1, 0] |
| 709 | + }, { |
| 710 | + "name": "union array slice, excessively large step", |
| 711 | + "selector": "$[1:10:113667776004]", |
| 712 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 713 | + "result": [1] |
| 714 | + }, { |
| 715 | + "name": "union array slice, excessively small step", |
| 716 | + "selector": "$[-1:-10:-113667776004]", |
| 717 | + "document": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 718 | + "result": [9] |
| 719 | + } |
528 | 720 | ]}
|
0 commit comments