|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -target %target-cpu-apple-macos14 -disable-availability-checking -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o |
| 3 | +// RUN: %target-clang %t/a.o -o %t/a.out %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswift_Concurrency.a -dead_strip |
| 4 | + |
| 5 | +// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt |
| 6 | + |
| 7 | +// RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.out | sort | tee %t/actual-dependencies.txt |
| 8 | + |
| 9 | +// Fail if there is any entry in actual-dependencies.txt that's not in allowed-dependencies.txt |
| 10 | +// RUN: test -z "`comm -13 %t/allowed-dependencies.txt %t/actual-dependencies.txt`" |
| 11 | + |
| 12 | +// DEP: __ZNSt3__111this_thread9sleep_forERKNS_6chrono8durationIxNS_5ratioILl1ELl1000000000EEEEE |
| 13 | +// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKc |
| 14 | +// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6appendEPKcm |
| 15 | +// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6insertEmPKc |
| 16 | +// DEP: __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev |
| 17 | +// DEP: __ZNSt3__16chrono12steady_clock3nowEv |
| 18 | +// DEP: __ZNSt3__19to_stringEj |
| 19 | +// DEP: __ZNSt3__19to_stringEy |
| 20 | +// DEP: __ZdlPv |
| 21 | +// DEP: __Znwm |
| 22 | +// DEP: ___assert_rtn |
| 23 | +// DEP: ___stack_chk_fail |
| 24 | +// DEP: ___stack_chk_guard |
| 25 | +// DEP: ___stderrp |
| 26 | +// DEP: __availability_version_check |
| 27 | +// DEP: _abort |
| 28 | +// DEP: _asl_log |
| 29 | +// DEP: _dispatch_once_f |
| 30 | +// DEP: _dlsym |
| 31 | +// DEP: _exit |
| 32 | +// DEP: _fclose |
| 33 | +// DEP: _fopen |
| 34 | +// DEP: _fprintf |
| 35 | +// DEP: _fread |
| 36 | +// DEP: _free |
| 37 | +// DEP: _fseek |
| 38 | +// DEP: _ftell |
| 39 | +// DEP: _malloc |
| 40 | +// DEP: _memcpy |
| 41 | +// DEP: _memset_s |
| 42 | +// DEP: _os_unfair_lock_lock |
| 43 | +// DEP: _os_unfair_lock_unlock |
| 44 | +// DEP: _posix_memalign |
| 45 | +// DEP: _pthread_equal |
| 46 | +// DEP: _pthread_getspecific |
| 47 | +// DEP: _pthread_self |
| 48 | +// DEP: _pthread_setspecific |
| 49 | +// DEP: _putchar |
| 50 | +// DEP: _rewind |
| 51 | +// DEP: _sscanf |
| 52 | +// DEP: _strlen |
| 53 | +// DEP: _vfprintf |
| 54 | +// DEP: _vsnprintf |
| 55 | +// DEP: _write |
| 56 | +// DEP: dyld_stub_binder |
| 57 | + |
| 58 | +// RUN: %target-run %t/a.out | %FileCheck %s |
| 59 | + |
| 60 | +// REQUIRES: swift_in_compiler |
| 61 | +// REQUIRES: executable_test |
| 62 | +// REQUIRES: optimized_stdlib |
| 63 | +// REQUIRES: OS=macosx |
| 64 | + |
| 65 | +import _Concurrency |
| 66 | + |
| 67 | +public func test() async -> Int { |
| 68 | + print("test") |
| 69 | + let t = Task { |
| 70 | + print("return 42") |
| 71 | + return 42 |
| 72 | + } |
| 73 | + print("await") |
| 74 | + let v = await t.value |
| 75 | + print("return") |
| 76 | + return v |
| 77 | +} |
| 78 | + |
| 79 | +@main |
| 80 | +struct Main { |
| 81 | + static func main() async { |
| 82 | + print("main") |
| 83 | + // CHECK: main |
| 84 | + let t = Task { |
| 85 | + print("task") |
| 86 | + let x = await test() |
| 87 | + print(x == 42 ? "42" : "???") |
| 88 | + } |
| 89 | + print("after task") |
| 90 | + await t.value |
| 91 | + // CHECK-NEXT: after task |
| 92 | + // CHECK-NEXT: task |
| 93 | + // CHECK-NEXT: test |
| 94 | + // CHECK-NEXT: await |
| 95 | + // CHECK-NEXT: return 42 |
| 96 | + // CHECK-NEXT: return |
| 97 | + // CHECK-NEXT: 42 |
| 98 | + } |
| 99 | +} |
0 commit comments