@@ -589,59 +589,40 @@ extension RegexTests {
589589 input: " \u{7} \u{1b} \u{a} \n \r \t abc " , match: " a " )
590590 }
591591
592- func testMatchGroups( ) {
593- // MARK: Groups
594-
595- // Named captures
596- matchTest (
597- #"a(?<label>b)c"# , input: " 123abcxyz " , match: " abc " )
598- matchTest (
599- #"a(?'label'b)c"# , input: " 123abcxyz " , match: " abc " )
600- matchTest (
601- #"a(?P<label>b)c"# , input: " 123abcxyz " , match: " abc " )
602-
603- // Other groups
604- matchTest (
605- #"a(?:b)c"# , input: " 123abcxyz " , match: " abc " )
606- matchTest (
607- " (?|(a)|(b)|(c)) " , input: " 123abcxyz " , match: " a " )
608-
609- matchTest (
610- #"(?:a|.b)c"# , input: " 123abcacxyz " , match: " abc " )
611- matchTest (
612- #"(?>a|.b)c"# , input: " 123abcacxyz " , match: " ac " , xfail: true )
613- matchTest (
614- " (*atomic:a|.b)c " , input: " 123abcacxyz " , match: " ac " , xfail: true )
615- matchTest (
616- #"(?:a+)[a-z]c"# , input: " 123aacacxyz " , match: " aac " )
617- matchTest (
618- #"(?>a+)[a-z]c"# , input: " 123aacacxyz " , match: " ac " , xfail: true )
619-
592+ func testAssertions( ) {
620593 matchTest (
621594 #"\d+(?= dollars)"# ,
622- input: " Price: 100 dollars " , match: " 100 " , xfail: true )
595+ input: " Price: 100 dollars " , match: " 100 " )
596+ matchTest (
597+ #"\d+(?= pesos)"# ,
598+ input: " Price: 100 dollars " , match: nil )
623599 matchTest (
624600 #"(?=\d+ dollars)\d+"# ,
625- input: " Price: 100 dollars " , match: " 100 " , xfail: true )
601+ input: " Price: 100 dollars " , match: " 100 " ,
602+ xfail: true ) // TODO
603+
626604 matchTest (
627605 #"\d+(*pla: dollars)"# ,
628- input: " Price: 100 dollars " , match: " 100 " , xfail : true )
606+ input: " Price: 100 dollars " , match: " 100 " )
629607 matchTest (
630608 #"\d+(*positive_lookahead: dollars)"# ,
631- input: " Price: 100 dollars " , match: " 100 " , xfail : true )
609+ input: " Price: 100 dollars " , match: " 100 " )
632610
633611 matchTest (
634612 #"\d+(?! dollars)"# ,
635- input: " Price: 100 pesos " , match: " 100 " , xfail: true )
613+ input: " Price: 100 pesos " , match: " 100 " )
614+ matchTest (
615+ #"\d+(?! dollars)"# ,
616+ input: " Price: 100 dollars " , match: " 10 " )
636617 matchTest (
637618 #"(?!\d+ dollars)\d+"# ,
638- input: " Price: 100 pesos " , match: " 100 " , xfail : true )
619+ input: " Price: 100 pesos " , match: " 100 " )
639620 matchTest (
640621 #"\d+(*nla: dollars)"# ,
641- input: " Price: 100 pesos " , match: " 100 " , xfail : true )
622+ input: " Price: 100 pesos " , match: " 100 " )
642623 matchTest (
643624 #"\d+(*negative_lookahead: dollars)"# ,
644- input: " Price: 100 pesos " , match: " 100 " , xfail : true )
625+ input: " Price: 100 pesos " , match: " 100 " )
645626
646627 matchTest (
647628 #"(?<=USD)\d+"# , input: " Price: USD100 " , match: " 100 " , xfail: true )
@@ -664,6 +645,36 @@ extension RegexTests {
664645 // engines generally enforce that lookbehinds are fixed width
665646 matchTest (
666647 #"\d{3}(?<!USD\d{3})"# , input: " Price: JYP100 " , match: " 100 " , xfail: true )
648+ }
649+
650+ func testMatchGroups( ) {
651+ // MARK: Groups
652+
653+ // Named captures
654+ matchTest (
655+ #"a(?<label>b)c"# , input: " 123abcxyz " , match: " abc " )
656+ matchTest (
657+ #"a(?'label'b)c"# , input: " 123abcxyz " , match: " abc " )
658+ matchTest (
659+ #"a(?P<label>b)c"# , input: " 123abcxyz " , match: " abc " )
660+
661+ // Other groups
662+ matchTest (
663+ #"a(?:b)c"# , input: " 123abcxyz " , match: " abc " )
664+ matchTest (
665+ " (?|(a)|(b)|(c)) " , input: " 123abcxyz " , match: " a " )
666+
667+ matchTest (
668+ #"(?:a|.b)c"# , input: " 123abcacxyz " , match: " abc " )
669+ matchTest (
670+ #"(?>a|.b)c"# , input: " 123abcacxyz " , match: " ac " , xfail: true )
671+ matchTest (
672+ " (*atomic:a|.b)c " , input: " 123abcacxyz " , match: " ac " , xfail: true )
673+ matchTest (
674+ #"(?:a+)[a-z]c"# , input: " 123aacacxyz " , match: " aac " )
675+ matchTest (
676+ #"(?>a+)[a-z]c"# , input: " 123aacacxyz " , match: " ac " , xfail: true )
677+
667678
668679 // TODO: Test example where non-atomic is significant
669680 matchTest (
0 commit comments