Skip to content

Commit 0d57449

Browse files
committed
testGrammarLiteralSearch in utf8.
1 parent 896fac6 commit 0d57449

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Sources/Patterns/Regex.swiftno renamed to Sources/Patterns/Regex.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ public protocol RegexConvertible: Pattern {
1313
var regex: String { get }
1414
}
1515

16-
// For `OneOf` to be convertible the regex has to be provided manually when it is created.
17-
1816
extension Literal: RegexConvertible where Input: StringProtocol {
1917
public var regex: String { NSRegularExpression.escapedPattern(for: String(self.elements)) }
2018
}
@@ -63,3 +61,5 @@ extension Skip: RegexConvertible {
6361
extension NoPattern: RegexConvertible {
6462
public var regex: String { "" }
6563
}
64+
65+
// For `OneOf` to be convertible the regex has to be provided manually when it is created. See OneOf.swift.

Tests/PerformanceTests/PerformanceTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ class PerformanceTests: XCTestCase {
8888
}
8989

9090
func testGrammarLiteralSearch() throws {
91-
let g = Grammar()
92-
g.a <- Capture("Prince") / any g.a
91+
func any<Input>() -> OneOf<Input> { OneOf(description: "any", contains: { _ in true }) }
92+
93+
let g = Grammar<String.UTF8View>()
94+
g.a <- Capture("Prince") / any() g.a
9395
let pattern = try Parser(g)
9496
try speedTest(pattern, textFraction: 13, hits: 260)
9597
}

0 commit comments

Comments
 (0)