Skip to content

Commit 1e63681

Browse files
authored
Merge pull request #37021 from apple/ktoso-patch-3
2 parents 3c61374 + ff2b2ce commit 1e63681

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/Concurrency/Runtime/async_taskgroup_asynciterator_semantics.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,44 @@ func test_taskGroup_asyncIterator() async {
112112
print("result with async iterator: \(sum)")
113113
}
114114

115+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
116+
func test_taskGroup_contains() async {
117+
let sum = await withTaskGroup(of: Int.self, returning: Int.self) { group in
118+
for n in 1...4 {
119+
group.spawn {
120+
return n
121+
}
122+
}
123+
124+
let three = await group.contains(3)
125+
print("three = \(three)") // CHECK: three = true
126+
127+
for n in 5...7 {
128+
group.spawn {
129+
return n
130+
}
131+
}
132+
133+
let six = await group.contains(6)
134+
print("six = \(six)") // CHECK: six = true
135+
136+
137+
let sixAgain = await group.contains(6)
138+
print("six again = \(sixAgain)") // CHECK: six again = false
139+
140+
return 0
141+
}
142+
143+
// CHECK: result with async iterator: 0
144+
print("result with async iterator: \(sum)")
145+
}
146+
115147
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
116148
@main struct Main {
117149
static func main() async {
118150
await test_taskGroup_next()
119151
await test_taskGroup_for_in()
120152
await test_taskGroup_asyncIterator()
153+
await test_taskGroup_contains()
121154
}
122155
}

0 commit comments

Comments
 (0)