Skip to content

Commit 26edd0c

Browse files
committed
Tests: use #filePath instead of #file.
Removes warnings.
1 parent 7240d30 commit 26edd0c

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

Tests/PatternsTests/GrammarTests.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ class GrammarTests: XCTestCase {
2727
func testDirectRecursion1() throws {
2828
let g = Grammar()
2929
g.a <- "a" / any g.a
30-
let g1Parser = try Parser(g)
31-
assertParseAll(g1Parser, input: " aba", count: 2)
30+
let parser = try Parser(g)
31+
assertParseAll(parser, input: " aba", count: 2)
3232
}
3333

3434
func testDirectRecursion2() throws {
3535
let g = Grammar()
3636
g.balancedParentheses <- "(" (!OneOf("()") any / g.balancedParentheses)* ")"
37-
let g2Parser = try Parser(g)
38-
assertParseAll(g2Parser, input: "( )", count: 1)
39-
assertParseAll(g2Parser, input: "((( )( )))", count: 1)
40-
assertParseAll(g2Parser, input: "(( )", count: 0)
37+
let parser = try Parser(g)
38+
assertParseAll(parser, input: "( )", count: 1)
39+
assertParseAll(parser, input: "((( )( )))", count: 1)
40+
assertParseAll(parser, input: "(( )", count: 0)
4141
}
4242

4343
func testArithmetic() throws {
@@ -62,8 +62,7 @@ class GrammarTests: XCTestCase {
6262

6363
func isCall(_ inst: Instruction<String.UTF8View>) -> Bool {
6464
switch inst {
65-
case .call:
66-
return true
65+
case .call: return true
6766
default: return false
6867
}
6968
}

Tests/PatternsTests/TestHelpers.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension XCTestCase {
2929
(_ seq1: @autoclosure () throws -> S1,
3030
_ seq2: @autoclosure () throws -> S2,
3131
_ message: @autoclosure () -> String = "",
32-
file: StaticString = #file, line: UInt = #line)
32+
file: StaticString = #filePath, line: UInt = #line)
3333
where S1.Element: Sequence, S2.Element: Sequence, S1.Element.Element: Equatable,
3434
S1.Element.Element == S2.Element.Element {
3535
do {
@@ -44,14 +44,14 @@ extension XCTestCase {
4444
}
4545

4646
func assertParseAll<Input: BidirectionalCollection>
47-
(_ parser: Parser<Input>, input: Input, result: [Input], file: StaticString = #file, line: UInt = #line)
47+
(_ parser: Parser<Input>, input: Input, result: [Input], file: StaticString = #filePath, line: UInt = #line)
4848
where Input.Element: Hashable {
4949
let parsed = parser.ranges(in: input).map { input[$0] }
5050
XCTAssertEqualElements(parsed, result, file: file, line: line)
5151
}
5252

5353
func assertParseAll<P: Patterns.Pattern>
54-
(_ pattern: P, input: P.Input, result: [P.Input], file: StaticString = #file, line: UInt = #line) {
54+
(_ pattern: P, input: P.Input, result: [P.Input], file: StaticString = #filePath, line: UInt = #line) {
5555
do {
5656
let parser = try Parser(search: pattern)
5757
assertParseAll(parser, input: input, result: result, file: file, line: line)
@@ -61,7 +61,7 @@ extension XCTestCase {
6161
}
6262

6363
func assertParseAll<Input: BidirectionalCollection>
64-
(_ parser: Parser<Input>, input: Input, result: Input? = nil, count: Int, file: StaticString = #file, line: UInt = #line)
64+
(_ parser: Parser<Input>, input: Input, result: Input? = nil, count: Int, file: StaticString = #filePath, line: UInt = #line)
6565
where Input.Element: Hashable {
6666
if let result = result {
6767
assertParseAll(parser, input: input, result: Array(repeating: result, count: count), file: file, line: line)
@@ -73,7 +73,7 @@ extension XCTestCase {
7373
}
7474

7575
func assertParseAll<P: Patterns.Pattern>(_ pattern: P, input: P.Input, result: P.Input? = nil, count: Int,
76-
file: StaticString = #file, line: UInt = #line) {
76+
file: StaticString = #filePath, line: UInt = #line) {
7777
do {
7878
let parser = try Parser(search: pattern)
7979
assertParseAll(parser, input: input, result: result, count: count, file: file, line: line)
@@ -94,12 +94,12 @@ extension XCTestCase {
9494
}
9595

9696
func assertParseMarkers<P: Patterns.Pattern>(_ pattern: P, input: String,
97-
file: StaticString = #file, line: UInt = #line) where P.Input == String {
97+
file: StaticString = #filePath, line: UInt = #line) where P.Input == String {
9898
assertParseMarkers(try! Parser(search: pattern), input: input, file: file, line: line)
9999
}
100100

101101
func assertParseMarkers(_ pattern: Parser<String>, input: String,
102-
file: StaticString = #file, line: UInt = #line) {
102+
file: StaticString = #filePath, line: UInt = #line) {
103103
let (string, correct) = processMarkers(input)
104104
let parsedRanges = Array(pattern.ranges(in: string))
105105
XCTAssert(parsedRanges.allSatisfy { $0.isEmpty }, "Not all results are empty ranges",
@@ -118,12 +118,12 @@ extension XCTestCase {
118118
}
119119

120120
func assertCaptures<P: Patterns.Pattern>(_ pattern: P, input: String, result: [[String]],
121-
file: StaticString = #file, line: UInt = #line) where P.Input == String {
121+
file: StaticString = #filePath, line: UInt = #line) where P.Input == String {
122122
assertCaptures(try! Parser(search: pattern), input: input, result: result, file: file, line: line)
123123
}
124124

125125
func assertCaptures(_ pattern: Parser<String>, input: String, result: [[String]],
126-
file: StaticString = #file, line: UInt = #line) {
126+
file: StaticString = #filePath, line: UInt = #line) {
127127
let matches = Array(pattern.matches(in: input))
128128
let output = matches.map { match in match.captures.map { String(input[$0.range]) } }
129129
XCTAssertEqual(output, result, file: file, line: line)
@@ -142,7 +142,7 @@ extension RangeReplaceableCollection where Self: BidirectionalCollection {
142142
}
143143
}
144144

145-
func getLocalURL(for path: String, file: String = #file) -> URL {
145+
func getLocalURL(for path: String, file: String = #filePath) -> URL {
146146
URL(fileURLWithPath: file)
147147
.deletingLastPathComponent().appendingPathComponent(path)
148148
}

Tests/PerformanceTests/PerformanceTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class PerformanceTests: XCTestCase {
142142
}
143143
}
144144

145-
func getLocalURL(for path: String, file: String = #file) -> URL {
145+
func getLocalURL(for path: String, file: String = #filePath) -> URL {
146146
URL(fileURLWithPath: file)
147147
.deletingLastPathComponent().appendingPathComponent(path)
148148
}

0 commit comments

Comments
 (0)