Files
swift-mirror/test/Concurrency/Runtime/task_destruction.swift
Kuba (Brecka) Mracek 7853184ed6 Enable running tests from test/Concurrency/ directory in freestanding/minimal presets (#61835)
* Enable running tests from test/Concurrency/ directory in freestanding/minimal presets

* Mark failing Concurrency tests as XFAIL/SKIP on freestanding/minimal
2022-11-04 09:07:27 -07:00

32 lines
665 B
Swift

// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -disable-availability-checking) | %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!")
}
}