Skip to content

[5.7] Retract ~= for Regex. #527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2022
Merged
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
11 changes: 0 additions & 11 deletions Sources/_StringProcessing/Regex/Match.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,3 @@ extension BidirectionalCollection where SubSequence == Substring {
try? r.regex.prefixMatch(in: self[...])
}
}

@available(SwiftStdlib 5.7, *)
extension RegexComponent {
public static func ~=(regex: Self, input: String) -> Bool {
input.wholeMatch(of: regex) != nil
}

public static func ~=(regex: Self, input: Substring) -> Bool {
input.wholeMatch(of: regex) != nil
}
}
60 changes: 0 additions & 60 deletions Tests/RegexBuilderTests/AlgorithmsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,66 +104,6 @@ class RegexConsumerTests: XCTestCase {
result: "9+16, 3, 10, 99+1")
)
}

func testSwitches() {
// Failure cases
do {
switch "abcde" {
case Regex {
"a"
ZeroOrMore(.any)
"f"
}:
XCTFail()

case OneOrMore { CharacterClass.whitespace }:
XCTFail()

case "abc":
XCTFail()

case Regex {
"a"
"b"
"c"
}:
XCTFail()

default:
break
}
}
// Success cases
do {
let input = "abcde"

switch input {
case Regex {
"a"
ZeroOrMore(.any)
"e"
}:
break

default:
XCTFail()
}

guard case Regex({
"a"
ZeroOrMore(.any)
"e"
}) = input else {
XCTFail()
return
}

guard case OneOrMore(.word) = input else {
XCTFail()
return
}
}
}
}

class AlgorithmsResultBuilderTests: XCTestCase {
Expand Down
15 changes: 0 additions & 15 deletions Tests/RegexTests/AlgorithmsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,4 @@ class AlgorithmTests: XCTestCase {
XCTAssertEqual(
s2.ranges(of: try Regex("a*?")).map(s2.offsets(of:)), [0..<0, 1..<1, 2..<2])
}

func testSwitches() {
switch "abcde" {
case try! Regex("a.*f"):
XCTFail()
case try! Regex("abc"):
XCTFail()

case try! Regex("a.*e"):
break // success

default:
XCTFail()
}
}
}