Skip to content

Commit 48ddcdc

Browse files
authored
[TaskGroup] add simple test to group asynciterator test
Simple additional test, not because it's unexpected but to document what we're expecting.
1 parent 623e54f commit 48ddcdc

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/Concurrency/Runtime/async_taskgroup_asynciterator_semantics.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,49 @@ 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)")
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)")
135+
136+
for n in 8...10 {
137+
group.spawn {
138+
return n
139+
}
140+
}
141+
142+
let nine = await group.contains(9)
143+
print("nine = \(nine)")
144+
145+
return 0
146+
}
147+
148+
// CHECK: result with async iterator: 0
149+
print("result with async iterator: \(sum)")
150+
}
151+
115152
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
116153
@main struct Main {
117154
static func main() async {
118155
await test_taskGroup_next()
119156
await test_taskGroup_for_in()
120157
await test_taskGroup_asyncIterator()
158+
await test_taskGroup_contains()
121159
}
122160
}

0 commit comments

Comments
 (0)