Skip to content

Remove Test.underestimatedCaseCount SPI #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
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
26 changes: 0 additions & 26 deletions Sources/Testing/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,6 @@ public struct Test: Sendable {
/// The source location of this test.
public var sourceLocation: SourceLocation

/// The (underestimated) number of iterations that will need to occur during
/// testing.
///
/// The value of this property is inherently capped at `Int.max`. In practice,
/// the number of iterations that can run in a reasonable timespan will be
/// significantly lower.
///
/// For instances of ``Test`` that represent non-parameterized test functions
/// (that is, test functions that do not iterate over a sequence of inputs),
/// the value of this property is always `1`. For instances of ``Test`` that
/// represent test suite types, the value of this property is always `nil`.
///
/// For more information about underestimated counts, see the documentation
/// for [`Sequence`](https://developer.apple.com/documentation/swift/array/underestimatedcount-4ggqp).
@_spi(ExperimentalParameterizedTesting)
public var underestimatedCaseCount: Int? {
// NOTE: it is important that we only expose an _underestimated_ count for
// two reasons:
// 1. If the total number of cases exceeds `.max` due to combinatoric
// complexity, `count` would be too low; and
// 2. We reserve the right to support async sequences as input in the
// future, and async sequences do not have `count` properties (but an
// underestimated count of `0` is still technically correct.)
testCases?.underestimatedCount
}

/// The type containing this test, if any.
///
/// If a test is associated with a free function or static function, the value
Expand Down
35 changes: 0 additions & 35 deletions Tests/TestingTests/MiscellaneousTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,41 +309,6 @@ struct MiscellaneousTests {
await valueGrid.validateCells()
}

@Test("Test.underestimatedCaseCount property")
func underestimatedCaseCount() async throws {
do {
let test = try #require(await testFunction(named: "parameterized(i:)", in: NonSendableTests.self))
#expect(test.underestimatedCaseCount == FixtureData.zeroUpTo100.count)
}
do {
let test = try #require(await testFunction(named: "parameterized2(i:j:)", in: NonSendableTests.self))
#expect(test.underestimatedCaseCount == FixtureData.zeroUpTo100.count * FixtureData.smallStringArray.count)
}
do {
let test = try #require(await testFunction(named: "parameterized(i:)", in: SendableTests.self))
#expect(test.underestimatedCaseCount == FixtureData.zeroUpTo100.count)
}
#if !SWT_NO_GLOBAL_ACTORS
do {
let test = try #require(await testFunction(named: "parameterized(i:)", in: MainActorIsolatedTests.self))
#expect(test.underestimatedCaseCount == FixtureData.zeroUpTo100.count)
}
do {
let test = try #require(await testFunction(named: "parameterizedNonisolated(i:)", in: MainActorIsolatedTests.self))
#expect(test.underestimatedCaseCount == FixtureData.zeroUpTo100.count)
}
#endif

do {
let thisTest = try #require(await testFunction(named: "succeeds()", in: SendableTests.self))
#expect(thisTest.underestimatedCaseCount == 1)
}
do {
let thisTest = try #require(await test(for: SendableTests.self))
#expect(thisTest.underestimatedCaseCount == nil)
}
}

@Test("Test.parameters property")
func parametersProperty() async throws {
do {
Expand Down