Skip to content

Commit 95edef7

Browse files
committed
[Concurrency] Add an async call into our async task for basic futures test.
Extend the basic futures test to include a call to an async function so that we exercise coroutine splitting.
1 parent a1284d0 commit 95edef7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/Concurrency/Runtime/basic_future.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ extension DispatchQueue {
1616
}
1717
}
1818

19+
func formGreeting(name: String) async -> String {
20+
return "Hello \(name) from async world"
21+
}
22+
1923
func test(name: String) {
2024
let taskHandle = DispatchQueue.main.async { () async -> String in
21-
return "Hello \(name) from async world"
25+
let greeting = await formGreeting(name: name)
26+
return greeting + "!"
2227
}
2328

2429
_ = DispatchQueue.main.async { () async in
@@ -28,7 +33,7 @@ func test(name: String) {
2833
let result = await try! taskHandle.get()
2934
// CHECK: Hello Ted from async world
3035
print(result)
31-
assert(result == "Hello Ted from async world")
36+
assert(result == "Hello Ted from async world!")
3237
exit(0)
3338
}
3439

0 commit comments

Comments
 (0)