diff --git a/Tests/TaggedNodeCorpusRoundTripTests.swift b/Tests/TaggedNodeCorpusRoundTripTests.swift index 3fdcef5..2f571f3 100644 --- a/Tests/TaggedNodeCorpusRoundTripTests.swift +++ b/Tests/TaggedNodeCorpusRoundTripTests.swift @@ -19,14 +19,12 @@ struct TaggedNodeCorpusRoundTripTests { )) var accepted = 0 var rejected = 0 - /// `URL.lastPathComponent` is `String` on Darwin's Foundation but `String?` on this - /// toolchain's swift-corelibs-foundation; the explicit `as String?` upcast/coercion makes - /// both platforms produce a uniform `String?` here so `?? ""` compiles identically either - /// way, rather than picking one platform's non-optional type and breaking the other. - func name(_ url: URL) -> String { - (url.lastPathComponent as String?) ?? "" - } - for url in urls.sorted(by: { name($0) < name($1) }) { + // `URL.lastPathComponent` is `String` on Darwin's Foundation but `String?` on this + // toolchain's swift-corelibs-foundation. Left deliberately untyped (no explicit `URL` + // parameter anywhere below) since a fixed `Bundle.module.urls(...)` result element type + // also varies across those two Foundations; the `as String?` coercion after the property + // access, not before, is what stays valid on both. + for url in urls.sorted(by: { ($0.lastPathComponent as String? ?? "") < ($1.lastPathComponent as String? ?? "") }) { let source = try String(contentsOf: url, encoding: .utf8) let parsed: PureYAML.Tagged.Node do { @@ -41,11 +39,11 @@ struct TaggedNodeCorpusRoundTripTests { do { reparsed = try PureYAML.parseTagged(dumped) } catch { - Issue.record("\(name(url)): dump produced unparseable YAML: \(error)") + Issue.record("\(url.lastPathComponent as String? ?? ""): dump produced unparseable YAML: \(error)") continue } if let detail = firstDivergence(parsed, reparsed, path: "$") { - Issue.record("\(name(url)): \(detail)") + Issue.record("\(url.lastPathComponent as String? ?? ""): \(detail)") } } #expect(accepted > 0)