Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/_StringProcessing/Regex/DSLList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ extension DSLList {
func indexOfCoalescableAtom(startingAt position: Int, findLast: Bool = false) -> Int? {
switch nodes[position] {
case .concatenation(let children):
guard children.count > 0 else { return nil }
var position = position + 1
if findLast {
for _ in 0..<(children.count - 1) {
Expand Down
25 changes: 24 additions & 1 deletion Tests/RegexBuilderTests/RegexDSLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,30 @@ class RegexDSLTests: XCTestCase {

""")
}


func testManyConcatenatedComponents() throws {
let r = Regex {
#/a\n/#
Regex<Substring>(verbatim: "/some/path")
#/\n/#
#/b\n/#
Regex<Substring>(verbatim: "/some/path")
#/\n/#
#/c\n/#
Regex<Substring>(verbatim: "/some/path")
#/\n/#
#/d\n/#
Regex<Substring>(verbatim: "/some/path")
#/\n/#
#/e\n/#
Regex<Substring>(verbatim: "/some/path")
#/\n/#
#/f/#
}
let input = "a\n/some/path\nb\n/some/path\nc\n/some/path\nd\n/some/path\ne\n/some/path\nf"
XCTAssertNotNil(try r.wholeMatch(in: input))
}

func testRegexComponentBuilderResultType() {
// Test that the user can declare a closure or computed property marked with
// `@RegexComponentBuilder` with `Regex` as the result type.
Expand Down
Loading