|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: cp %s %t/main.swift |
| 3 | +// RUN: %target-build-swift -whole-module-optimization -module-name PlaygroundSupport -emit-module-path %t/PlaygroundSupport.swiftmodule -parse-as-library -c -o %t/PlaygroundSupport.o %S/Inputs/SilentPCMacroRuntime.swift %S/Inputs/PlaygroundsRuntime.swift |
| 4 | +// RUN: %target-build-swift -Xfrontend -disable-availability-checking -Xfrontend -playground -o %t/main -I=%t %t/PlaygroundSupport.o %t/main.swift |
| 5 | +// RUN: %target-codesign %t/main |
| 6 | +// RUN: %target-run %t/main | %FileCheck %s |
| 7 | +// RUN: %target-build-swift -Xfrontend -disable-availability-checking -Xfrontend -pc-macro -Xfrontend -playground -o %t/main2 -I=%t %t/PlaygroundSupport.o %t/main.swift |
| 8 | +// RUN: %target-codesign %t/main2 |
| 9 | +// RUN: %target-run %t/main2 | %FileCheck %s |
| 10 | + |
| 11 | +// REQUIRES: executable_test |
| 12 | +// REQUIRES: concurrency |
| 13 | + |
| 14 | +// rdar://76038845 |
| 15 | +// REQUIRES: concurrency_runtime |
| 16 | +// UNSUPPORTED: back_deployment_runtime |
| 17 | + |
| 18 | +import PlaygroundSupport |
| 19 | + |
| 20 | +func factorial(_ x : Int) async -> Int { |
| 21 | + if x < 1 { |
| 22 | + return 1 |
| 23 | + } |
| 24 | + return await x * factorial(x - 1) |
| 25 | +} |
| 26 | + |
| 27 | +async let fac4 = factorial(4) |
| 28 | +print(await fac4) |
| 29 | + |
| 30 | +// return await x * factorial(x - 1) |
| 31 | +// CHECK: [22:{{[[:digit:]]+}}-22:{{[[:digit:]]+}}] __builtin_log[='1'] |
| 32 | + |
| 33 | +// return await x * factorial(x - 1) |
| 34 | +// CHECK: [24:{{[[:digit:]]+}}-24:{{[[:digit:]]+}}] __builtin_log[='1'] |
| 35 | + |
| 36 | +// return await x * factorial(x - 1) |
| 37 | +// CHECK: [24:{{[[:digit:]]+}}-24:{{[[:digit:]]+}}] __builtin_log[='2'] |
| 38 | + |
| 39 | +// return await x * factorial(x - 1) |
| 40 | +// CHECK: [24:{{[[:digit:]]+}}-24:{{[[:digit:]]+}}] __builtin_log[='6'] |
| 41 | + |
| 42 | +// return await x * factorial(x - 1) |
| 43 | +// CHECK: [24:{{[[:digit:]]+}}-24:{{[[:digit:]]+}}] __builtin_log[='24'] |
| 44 | + |
| 45 | +// func factorial(_ x : Int) { ... } |
| 46 | +// CHECK-NEXT: [20:{{[[:digit:]]+}}-25:{{[[:digit:]]+}}] __builtin_log_scope_exit |
| 47 | + |
| 48 | +// (actually print the thing) |
| 49 | +// CHECK-NEXT: 24 |
| 50 | + |
| 51 | +// print(await fac4) |
| 52 | +// CHECK-NEXT: [28:{{[[:digit:]]+}}-28:{{[[:digit:]]+}}] __builtin_postPrint |
0 commit comments