Skip to content

Commit ef5dbd4

Browse files
committed
Expand variadic compilation tests
1 parent 9430a76 commit ef5dbd4

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

Diff for: Tests/RegexBuilderTests/RegexDSLTests.swift

+72
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,78 @@ extension RegexDSLTests {
20292029
XCTAssertEqual(match.output.2, "b")
20302030
XCTAssertNil(match.output.3)
20312031
}
2032+
2033+
func testVariadicNesting_Compilation() {
2034+
let regex2_1 = Regex {
2035+
"a"
2036+
Optionally {
2037+
Capture { "b" }
2038+
}
2039+
}
2040+
let _: Regex<(Substring, Substring?)> = regex2_1
2041+
2042+
let regex2_2 = Regex {
2043+
"a"
2044+
Optionally {
2045+
Capture { "b" }
2046+
Capture { "c" }
2047+
}
2048+
}
2049+
let _: Regex<(Substring, Substring?, Substring?)> = regex2_2
2050+
2051+
let regex3_1 = Regex {
2052+
Optionally {
2053+
regex2_1
2054+
}
2055+
}
2056+
let _: Regex<(Substring, Substring??)> = regex3_1
2057+
2058+
let regex3_2 = Regex {
2059+
Optionally {
2060+
regex2_2
2061+
}
2062+
}
2063+
let _: Regex<(Substring, Substring??, Substring??)> = regex3_2
2064+
2065+
let regex3_1_1 = Regex {
2066+
Optionally {
2067+
regex2_1
2068+
regex2_1
2069+
}
2070+
}
2071+
let _: Regex<(Substring, Substring??, Substring??)> = regex3_1_1
2072+
2073+
let regex3_2_1 = Regex {
2074+
Optionally {
2075+
regex2_2
2076+
regex2_1
2077+
}
2078+
}
2079+
let _: Regex<(Substring, Substring??, Substring??, Substring??)> = regex3_2_1
2080+
2081+
let regex3_2_2 = Regex {
2082+
Optionally {
2083+
regex2_2
2084+
regex2_2
2085+
}
2086+
}
2087+
let _: Regex<(Substring, Substring??, Substring??, Substring??, Substring??)> = regex3_2_2
2088+
2089+
let regexChoices = Regex {
2090+
ChoiceOf {
2091+
Capture { "A" }
2092+
"b"
2093+
"c"
2094+
Capture { "D" }
2095+
Optionally {
2096+
Capture {
2097+
"E"
2098+
}
2099+
}
2100+
}
2101+
}
2102+
let _: Regex<(Substring, Substring?, Substring?, Substring??)> = regexChoices
2103+
}
20322104
}
20332105

20342106
extension Unicode.Scalar {

0 commit comments

Comments
 (0)