|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency -parse-stdlib -parse-as-library -lswiftSwiftReflectionTest %s -o %t/reflect_task |
| 3 | +// RUN: %target-codesign %t/reflect_task |
| 4 | + |
| 5 | +// RUN: %target-run %target-swift-reflection-test %t/reflect_task | %FileCheck %s --dump-input=fail |
| 6 | + |
| 7 | +// REQUIRES: reflection_test_support |
| 8 | +// REQUIRES: executable_test |
| 9 | +// REQUIRES: concurrency |
| 10 | +// UNSUPPORTED: use_os_stdlib |
| 11 | + |
| 12 | +import Swift |
| 13 | +import _Concurrency |
| 14 | + |
| 15 | +import SwiftReflectionTest |
| 16 | + |
| 17 | +@_silgen_name("swift_task_getCurrent") |
| 18 | +func _getCurrentAsyncTask() -> UInt |
| 19 | + |
| 20 | +func add(_ a: UInt, _ b: UInt) async -> UInt { |
| 21 | + if b == 0 { |
| 22 | + reflect(asyncTask: _getCurrentAsyncTask()) |
| 23 | + // CHECK: Reflecting an async task. |
| 24 | + // CHECK: Async task {{0x[0-9a-fA-F]*}} |
| 25 | + |
| 26 | + // The actual number of chunks we'll get depends on internal implementation |
| 27 | + // details that we don't want this test to depend on. We'll just make sure |
| 28 | + // we get at least two, and ignore the details. |
| 29 | + // CHECK: Allocation block {{0x[0-9a-fA-F]*}} |
| 30 | + // CHECK: Chunk at {{0x[0-9a-fA-F]*}} length {{[0-9]*}} kind {{[0-9]*}} |
| 31 | + // CHECK: Allocation block {{0x[0-9a-fA-F]*}} |
| 32 | + // CHECK: Chunk at {{0x[0-9a-fA-F]*}} length {{[0-9]*}} kind {{[0-9]*}} |
| 33 | + return a |
| 34 | + } else { |
| 35 | + return await add(a, b - 1) + 1 |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +@main struct Main { |
| 40 | + static func main() async { |
| 41 | + let n = await add(100, 100) |
| 42 | + reflect(any: n) |
| 43 | + |
| 44 | + doneReflecting() |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +// CHECK: Done. |
0 commit comments