Skip to content

Commit 39b3336

Browse files
authored
Merge pull request #1438 from ahoppen/ahoppen/lowercase-assert
Lowercase all `Assert` methods
2 parents 734c911 + cfa0294 commit 39b3336

File tree

138 files changed

+2357
-2357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2357
-2357
lines changed

Sources/SwiftParser/SwiftParser.docc/FixingBugs.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Once you’ve written a test case (see below), set a breakpoint in `Parser.parse
1010

1111
1. Add a new test case in `SwiftParserTest` that looks like the following
1212
```swift
13-
AssertParse(
13+
assertParse(
1414
"""
1515
<#your code that does not round trip#>
1616
"""
@@ -27,7 +27,7 @@ Diagnostics are produced when the parsed syntax tree contains missing or unexpec
2727

2828
1. Add a test case in `SwiftParserTest` that looks like the following
2929
```swift
30-
AssertParse(
30+
assertParse(
3131
"""
3232
<#your code that produces an invalid syntax tree#>
3333
""",
@@ -54,7 +54,7 @@ To add a new, more contextual diagnostic, perform the following steps.
5454
1. Add a test case in `SwiftParserTest` that looks like the following
5555
5656
```swift
57-
AssertParse(
57+
assertParse(
5858
"""
5959
<#your code that produced the unhelpful diagnostic#>
6060
""",
@@ -69,7 +69,7 @@ To add a new, more contextual diagnostic, perform the following steps.
6969
5. If the function does not already exist, write a new visit method on <doc:SwiftParser/ParseDiagnosticsGenerator>.
7070
6. In that visitation method, detect the pattern for which the improved diagnostic should be emitted and emit it using `diagnostics.append`.
7171
7. Mark the missing or garbage nodes that are covered by the new diagnostic as handled by adding their `SyntaxIdentifier`s to `handledNodes`.
72-
8. If the diagnostic produces Fix-Its assert that they are generated by adding the Fix-It's message to the `DiagnosticSpec` with the `fixIt` parameter and asserting that applying the Fix-Its produces the correct source code by adding the `fixedSource` parameter to `AssertParse`.
72+
8. If the diagnostic produces Fix-Its assert that they are generated by adding the Fix-It's message to the `DiagnosticSpec` with the `fixIt` parameter and asserting that applying the Fix-Its produces the correct source code by adding the `fixedSource` parameter to `assertParse`.
7373
7474
> 💡 Tip: To make typing the marker emojis more convienient. you can set up code snippets in Xcode. To do this, perform the following steps:
7575
> 1. Type the marker in any Xcode window or find it in some test case

Sources/_SwiftSyntaxTestSupport/AssertEqualWithDiff.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import XCTest
2323
/// which this function was called.
2424
/// - line: The line number on which failure occurred. Defaults to the line number on which this
2525
/// function was called.
26-
public func AssertStringsEqualWithDiff(
26+
public func assertStringsEqualWithDiff(
2727
_ actual: String,
2828
_ expected: String,
2929
_ message: String = "",
@@ -34,7 +34,7 @@ public func AssertStringsEqualWithDiff(
3434
if actual == expected {
3535
return
3636
}
37-
FailStringsEqualWithDiff(
37+
failStringsEqualWithDiff(
3838
actual,
3939
expected,
4040
message,
@@ -55,7 +55,7 @@ public func AssertStringsEqualWithDiff(
5555
/// which this function was called.
5656
/// - line: The line number on which failure occurred. Defaults to the line number on which this
5757
/// function was called.
58-
public func AssertDataEqualWithDiff(
58+
public func assertDataEqualWithDiff(
5959
_ actual: Data,
6060
_ expected: Data,
6161
_ message: String = "",
@@ -69,7 +69,7 @@ public func AssertDataEqualWithDiff(
6969

7070
// NOTE: Converting to `Stirng` here looses invalid UTF8 sequence difference,
7171
// but at least we can see something is different.
72-
FailStringsEqualWithDiff(
72+
failStringsEqualWithDiff(
7373
String(decoding: actual, as: UTF8.self),
7474
String(decoding: expected, as: UTF8.self),
7575
message,
@@ -80,7 +80,7 @@ public func AssertDataEqualWithDiff(
8080
}
8181

8282
/// `XCTFail` with `diff`-style output.
83-
public func FailStringsEqualWithDiff(
83+
public func failStringsEqualWithDiff(
8484
_ actual: String,
8585
_ expected: String,
8686
_ message: String = "",

Tests/SwiftDiagnosticsTest/DiagnosticsFormatterTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class DiagnosticsFormatterTests: XCTestCase {
3333
│ ╰─ error: expected expression after operator
3434
3535
"""
36-
AssertStringsEqualWithDiff(annotate(source: source), expectedOutput)
36+
assertStringsEqualWithDiff(annotate(source: source), expectedOutput)
3737
}
3838

3939
func testMultipleDiagnosticsInOneLine() {
@@ -47,7 +47,7 @@ final class DiagnosticsFormatterTests: XCTestCase {
4747
│ ╰─ error: expected name in member access
4848
4949
"""
50-
AssertStringsEqualWithDiff(annotate(source: source), expectedOutput)
50+
assertStringsEqualWithDiff(annotate(source: source), expectedOutput)
5151
}
5252

5353
func testLineSkipping() {
@@ -78,7 +78,7 @@ final class DiagnosticsFormatterTests: XCTestCase {
7878
│ ╰─ error: expected value and ')' to end function call
7979
8080
"""
81-
AssertStringsEqualWithDiff(annotate(source: source), expectedOutput)
81+
assertStringsEqualWithDiff(annotate(source: source), expectedOutput)
8282
}
8383

8484
func testTwoDiagnosticsAtSameLocation() throws {
@@ -91,7 +91,7 @@ final class DiagnosticsFormatterTests: XCTestCase {
9191
9292
"""
9393

94-
AssertStringsEqualWithDiff(annotate(source: source), expectedOutput)
94+
assertStringsEqualWithDiff(annotate(source: source), expectedOutput)
9595
}
9696

9797
func testAddsColoringToSingleErrorDiagnostic() {
@@ -104,7 +104,7 @@ final class DiagnosticsFormatterTests: XCTestCase {
104104
\u{001B}[0;36m│\u{001B}[0;0m ╰─ \u{001B}[1;31merror: expected expression after operator\u{001B}[0;0m
105105
106106
"""
107-
AssertStringsEqualWithDiff(annotate(source: source, colorize: true), expectedOutput)
107+
assertStringsEqualWithDiff(annotate(source: source, colorize: true), expectedOutput)
108108
}
109109

110110
func testAddsColoringToMultipleDiagnosticsInOneLine() {
@@ -118,7 +118,7 @@ final class DiagnosticsFormatterTests: XCTestCase {
118118
\u{001B}[0;36m│\u{001B}[0;0m ╰─ \u{001B}[1;31merror: expected name in member access\u{001B}[0;0m
119119
120120
"""
121-
AssertStringsEqualWithDiff(annotate(source: source, colorize: true), expectedOutput)
121+
assertStringsEqualWithDiff(annotate(source: source, colorize: true), expectedOutput)
122122
}
123123

124124
func testColoringWithHighlights() {
@@ -133,6 +133,6 @@ final class DiagnosticsFormatterTests: XCTestCase {
133133
134134
"""
135135

136-
AssertStringsEqualWithDiff(annotate(source: source, colorize: true), expectedOutput)
136+
assertStringsEqualWithDiff(annotate(source: source, colorize: true), expectedOutput)
137137
}
138138
}

Tests/SwiftDiagnosticsTest/GroupDiagnosticsFormatterTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ final class GroupedDiagnosticsFormatterTests: XCTestCase {
109109
)
110110

111111
let annotated = DiagnosticsFormatter.annotateSources(in: group)
112-
AssertStringsEqualWithDiff(
112+
assertStringsEqualWithDiff(
113113
annotated,
114114
"""
115115
=== main.swift:5 ===
@@ -178,7 +178,7 @@ final class GroupedDiagnosticsFormatterTests: XCTestCase {
178178
)
179179

180180
let annotated = DiagnosticsFormatter.annotateSources(in: group)
181-
AssertStringsEqualWithDiff(
181+
assertStringsEqualWithDiff(
182182
annotated,
183183
"""
184184
=== main.swift:2 ===

Tests/SwiftParserTest/Assertions.swift

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct LexemeSpec {
6565
/// which this function was called.
6666
/// - line: The line number on which failure occurred. Defaults to the line number on which this
6767
/// function was called.
68-
private func AssertTokens(
68+
private func assertTokens(
6969
_ actual: [Lexer.Lexeme],
7070
_ expected: [LexemeSpec],
7171
markerLocations: [String: Int],
@@ -98,7 +98,7 @@ private func AssertTokens(
9898
}
9999

100100
if actualLexeme.leadingTriviaText != expectedLexeme.leadingTrivia {
101-
FailStringsEqualWithDiff(
101+
failStringsEqualWithDiff(
102102
String(syntaxText: actualLexeme.leadingTriviaText),
103103
String(syntaxText: expectedLexeme.leadingTrivia),
104104
"Leading trivia does not match",
@@ -108,7 +108,7 @@ private func AssertTokens(
108108
}
109109

110110
if actualLexeme.tokenText.debugDescription != expectedLexeme.tokenText.debugDescription {
111-
FailStringsEqualWithDiff(
111+
failStringsEqualWithDiff(
112112
actualLexeme.tokenText.debugDescription,
113113
expectedLexeme.tokenText.debugDescription,
114114
"Token text does not match",
@@ -118,7 +118,7 @@ private func AssertTokens(
118118
}
119119

120120
if actualLexeme.trailingTriviaText != expectedLexeme.trailingTrivia {
121-
FailStringsEqualWithDiff(
121+
failStringsEqualWithDiff(
122122
String(syntaxText: actualLexeme.trailingTriviaText),
123123
String(syntaxText: expectedLexeme.trailingTrivia),
124124
"Trailing trivia does not match",
@@ -142,7 +142,7 @@ private func AssertTokens(
142142
line: expectedLexeme.line
143143
)
144144
case (let actualError?, let expectedError?):
145-
AssertStringsEqualWithDiff(
145+
assertStringsEqualWithDiff(
146146
actualError.diagnosticMessage(wholeTextBytes: Array(actualLexeme.wholeText)).message,
147147
expectedError,
148148
file: expectedLexeme.file,
@@ -175,7 +175,7 @@ private func AssertTokens(
175175
}
176176
}
177177

178-
func AssertLexemes(
178+
func assertLexemes(
179179
_ markedSource: String,
180180
lexemes expectedLexemes: [LexemeSpec],
181181
file: StaticString = #file,
@@ -196,7 +196,7 @@ func AssertLexemes(
196196
break
197197
}
198198
}
199-
AssertTokens(lexemes, expectedLexemes, markerLocations: markerLocations, file: file, line: line)
199+
assertTokens(lexemes, expectedLexemes, markerLocations: markerLocations, file: file, line: line)
200200
}
201201
}
202202

@@ -324,7 +324,7 @@ class FixItApplier: SyntaxRewriter {
324324
}
325325

326326
/// Assert that `location` is the same as that of `locationMarker` in `tree`.
327-
func AssertLocation<T: SyntaxProtocol>(
327+
func assertLocation<T: SyntaxProtocol>(
328328
_ location: SourceLocation,
329329
in tree: T,
330330
markerLocations: [String: Int],
@@ -354,7 +354,7 @@ func AssertLocation<T: SyntaxProtocol>(
354354

355355
/// Assert that the diagnostic `note` produced in `tree` matches `spec`,
356356
/// using `markerLocations` to translate markers to actual source locations.
357-
func AssertNote<T: SyntaxProtocol>(
357+
func assertNote<T: SyntaxProtocol>(
358358
_ note: Note,
359359
in tree: T,
360360
markerLocations: [String: Int],
@@ -364,7 +364,7 @@ func AssertNote<T: SyntaxProtocol>(
364364
) {
365365
XCTAssertEqual(note.message, spec.message, file: file, line: line)
366366
let locationConverter = SourceLocationConverter(file: "", source: tree.description)
367-
AssertLocation(
367+
assertLocation(
368368
note.location(converter: locationConverter),
369369
in: tree,
370370
markerLocations: markerLocations,
@@ -376,7 +376,7 @@ func AssertNote<T: SyntaxProtocol>(
376376

377377
/// Assert that the diagnostic `diag` produced in `tree` matches `spec`,
378378
/// using `markerLocations` to translate markers to actual source locations.
379-
func AssertDiagnostic<T: SyntaxProtocol>(
379+
func assertDiagnostic<T: SyntaxProtocol>(
380380
_ diag: Diagnostic,
381381
in tree: T,
382382
markerLocations: [String: Int],
@@ -385,7 +385,7 @@ func AssertDiagnostic<T: SyntaxProtocol>(
385385
line: UInt = #line
386386
) {
387387
let locationConverter = SourceLocationConverter(file: "", source: tree.description)
388-
AssertLocation(
388+
assertLocation(
389389
diag.location(converter: locationConverter),
390390
in: tree,
391391
markerLocations: markerLocations,
@@ -397,7 +397,7 @@ func AssertDiagnostic<T: SyntaxProtocol>(
397397
XCTAssertEqual(diag.diagnosticID, id, file: file, line: line)
398398
}
399399
if let message = spec.message {
400-
AssertStringsEqualWithDiff(diag.message, message, file: file, line: line)
400+
assertStringsEqualWithDiff(diag.message, message, file: file, line: line)
401401
}
402402
XCTAssertEqual(spec.severity, diag.diagMessage.severity, file: file, line: line)
403403
if diag.message.contains("\n") {
@@ -411,7 +411,7 @@ func AssertDiagnostic<T: SyntaxProtocol>(
411411
)
412412
}
413413
if let highlight = spec.highlight {
414-
AssertStringsEqualWithDiff(
414+
assertStringsEqualWithDiff(
415415
diag.highlights.map(\.description).joined().trimmingTrailingWhitespace(),
416416
highlight.trimmingTrailingWhitespace(),
417417
file: file,
@@ -430,13 +430,13 @@ func AssertDiagnostic<T: SyntaxProtocol>(
430430
)
431431
} else {
432432
for (note, expectedNote) in zip(diag.notes, notes) {
433-
AssertNote(note, in: tree, markerLocations: markerLocations, expected: expectedNote, file: expectedNote.file, line: expectedNote.line)
433+
assertNote(note, in: tree, markerLocations: markerLocations, expected: expectedNote, file: expectedNote.file, line: expectedNote.line)
434434
}
435435
}
436436
}
437437
if let fixIts = spec.fixIts {
438438
if fixIts != diag.fixIts.map(\.message.message) {
439-
FailStringsEqualWithDiff(
439+
failStringsEqualWithDiff(
440440
diag.fixIts.map(\.message.message).joined(separator: "\n"),
441441
fixIts.joined(separator: "\n"),
442442
file: file,
@@ -462,9 +462,9 @@ public struct AssertParseOptions: OptionSet {
462462
public static let normalizeNewlinesInFixedSource = AssertParseOptions(rawValue: 1 << 1)
463463
}
464464

465-
/// Same as `AssertParse` overload with a `(String) -> S` `parse`,
465+
/// Same as `assertParse` overload with a `(String) -> S` `parse`,
466466
/// parsing the resulting `String` as a `SourceFileSyntax`.
467-
func AssertParse(
467+
func assertParse(
468468
_ markedSource: String,
469469
substructure expectedSubstructure: Syntax? = nil,
470470
substructureAfterMarker: String = "START",
@@ -475,7 +475,7 @@ func AssertParse(
475475
file: StaticString = #file,
476476
line: UInt = #line
477477
) {
478-
AssertParse(
478+
assertParse(
479479
markedSource,
480480
{ SourceFileSyntax.parse(from: &$0) },
481481
substructure: expectedSubstructure,
@@ -489,10 +489,10 @@ func AssertParse(
489489
)
490490
}
491491

492-
/// Same as `AssertParse` overload with a `(String) -> S` `parse`,
492+
/// Same as `assertParse` overload with a `(String) -> S` `parse`,
493493
/// constructing a `Parser` from the given `String` and passing that to
494494
/// `parse` instead.
495-
func AssertParse<S: SyntaxProtocol>(
495+
func assertParse<S: SyntaxProtocol>(
496496
_ markedSource: String,
497497
_ parse: (inout Parser) -> S,
498498
substructure expectedSubstructure: Syntax? = nil,
@@ -504,7 +504,7 @@ func AssertParse<S: SyntaxProtocol>(
504504
file: StaticString = #file,
505505
line: UInt = #line
506506
) {
507-
AssertParse(
507+
assertParse(
508508
markedSource,
509509
{ (source: String) -> S in
510510
var parser = Parser(source)
@@ -539,7 +539,7 @@ func AssertParse<S: SyntaxProtocol>(
539539
/// - applyFixIts: Applies only the fix-its with these messages.
540540
/// - fixedSource: Asserts that the source after applying fix-its matches
541541
/// this string.
542-
func AssertParse<S: SyntaxProtocol>(
542+
func assertParse<S: SyntaxProtocol>(
543543
_ markedSource: String,
544544
_ parse: (String) -> S,
545545
substructure expectedSubstructure: Syntax? = nil,
@@ -558,7 +558,7 @@ func AssertParse<S: SyntaxProtocol>(
558558
let tree: S = parse(source)
559559

560560
// Round-trip
561-
AssertStringsEqualWithDiff(
561+
assertStringsEqualWithDiff(
562562
"\(tree)",
563563
source,
564564
additionalInfo: """
@@ -594,7 +594,7 @@ func AssertParse<S: SyntaxProtocol>(
594594
)
595595
} else {
596596
for (diag, expectedDiag) in zip(diags, expectedDiagnostics) {
597-
AssertDiagnostic(diag, in: tree, markerLocations: markerLocations, expected: expectedDiag, file: expectedDiag.file, line: expectedDiag.line)
597+
assertDiagnostic(diag, in: tree, markerLocations: markerLocations, expected: expectedDiag, file: expectedDiag.file, line: expectedDiag.line)
598598
}
599599
}
600600

@@ -608,7 +608,7 @@ func AssertParse<S: SyntaxProtocol>(
608608
.replacingOccurrences(of: "\r\n", with: "\n")
609609
.replacingOccurrences(of: "\r", with: "\n")
610610
}
611-
AssertStringsEqualWithDiff(
611+
assertStringsEqualWithDiff(
612612
fixedTreeDescription.trimmingTrailingWhitespace(),
613613
expectedFixedSource.trimmingTrailingWhitespace(),
614614
file: file,

0 commit comments

Comments
 (0)