diff --git a/Sources/Testing/Issues/Issue.swift b/Sources/Testing/Issues/Issue.swift index 9f9029459..44943d1b3 100644 --- a/Sources/Testing/Issues/Issue.swift +++ b/Sources/Testing/Issues/Issue.swift @@ -204,7 +204,7 @@ extension Issue.Kind: CustomStringConvertible { // bound." That's sufficient for us to determine if the range contains // a single value. let upperBound = expected.first { $0 > lowerBound } - if let upperBound, upperBound > lowerBound && lowerBound == upperBound - 1 { + if upperBound == nil { return "Confirmation was confirmed \(actual.counting("time")), but expected to be confirmed \(lowerBound.counting("time"))" } } diff --git a/Tests/TestingTests/ConfirmationTests.swift b/Tests/TestingTests/ConfirmationTests.swift index 8e4a9b8a7..5502cb8d2 100644 --- a/Tests/TestingTests/ConfirmationTests.swift +++ b/Tests/TestingTests/ConfirmationTests.swift @@ -51,12 +51,36 @@ struct ConfirmationTests { var configuration = Configuration() configuration.eventHandler = { event, _ in if case let .issueRecorded(issue) = event.kind { - #expect(String(describing: issue) != "") + #expect(String(describing: issue).contains("time(s)")) } } await Test { await confirmation(expectedCount: 1...) { _ in } + await confirmation(expectedCount: 1...2) { _ in } + await confirmation(expectedCount: 1..<3) { _ in } + }.run(configuration: configuration) + } + + @Test func confirmationFailureCanBeDescribedAsSingleValue() async { + var configuration = Configuration() + configuration.eventHandler = { event, _ in + if case let .issueRecorded(issue) = event.kind { + #expect(!String(describing: issue).contains("time(s)")) + } + } + + await Test { + await confirmation(expectedCount: 1...1) { _ in } + await confirmation(expectedCount: 1..<2) { _ in } + await confirmation(expectedCount: Int.max...Int.max) { _ in } +#if !SWT_NO_EXIT_TESTS + await withKnownIssue("Crashes in Swift standard library (rdar://139568287)") { + await #expect(exitsWith: .success) { + await confirmation(expectedCount: Int.max...) { _ in } + } + } +#endif }.run(configuration: configuration) }