@@ -482,13 +482,13 @@ test('parseScript: push of a push statement', t => {
482
482
} ) ;
483
483
484
484
test ( 'parseScript: push of an evaluation' , t => {
485
- t . deepEqual ( parseScript ( '<$(<1> <2> OP_ADD)> OP_EQUAL' ) , {
485
+ t . deepEqual ( parseScript ( '<$(<1><2> OP_ADD)> OP_EQUAL' ) , {
486
486
status : true ,
487
487
value : {
488
488
end : {
489
- column : 29 ,
489
+ column : 28 ,
490
490
line : 1 ,
491
- offset : 28
491
+ offset : 27
492
492
} ,
493
493
name : 'Script' ,
494
494
start : {
@@ -499,9 +499,9 @@ test('parseScript: push of an evaluation', t => {
499
499
value : [
500
500
{
501
501
end : {
502
- column : 20 ,
502
+ column : 19 ,
503
503
line : 1 ,
504
- offset : 19
504
+ offset : 18
505
505
} ,
506
506
name : 'Push' ,
507
507
start : {
@@ -511,9 +511,9 @@ test('parseScript: push of an evaluation', t => {
511
511
} ,
512
512
value : {
513
513
end : {
514
- column : 19 ,
514
+ column : 18 ,
515
515
line : 1 ,
516
- offset : 18
516
+ offset : 17
517
517
} ,
518
518
name : 'Script' ,
519
519
start : {
@@ -524,9 +524,9 @@ test('parseScript: push of an evaluation', t => {
524
524
value : [
525
525
{
526
526
end : {
527
- column : 19 ,
527
+ column : 18 ,
528
528
line : 1 ,
529
- offset : 18
529
+ offset : 17
530
530
} ,
531
531
name : 'Evaluation' ,
532
532
start : {
@@ -536,9 +536,9 @@ test('parseScript: push of an evaluation', t => {
536
536
} ,
537
537
value : {
538
538
end : {
539
- column : 18 ,
539
+ column : 17 ,
540
540
line : 1 ,
541
- offset : 17
541
+ offset : 16
542
542
} ,
543
543
name : 'Script' ,
544
544
start : {
@@ -591,40 +591,40 @@ test('parseScript: push of an evaluation', t => {
591
591
} ,
592
592
{
593
593
end : {
594
- column : 11 ,
594
+ column : 10 ,
595
595
line : 1 ,
596
- offset : 10
596
+ offset : 9
597
597
} ,
598
598
name : 'Push' ,
599
599
start : {
600
- column : 8 ,
600
+ column : 7 ,
601
601
line : 1 ,
602
- offset : 7
602
+ offset : 6
603
603
} ,
604
604
value : {
605
605
end : {
606
- column : 10 ,
606
+ column : 9 ,
607
607
line : 1 ,
608
- offset : 9
608
+ offset : 8
609
609
} ,
610
610
name : 'Script' ,
611
611
start : {
612
- column : 9 ,
612
+ column : 8 ,
613
613
line : 1 ,
614
- offset : 8
614
+ offset : 7
615
615
} ,
616
616
value : [
617
617
{
618
618
end : {
619
- column : 10 ,
619
+ column : 9 ,
620
620
line : 1 ,
621
- offset : 9
621
+ offset : 8
622
622
} ,
623
623
name : 'BigIntLiteral' ,
624
624
start : {
625
- column : 9 ,
625
+ column : 8 ,
626
626
line : 1 ,
627
- offset : 8
627
+ offset : 7
628
628
} ,
629
629
value : BigInt ( 2 )
630
630
}
@@ -633,15 +633,15 @@ test('parseScript: push of an evaluation', t => {
633
633
} ,
634
634
{
635
635
end : {
636
- column : 18 ,
636
+ column : 17 ,
637
637
line : 1 ,
638
- offset : 17
638
+ offset : 16
639
639
} ,
640
640
name : 'Identifier' ,
641
641
start : {
642
- column : 12 ,
642
+ column : 11 ,
643
643
line : 1 ,
644
- offset : 11
644
+ offset : 10
645
645
} ,
646
646
value : 'OP_ADD'
647
647
}
@@ -653,15 +653,15 @@ test('parseScript: push of an evaluation', t => {
653
653
} ,
654
654
{
655
655
end : {
656
- column : 29 ,
656
+ column : 28 ,
657
657
line : 1 ,
658
- offset : 28
658
+ offset : 27
659
659
} ,
660
660
name : 'Identifier' ,
661
661
start : {
662
- column : 21 ,
662
+ column : 20 ,
663
663
line : 1 ,
664
- offset : 20
664
+ offset : 19
665
665
} ,
666
666
value : 'OP_EQUAL'
667
667
}
@@ -672,11 +672,11 @@ test('parseScript: push of an evaluation', t => {
672
672
673
673
test ( 'parseScript: invalid identifier characters' , t => {
674
674
t . deepEqual ( parseScript ( 'test_$variable' ) , {
675
- expected : [ 'EOF' , 'whitespace' ] ,
675
+ expected : [ "the opening parenthesis of this evaluation ('(')" ] ,
676
676
index : {
677
- column : 6 ,
677
+ column : 7 ,
678
678
line : 1 ,
679
- offset : 5
679
+ offset : 6
680
680
} ,
681
681
status : false
682
682
} ) ;
@@ -703,33 +703,118 @@ test('parseScript: incomplete UTF8Literal', t => {
703
703
} ) ;
704
704
} ) ;
705
705
706
- test ( 'parseScript: incomplete BigIntLiteral' , t => {
707
- t . deepEqual ( parseScript ( '1234a 42 "abc"' ) , {
708
- expected : [ 'EOF' , 'whitespace' ] ,
709
- index : {
710
- column : 5 ,
711
- line : 1 ,
712
- offset : 4
713
- } ,
714
- status : false
706
+ test ( 'parseScript: BigIntLiteral without trailing whitespace' , t => {
707
+ t . deepEqual ( parseScript ( '1234a' ) , {
708
+ status : true ,
709
+ value : {
710
+ end : {
711
+ column : 6 ,
712
+ line : 1 ,
713
+ offset : 5
714
+ } ,
715
+ name : 'Script' ,
716
+ start : {
717
+ column : 1 ,
718
+ line : 1 ,
719
+ offset : 0
720
+ } ,
721
+ value : [
722
+ {
723
+ end : {
724
+ column : 5 ,
725
+ line : 1 ,
726
+ offset : 4
727
+ } ,
728
+ name : 'BigIntLiteral' ,
729
+ start : {
730
+ column : 1 ,
731
+ line : 1 ,
732
+ offset : 0
733
+ } ,
734
+ value : BigInt ( 1234 )
735
+ } ,
736
+ {
737
+ end : {
738
+ column : 6 ,
739
+ line : 1 ,
740
+ offset : 5
741
+ } ,
742
+ name : 'Identifier' ,
743
+ start : {
744
+ column : 5 ,
745
+ line : 1 ,
746
+ offset : 4
747
+ } ,
748
+ value : 'a'
749
+ }
750
+ ]
751
+ }
715
752
} ) ;
716
753
} ) ;
717
754
718
- test ( 'parseScript: incomplete HexLiteral' , t => {
755
+ test ( 'parseScript: HexLiteral without trailing whitespace ' , t => {
719
756
t . deepEqual ( parseScript ( '0x010203f' ) , {
720
- expected : [ 'EOF' , 'whitespace' ] ,
721
- index : {
722
- column : 9 ,
723
- line : 1 ,
724
- offset : 8
725
- } ,
726
- status : false
757
+ status : true ,
758
+ value : {
759
+ end : {
760
+ column : 10 ,
761
+ line : 1 ,
762
+ offset : 9
763
+ } ,
764
+ name : 'Script' ,
765
+ start : {
766
+ column : 1 ,
767
+ line : 1 ,
768
+ offset : 0
769
+ } ,
770
+ value : [
771
+ {
772
+ end : {
773
+ column : 9 ,
774
+ line : 1 ,
775
+ offset : 8
776
+ } ,
777
+ name : 'HexLiteral' ,
778
+ start : {
779
+ column : 1 ,
780
+ line : 1 ,
781
+ offset : 0
782
+ } ,
783
+ value : '010203'
784
+ } ,
785
+ {
786
+ end : {
787
+ column : 10 ,
788
+ line : 1 ,
789
+ offset : 9
790
+ } ,
791
+ name : 'Identifier' ,
792
+ start : {
793
+ column : 9 ,
794
+ line : 1 ,
795
+ offset : 8
796
+ } ,
797
+ value : 'f'
798
+ }
799
+ ]
800
+ }
727
801
} ) ;
728
802
} ) ;
729
803
730
804
test ( 'parseScript: incomplete push' , t => {
731
805
t . deepEqual ( parseScript ( '<my_var' ) , {
732
- expected : [ "the end of this push statement ('>')" , 'whitespace' ] ,
806
+ expected : [
807
+ 'a double quote (")' ,
808
+ "a hex literal ('0x...')" ,
809
+ "a single quote (')" ,
810
+ 'a valid identifier' ,
811
+ 'an integer literal' ,
812
+ "the end of this push statement ('>')" ,
813
+ "the start of a multi-line comment ('/*')" ,
814
+ "the start of a push statement ('<')" ,
815
+ "the start of a single-line comment ('//')" ,
816
+ "the start of an evaluation ('$')"
817
+ ] ,
733
818
index : {
734
819
column : 8 ,
735
820
line : 1 ,
0 commit comments