Files
swift-mirror/test/Concurrency/Runtime/task_destruction.swift
Allan Shortlidge c02fc4724d Tests: Remove -disable-availability-checking from many Concurrency tests.
Instead, use the `%target-swift-5.1-abi-triple` substitution to compile the tests
for deployment to the minimum OS versions required for use of _Concurrency APIs.
2024-10-18 16:21:51 -07:00

32 lines
660 B
Swift

// RUN: %target-run-simple-swift(-parse-as-library -target %target-swift-5.1-abi-triple) | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: concurrency
// REQUIRES: concurrency_runtime
// UNSUPPORTED: freestanding
// UNSUPPORTED: back_deployment_runtime
class C {}
@main
enum Main {
static func main() async {
weak var weakRef: C?
do {
let c = C()
let t = Task.detached { return c }
weakRef = c
}
Task.detached {
try await Task.sleep(nanoseconds: 10_000_000_000)
fatalError("Fail!")
}
while weakRef != nil {
await Task.yield()
}
// CHECK: Success
print("Success!")
}
}