Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 117fc5b

Browse files
Merge pull request swiftlang#2233 from adrian-prantl/71866936-test
Add an end-to-end test fo function arguments in an async function.
2 parents 41f316f + f302f0c commit 117fc5b

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS := -Xfrontend -enable-experimental-concurrency
3+
include Makefile.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import unittest2
6+
7+
8+
class TestSwiftAsyncFnArgs(lldbtest.TestBase):
9+
10+
mydir = lldbtest.TestBase.compute_mydir(__file__)
11+
12+
@swiftTest
13+
def test(self):
14+
"""Test function arguments in async functions"""
15+
self.build()
16+
src = lldb.SBFileSpec('main.swift')
17+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
18+
self, 'Set breakpoint here', src)
19+
20+
self.expect("frame var -d run-target -- msg", '"world"')
21+
22+
# Continue into the second coroutine funclet.
23+
bkpt2 = target.BreakpointCreateBySourceRegex("And also here", src, None)
24+
self.assertGreater(bkpt2.GetNumLocations(), 0)
25+
process.Continue()
26+
self.assertEqual(
27+
len(lldbutil.get_threads_stopped_at_breakpoint(process, bkpt2)), 1)
28+
29+
self.expect("frame var -d run-target -- msg", '"world"')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Swift
2+
func use<T>(_ t: T) {}
3+
4+
func sayHello() async {
5+
print("hello")
6+
}
7+
8+
func sayGeneric<T>(_ msg: T) async {
9+
print("Set breakpoint here")
10+
await sayHello()
11+
print(msg) // And also here.
12+
}
13+
14+
runAsyncAndBlock {
15+
await sayHello()
16+
await sayGeneric("world")
17+
}

0 commit comments

Comments
 (0)