Skip to content
Merged
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
32 changes: 13 additions & 19 deletions Tests/JExtractSwiftTests/Asserts/TextAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,15 @@ func assertOutput(

var diffLineNumbers: [Int] = []
guard let matchingOutputOffset else {
print("error: Output did not contain expected chunk!".red)

print("==== ---------------------------------------------------------------")
print("Expected output:")
print("'\(expectedChunk.yellow)'")
print("==== ---------------------------------------------------------------")
print("Got output:")
print(output)
print("==== ---------------------------------------------------------------")

#expect(output.contains(expectedChunk), sourceLocation: sourceLocation)
let outputContainsExpectedChunk = output.contains(expectedChunk)
#expect(outputContainsExpectedChunk, """
\("error: Output did not contain expected chunk!".red)
==== Expected output -----------------------------------------------
\(expectedChunk.yellow)
==== Got output ----------------------------------------------------
\(output)
==== ---------------------------------------------------------------
""", sourceLocation: sourceLocation)
continue
}

Expand Down Expand Up @@ -183,17 +181,15 @@ func assertOutput(
if hasDiff {
print("error: Number of not matching lines: \(diffLineNumbers.count)!".red)

print("==== ---------------------------------------------------------------")
print("Expected output:")
print("==== Expected output -----------------------------------------------")
for (n, e) in expectedLines.enumerated() {
let isMismatch = diffLineNumbers.map({$0 - matchingOutputOffset}).contains(n)
let marker = isMismatch ? " // <<<<<<<<<<< mismatch" : ""
print("\(n): \(e)\(marker)".yellow(if: isMismatch))
}
}

print("==== ---------------------------------------------------------------")
print("Got output:")
print("==== Got output ----------------------------------------------------")
let printFromLineNo = matchingOutputOffset
for (n, g) in gotLines.enumerated() where n >= printFromLineNo {
let baseLine = "\(n): \(g)"
Expand Down Expand Up @@ -246,17 +242,15 @@ func assertOutput(
if hasDiff {
print("error: Number of not matching lines: \(diffLineNumbers.count)!".red)

print("==== ---------------------------------------------------------------")
print("Expected output:")
print("==== Expected output -----------------------------------------------")
for (n, e) in expectedLines.enumerated() {
let isMismatch = diffLineNumbers.contains(n)
let marker = isMismatch ? " // <<<<<<<< error: mismatch" : ""
print("\(e)\(marker)".yellow(if: isMismatch))
}
}

print("==== ---------------------------------------------------------------")
print("Got output:")
print("==== Got output ----------------------------------------------------")
for (n, g) in gotLines.enumerated() {
let isMismatch = diffLineNumbers.contains(n)
let marker = isMismatch ? "// <<<<<<<< error: mismatch" : ""
Expand Down
Loading