@@ -15,47 +15,19 @@ import Testing
1515
1616@Suite struct OptimizationTests {
1717 @available ( macOS 9999 , * )
18- @Test ( arguments: [ #/a/#, #/a+/#, #/(?:a+)/#, #/(?:a)+/#, #/(?m)a+/#, #/ab?c/#, #/(?:a+)+$/# ] )
18+ @Test ( arguments: [ #/a/#, #/a+/#, #/(?:a+)/#, #/(?:a)+/#, #/(?m)a+/#, #/ab?c/#, #/(?:a+)+$/#, #/(?:(?:a+b)+b)/# ] )
1919 func requiredFirstAtom( pattern: Regex < Substring > ) throws {
20- let atom = pattern. root. requiredFirstAtom ( )
21- #expect( atom? . literalCharacterValue == " a " , " Missing first character atom in ' \( pattern. _literalPattern!) ' " )
22-
2320 let list = DSLList ( tree: pattern. program. tree)
24- var nodes = list. nodes [ ... ]
25- let atom2 = _StringProcessing. requiredFirstAtom ( & nodes)
26- #expect( atom2? . literalCharacterValue == " a " , " Missing first character atom in ' \( pattern. _literalPattern!) ' " )
27-
28- let atom3 = list. requiredFirstAtom ( )
29- #expect( atom3? . literalCharacterValue == " a " , " Missing first character atom in ' \( pattern. _literalPattern!) ' " )
21+ let atom = list. requiredFirstAtom ( )
22+ #expect( atom? . literalCharacterValue == " a " , " Missing first character atom in ' \( pattern. _literalPattern!) ' " )
3023 }
3124
3225 @available ( macOS 9999 , * )
3326 @Test ( arguments: [ #/a?/#, #/(?:a|b)/#, #/[a]/#, #/a?bc/# ] )
3427 func noRequiredFirstAtom( pattern: Regex < Substring > ) throws {
35- let atom = pattern. root. requiredFirstAtom ( )
36- #expect( atom == nil , " Unexpected required first atom in ' \( pattern. _literalPattern!) ' " )
37-
3828 let list = DSLList ( tree: pattern. program. tree)
39- var nodes = list. nodes [ ... ]
40- let atom2 = _StringProcessing. requiredFirstAtom ( & nodes)
41- #expect( atom2 == nil , " Unexpected required first atom in ' \( pattern. _literalPattern!) ' " )
42-
43- let atom3 = list. requiredFirstAtom ( )
44- #expect( atom3 == nil , " Unexpected required first atom in ' \( pattern. _literalPattern!) ' " )
45- }
46-
47- @available ( macOS 9999 , * )
48- @Test ( arguments: [ #/a/#, #/a+/#, #/(?:a+)/#, #/(?:a)+/#, #/(?m)a+/#, #/cb?a/# ] )
49- func requiredLastAtom( pattern: Regex < Substring > ) throws {
50- let atom = pattern. root. requiredLastAtom ( )
51- #expect( atom? . literalCharacterValue == " a " , " Missing last character atom in ' \( pattern. _literalPattern!) ' " )
52- }
53-
54- @available ( macOS 9999 , * )
55- @Test ( arguments: [ #/a?/#, #/a*/#, #/(?:a|b)/#, #/[a]/#, #/abc?/# ] )
56- func noRequiredLastAtom( pattern: Regex < Substring > ) throws {
57- let atom = pattern. root. requiredLastAtom ( )
58- #expect( atom == nil , " Unexpected required last atom in ' \( pattern. _literalPattern!) ' " )
29+ let atom = list. requiredFirstAtom ( )
30+ #expect( atom == nil , " Unexpected required first atom in ' \( pattern. _literalPattern!) ' " )
5931 }
6032
6133 @available ( macOS 9999 , * )
0 commit comments