From 8c0ceaff565108c8390b300c7ae35296caeeefef Mon Sep 17 00:00:00 2001 From: Iceman Date: Mon, 2 Feb 2026 17:50:32 +0900 Subject: [PATCH 1/2] improve readability of assertion --- .../Asserts/TextAssertions.swift | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift b/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift index 301524bbb..9e225a24a 100644 --- a/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift +++ b/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift @@ -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 `output.contains(expectedChunk)` = output.contains(expectedChunk) + #expect(`output.contains(expectedChunk)`, """ + \("error: Output did not contain expected chunk!".red) + ==== Expected output ----------------------------------------------- + \(expectedChunk.yellow) + ==== Got output ---------------------------------------------------- + \(output) + ==== --------------------------------------------------------------- + """, sourceLocation: sourceLocation) continue } @@ -183,8 +181,7 @@ 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" : "" @@ -192,8 +189,7 @@ func assertOutput( } } - print("==== ---------------------------------------------------------------") - print("Got output:") + print("==== Got output ----------------------------------------------------") let printFromLineNo = matchingOutputOffset for (n, g) in gotLines.enumerated() where n >= printFromLineNo { let baseLine = "\(n): \(g)" @@ -246,8 +242,7 @@ 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" : "" @@ -255,8 +250,7 @@ func assertOutput( } } - print("==== ---------------------------------------------------------------") - print("Got output:") + print("==== Got output ----------------------------------------------------") for (n, g) in gotLines.enumerated() { let isMismatch = diffLineNumbers.contains(n) let marker = isMismatch ? "// <<<<<<<< error: mismatch" : "" From 368dcaf20596eeb8f49f205b8ec3d7174f0a5048 Mon Sep 17 00:00:00 2001 From: Iceman Date: Thu, 5 Feb 2026 15:16:44 +0900 Subject: [PATCH 2/2] Follow swift 6.1.3 --- Tests/JExtractSwiftTests/Asserts/TextAssertions.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift b/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift index 9e225a24a..c6d05bfc3 100644 --- a/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift +++ b/Tests/JExtractSwiftTests/Asserts/TextAssertions.swift @@ -110,8 +110,8 @@ func assertOutput( var diffLineNumbers: [Int] = [] guard let matchingOutputOffset else { - let `output.contains(expectedChunk)` = output.contains(expectedChunk) - #expect(`output.contains(expectedChunk)`, """ + let outputContainsExpectedChunk = output.contains(expectedChunk) + #expect(outputContainsExpectedChunk, """ \("error: Output did not contain expected chunk!".red) ==== Expected output ----------------------------------------------- \(expectedChunk.yellow)