Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ffd04e

Browse files
committedMar 25, 2024
Expand variadic compilation tests
1 parent 9430a76 commit 8ffd04e

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
 

‎Tests/RegexBuilderTests/RegexDSLTests.swift

+90
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,8 @@ fileprivate let regexWithCapture = #/:(\d+):/#
18421842
fileprivate let regexWithLabeledCapture = #/:(?<number>\d+):/#
18431843
@available(SwiftStdlib 5.7, *)
18441844
fileprivate let regexWithNonCapture = #/:(?:\d+):/#
1845+
@available(SwiftStdlib 5.7, *)
1846+
fileprivate let regexWithMultipleCaptures = #/:(\d+):(.+):(\d+):/#
18451847

18461848
@available(SwiftStdlib 5.7, *)
18471849
extension RegexDSLTests {
@@ -2029,6 +2031,94 @@ extension RegexDSLTests {
20292031
XCTAssertEqual(match.output.2, "b")
20302032
XCTAssertNil(match.output.3)
20312033
}
2034+
2035+
func testVariadicNesting_Compilation() {
2036+
let x_sOCs৲৲_x = 1
2037+
let regex_OC = Regex { // sOCsco
2038+
"a"
2039+
Optionally {
2040+
Capture { "b" }
2041+
}
2042+
}
2043+
let _: Regex<(Substring, Substring?)> = regex_OC
2044+
2045+
let regex_OCC = Regex {
2046+
"a"
2047+
Optionally {
2048+
Capture { "b" }
2049+
Capture { "c" }
2050+
}
2051+
}
2052+
let _: Regex<(Substring, Substring?, Substring?)> = regex_OCC
2053+
2054+
let regex_O_OC = Regex {
2055+
Optionally {
2056+
regex_OC
2057+
}
2058+
}
2059+
let _: Regex<(Substring, Substring??)> = regex_O_OC
2060+
2061+
let regex_O_OCC = Regex {
2062+
Optionally {
2063+
regex_OCC
2064+
}
2065+
}
2066+
let _: Regex<(Substring, Substring??, Substring??)> = regex_O_OCC
2067+
2068+
let regex_O_OC_OC = Regex {
2069+
Optionally {
2070+
regex_OC
2071+
regex_OC
2072+
}
2073+
}
2074+
let _: Regex<(Substring, Substring??, Substring??)> = regex_O_OC_OC
2075+
2076+
let regex_O_OCC_OC = Regex {
2077+
Optionally {
2078+
regex_OCC
2079+
regex_OC
2080+
}
2081+
}
2082+
let _: Regex<(Substring, Substring??, Substring??, Substring??)> = regex_O_OCC_OC
2083+
2084+
let regex_O_OCC_OCC = Regex {
2085+
Optionally {
2086+
regex_OCC
2087+
regex_OCC
2088+
}
2089+
}
2090+
let _: Regex<(Substring, Substring??, Substring??, Substring??, Substring??)> = regex_O_OCC_OCC
2091+
2092+
let regexChoices_CCOC = Regex {
2093+
ChoiceOf {
2094+
Capture { "A" }
2095+
"b"
2096+
"c"
2097+
Capture { "D" }
2098+
Optionally {
2099+
Capture {
2100+
"E"
2101+
}
2102+
}
2103+
}
2104+
}
2105+
let _: Regex<(Substring, Substring?, Substring?, Substring??)> = regexChoices_CCOC
2106+
2107+
let regex_Zr3Mr3MOr3e = Regex {
2108+
ZeroOrMore {
2109+
regexWithMultipleCaptures
2110+
}
2111+
OneOrMore {
2112+
regexWithMultipleCaptures
2113+
}
2114+
OneOrMore {
2115+
Optionally {
2116+
regexWithMultipleCaptures
2117+
}
2118+
}
2119+
}
2120+
let _: Regex<(Substring, Substring?, Substring?, Substring?, Substring, Substring, Substring, Substring?, Substring?, Substring?)> = regex_Zr3Mr3MOr3
2121+
}
20322122
}
20332123

20342124
extension Unicode.Scalar {

0 commit comments

Comments
 (0)
Please sign in to comment.