@@ -298,6 +298,7 @@ func firstMatchTests(
298
298
enableTracing: Bool = false ,
299
299
dumpAST: Bool = false ,
300
300
xfail: Bool = false ,
301
+ validateOptimizations: Bool = true ,
301
302
semanticLevel: RegexSemanticLevel = . graphemeCluster,
302
303
file: StaticString = #filePath,
303
304
line: UInt = #line
@@ -311,6 +312,7 @@ func firstMatchTests(
311
312
enableTracing: enableTracing,
312
313
dumpAST: dumpAST,
313
314
xfail: xfail,
315
+ validateOptimizations: validateOptimizations,
314
316
semanticLevel: semanticLevel,
315
317
file: file,
316
318
line: line)
@@ -1586,7 +1588,7 @@ extension RegexTests {
1586
1588
1587
1589
// TODO: Why is a match not found when unoptimized?
1588
1590
firstMatchTest (
1589
- #"\d{3}(?<=USD\d{3})"# , input: " Price: USD100 " , match: " 100 " )
1591
+ #"\d{3}(?<=USD\d{3})"# , input: " Price: USD100 " , match: " 100 " , validateOptimizations : false )
1590
1592
1591
1593
firstMatchTest (
1592
1594
#"(?<!USD)\d+"# , input: " Price: JYP100 " , match: " 100 " )
@@ -1598,6 +1600,34 @@ extension RegexTests {
1598
1600
1599
1601
firstMatchTest (
1600
1602
#"\d{3}(?<!USD\d{3})"# , input: " Price: JYP100 " , match: " 100 " )
1603
+
1604
+ firstMatchTest ( #"(?<=abc)def"# , input: " abcdefg " , match: " def " , validateOptimizations: false )
1605
+ firstMatchTests (
1606
+ #"(?<=az|b|c)def"# ,
1607
+ ( " azdefg " , " def " ) ,
1608
+ ( " bdefg " , " def " ) ,
1609
+ ( " cdefg " , " def " ) ,
1610
+ ( " 123defg " , nil ) ,
1611
+ validateOptimizations: false
1612
+ )
1613
+
1614
+ // FIXME: quickMatch and thoroughMatch have different results
1615
+ firstMatchTest (
1616
+ #"(?<=\d{1,3}-.{1,3}-\d{1,3})suffix"# ,
1617
+ input: " 123-_+/-789suffix " ,
1618
+ match: " suffix " ,
1619
+ validateOptimizations: false
1620
+ )
1621
+
1622
+ firstMatchTests (
1623
+ #"(?<=^\d{1,3})abc"# ,
1624
+ ( " 123abc " , " abc " ) ,
1625
+ ( " 12abc " , " abc " ) ,
1626
+ ( " 1abc " , " abc " ) ,
1627
+ ( " 1234abc " , nil ) , // FIXME: Shouldn't match but does because `^` assertions are broken
1628
+ ( " z123abc " , nil ) , // FIXME: Same as above
1629
+ validateOptimizations: false
1630
+ )
1601
1631
}
1602
1632
1603
1633
func testMatchAnchors( ) throws {
0 commit comments