Skip to content

Add an end-to-end test fo function arguments in an async function. #2234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lldb/test/API/lang/swift/async/async_fnargs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS := -Xfrontend -enable-experimental-concurrency
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil
import unittest2


class TestSwiftAsyncFnArgs(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@swiftTest
def test(self):
"""Test function arguments in async functions"""
self.build()
src = lldb.SBFileSpec('main.swift')
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, 'Set breakpoint here', src)

self.expect("frame var -d run-target -- msg", '"world"')

# Continue into the second coroutine funclet.
bkpt2 = target.BreakpointCreateBySourceRegex("And also here", src, None)
self.assertGreater(bkpt2.GetNumLocations(), 0)
process.Continue()
self.assertEqual(
len(lldbutil.get_threads_stopped_at_breakpoint(process, bkpt2)), 1)

self.expect("frame var -d run-target -- msg", '"world"')
17 changes: 17 additions & 0 deletions lldb/test/API/lang/swift/async/async_fnargs/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Swift
func use<T>(_ t: T) {}

func sayHello() async {
print("hello")
}

func sayGeneric<T>(_ msg: T) async {
print("Set breakpoint here")
await sayHello()
print(msg) // And also here.
}

runAsyncAndBlock {
await sayHello()
await sayGeneric("world")
}