import XCTest
final class AsyncSetUpTranspilerReproTests: XCTestCase {
private var valueFromAsyncSetUp: String!
override func setUp() async throws {
try await super.setUp()
valueFromAsyncSetUp = try await Self.sleepThenReturnExpectedString()
}
private static func sleepThenReturnExpectedString() async throws -> String {
try await Task.sleep(nanoseconds: 10_000_000)
return "expected-after-sleep"
}
func testAsyncSetUpStoresExpectedString() throws {
XCTAssertEqual(valueFromAsyncSetUp, "expected-after-sleep")
}
}
This test passes in native Swift, but, after transpilation, it fails to compile.
e: file:///private/tmp/tp/lib-project/.build/plugins/outputs/lib-project/ModuleNameTests/destination/skipstone/ModuleName/src/test/kotlin/module/name/AsyncSetUpTranspilerReproTests.kt:11:26 Suspend function 'setUp' cannot override non-suspend function 'fun setUp(): Unit' defined in 'skip.unit.XCTestCase'.
The setUp() function transpiles to this:
override suspend fun setUp(): Unit = Async.run {
super.setUp()
valueFromAsyncSetUp = Companion.sleepThenReturnExpectedString()
}
This test passes in native Swift, but, after transpilation, it fails to compile.
The
setUp()function transpiles to this: