Skip to content

Commit 81e0299

Browse files
committed
improve marking mismatches a bit in test cases
1 parent 47ed90f commit 81e0299

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Tests/JExtractSwiftTests/Asserts/TextAssertions.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ func assertOutput(
179179
print("==== ---------------------------------------------------------------")
180180
print("Expected output:")
181181
for (n, e) in expectedLines.enumerated() {
182-
print("\(n): \(e)".yellow(if: diffLineNumbers.map({$0 - matchingOutputOffset}).contains(n)))
182+
let isMismatch = diffLineNumbers.map({$0 - matchingOutputOffset}).contains(n)
183+
let marker = isMismatch ? " // <<<<<<<<<<< mismatch" : ""
184+
print("\(n): \(e)\(marker)".yellow(if: isMismatch))
183185
}
184186
}
185187

@@ -188,8 +190,7 @@ func assertOutput(
188190
let printFromLineNo = matchingOutputOffset
189191
for (n, g) in gotLines.enumerated() where n >= printFromLineNo {
190192
let baseLine = "\(n): \(g)"
191-
var line = baseLine
192-
print(line)
193+
print(baseLine)
193194
}
194195
print("==== ---------------------------------------------------------------\n")
195196
}
@@ -241,14 +242,18 @@ func assertOutput(
241242
print("==== ---------------------------------------------------------------")
242243
print("Expected output:")
243244
for (n, e) in expectedLines.enumerated() {
244-
print("\(e)".yellow(if: diffLineNumbers.contains(n)))
245+
let isMismatch = diffLineNumbers.contains(n)
246+
let marker = isMismatch ? " // <<<<<<<< error: mismatch" : ""
247+
print("\(e)\(marker)".yellow(if: isMismatch))
245248
}
246249
}
247250

248251
print("==== ---------------------------------------------------------------")
249252
print("Got output:")
250253
for (n, g) in gotLines.enumerated() {
251-
print("\(g)".red(if: diffLineNumbers.contains(n)))
254+
let isMismatch = diffLineNumbers.contains(n)
255+
let marker = isMismatch ? "// <<<<<<<< error: mismatch" : ""
256+
print("\(g)\(marker)".red(if: isMismatch))
252257
}
253258
print("==== ---------------------------------------------------------------\n")
254259
}

0 commit comments

Comments
 (0)