Skip to content

Commit 16c4bb9

Browse files
committed
Fix LongTests.
Some of them took too long for the compiler.
1 parent 0d57449 commit 16c4bb9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Sources/Patterns/Atomic Patterns/Line.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension String.UTF8View.Element: CharacterLike {
1414
@inlinable
1515
public var isNewline: Bool {
1616
// “\n” (U+000A): LINE FEED (LF), U+000B: LINE TABULATION (VT), U+000C: FORM FEED (FF), “\r” (U+000D): CARRIAGE RETURN (CR)
17-
(10 ... 13).contains(self)
17+
self < 14 && self > 9
1818
}
1919
}
2020

Tests/LongTests/LongTests.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ import XCTest
44

55
class LongTests: XCTestCase {
66
func testOr() {
7-
XCTAssert(type(of: "a" / letter / ascii / punctuation / "b")
8-
== OrPattern<OrPattern<Literal, OneOf>, Literal>.self,
7+
let char = letter / ascii / punctuation
8+
XCTAssert(type(of: "a" / char / "b")
9+
== OrPattern<OrPattern<Literal<String>, OneOf<String>>, Literal<String>>.self,
910
"'/' operator isn't optimizing OneOf's properly.")
1011
}
1112

1213
func testNot() {
1314
XCTAssert(
14-
type(of: "a" !letter ascii "b") == Concat<Concat<Literal, OneOf>, Literal>.self,
15+
type(of: "a" !letter ascii "b") == Concat<Concat<Literal<String>, OneOf<String>>, Literal<String>>.self,
1516
"'•' operator isn't optimizing OneOf's properly.")
1617
}
1718

1819
func testAnd() throws {
1920
XCTAssert(
20-
type(of: "a" &&letter ascii "b") == Concat<Concat<Literal, OneOf>, Literal>.self,
21+
type(of: "a" &&letter ascii "b") == Concat<Concat<Literal<String>, OneOf<String>>, Literal<String>>.self,
2122
"'•' operator isn't optimizing OneOf's properly.")
2223
}
2324

@@ -50,14 +51,15 @@ class LongTests: XCTestCase {
5051
}
5152

5253
// from http://www.inf.puc-rio.br/~roberto/docs/peg.pdf, page 2 and 5
53-
static let pegGrammar = Grammar { g in
54+
static let pegGrammar = Grammar<String> { g in
5455
//g.all <- g.pattern • !any
5556
g.pattern <- g.grammar / g.simplepatt
5657
g.grammar <- (g.nonterminal "<-" g.sp g.simplepatt)+
5758
g.simplepatt <- g.alternative ("/" g.sp g.alternative)*
5859
g.alternative <- (OneOf("!&")¿ g.sp g.suffix)+
5960
g.suffix <- g.primary (OneOf("*+?") g.sp)*
60-
g.primary <- "(" g.sp g.pattern ")" g.sp / "." g.sp / g.literal / g.charclass / g.nonterminal !"<-"
61+
let primaryPart1 = "(" g.sp g.pattern ")" g.sp / "." g.sp / g.literal
62+
g.primary <- primaryPart1 / g.charclass / g.nonterminal !"<-"
6163
g.literal <- "" (!"" any)* "" g.sp
6264
g.charclass <- "[" (!"]" (any "-" any / any))* "]" g.sp
6365
g.nonterminal <- OneOf("a" ... "z", "A" ... "Z")+ g.sp

0 commit comments

Comments
 (0)