Skip to content

Add highlight to assertion #1689

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 1 commit into from
Jun 8, 2023
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
17 changes: 9 additions & 8 deletions Tests/SwiftParserTest/Assertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,15 @@ func assertDiagnostic<T: SyntaxProtocol>(
line: spec.line
)
}
if let highlight = spec.highlight {
assertStringsEqualWithDiff(
diag.highlights.map(\.description).joined().trimmingTrailingWhitespace(),
highlight.trimmingTrailingWhitespace(),
file: spec.file,
line: spec.line
)
}

let highlight = spec.highlight ?? diag.node.description
assertStringsEqualWithDiff(
diag.highlights.map(\.description).joined().trimmingTrailingWhitespace(),
highlight.trimmingTrailingWhitespace(),
file: spec.file,
line: spec.line
)

if diag.notes.count != spec.notes.count {
XCTFail(
"""
Expand Down
1 change: 1 addition & 0 deletions Tests/SwiftParserTest/ExpressionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ final class ExpressionTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand Down
21 changes: 21 additions & 0 deletions Tests/SwiftParserTest/translated/MultilineErrorsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -89,6 +90,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -114,6 +116,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -138,6 +141,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -162,6 +166,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -187,6 +192,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -213,6 +219,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "unexpected tab in indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -238,6 +245,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "unexpected tab in indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -263,6 +271,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "unexpected space in indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand All @@ -288,6 +297,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "unexpected space in indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand Down Expand Up @@ -381,6 +391,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "unexpected space in indentation of the next 2 lines in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand Down Expand Up @@ -416,18 +427,21 @@ final class MultilineErrorsTests: XCTestCase {
DiagnosticSpec(
locationMarker: "1️⃣",
message: "insufficient indentation of the next 4 lines in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
),
DiagnosticSpec(
locationMarker: "2️⃣",
message: "unexpected space in indentation of the next 2 lines in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
),
DiagnosticSpec(
locationMarker: "3️⃣",
message: "insufficient indentation of the next 2 lines in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
),
Expand Down Expand Up @@ -463,6 +477,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of the next 2 lines in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand Down Expand Up @@ -490,12 +505,14 @@ final class MultilineErrorsTests: XCTestCase {
DiagnosticSpec(
locationMarker: "1️⃣",
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
),
DiagnosticSpec(
locationMarker: "2️⃣",
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
),
Expand Down Expand Up @@ -854,6 +871,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand Down Expand Up @@ -881,12 +899,14 @@ final class MultilineErrorsTests: XCTestCase {
DiagnosticSpec(
locationMarker: "1️⃣",
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
),
DiagnosticSpec(
locationMarker: "2️⃣",
message: "insufficient indentation of line in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
),
Expand Down Expand Up @@ -915,6 +935,7 @@ final class MultilineErrorsTests: XCTestCase {
diagnostics: [
DiagnosticSpec(
message: "insufficient indentation of the next 3 lines in multi-line string literal",
highlight: " ",
notes: [NoteSpec(message: "should match indentation here")],
fixIts: ["change indentation of this line to match closing delimiter"]
)
Expand Down