mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
lit.py currently allows any substring of `target_triple` to be used as a feature in REQUIRES/UNSUPPORTED/XFAIL. This results in various forms of the OS spread across the tests and is also somewhat confusing since they aren't actually listed in the available features. Modify all OS-related features to use the `OS=` version that Swift adds instead. We can later remove `config.target_triple` so that these don't the non-OS versions don't work in the first place.
72 lines
1.5 KiB
Swift
72 lines
1.5 KiB
Swift
// RUN: %target-run-simple-swift( -Xfrontend -disable-availability-checking -parse-as-library) | %FileCheck %s --dump-input=always
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: concurrency
|
|
|
|
// rdar://76038845
|
|
// REQUIRES: concurrency_runtime
|
|
// UNSUPPORTED: back_deployment_runtime
|
|
|
|
// UNSUPPORTED: OS=linux-gnu
|
|
|
|
@available(SwiftStdlib 5.1, *)
|
|
func test_taskGroup_is_asyncSequence() async {
|
|
print(#function)
|
|
|
|
let sum = await withTaskGroup(of: Int.self, returning: Int.self) { group in
|
|
for n in 1...10 {
|
|
group.spawn {
|
|
print("add \(n)")
|
|
return n
|
|
}
|
|
}
|
|
|
|
var sum = 0
|
|
for await r in group { // here
|
|
print("next: \(r)")
|
|
sum += r
|
|
}
|
|
|
|
return sum
|
|
}
|
|
|
|
print("result: \(sum)")
|
|
}
|
|
|
|
@available(SwiftStdlib 5.1, *)
|
|
func test_throwingTaskGroup_is_asyncSequence() async throws {
|
|
print(#function)
|
|
|
|
let sum = try await withThrowingTaskGroup(of: Int.self, returning: Int.self) { group in
|
|
for n in 1...10 {
|
|
group.spawn {
|
|
print("add \(n)")
|
|
return n
|
|
}
|
|
}
|
|
|
|
var sum = 0
|
|
for try await r in group { // here
|
|
print("next: \(r)")
|
|
sum += r
|
|
}
|
|
|
|
return sum
|
|
}
|
|
|
|
print("result: \(sum)")
|
|
}
|
|
|
|
@available(SwiftStdlib 5.1, *)
|
|
@main struct Main {
|
|
static func main() async {
|
|
await test_taskGroup_is_asyncSequence()
|
|
// CHECK: test_taskGroup_is_asyncSequence()
|
|
// CHECK: result: 55
|
|
|
|
try! await test_throwingTaskGroup_is_asyncSequence()
|
|
// CHECK: test_throwingTaskGroup_is_asyncSequence()
|
|
// CHECK: result: 55
|
|
}
|
|
}
|