mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Defines the %target-playground-build-run-swift macro in the local lit config for PlaygroundTransform which contains all the boilerplate code used by most PlaygroundTransform tests: * Build a PlaygroundSupport module * Build the test source into an executable, linking PlaygroundSupport * Codesign and run the executable
51 lines
1.9 KiB
Swift
51 lines
1.9 KiB
Swift
// -playground
|
|
// RUN: %target-playground-build-run-swift(-swift-version 5 -Xfrontend -disable-availability-checking -Xfrontend -playground) | %FileCheck %s
|
|
// RUN: %target-playground-build-run-swift(-swift-version 6 -Xfrontend -disable-availability-checking -Xfrontend -playground) | %FileCheck %s
|
|
//
|
|
// -pc-macro -playground
|
|
// RUN: %target-playground-build-run-swift(-swift-version 5 -Xfrontend -disable-availability-checking -Xfrontend -pc-macro -Xfrontend -playground) | %FileCheck %s
|
|
// RUN: %target-playground-build-run-swift(-swift-version 6 -Xfrontend -disable-availability-checking -Xfrontend -pc-macro -Xfrontend -playground) | %FileCheck %s
|
|
//
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: concurrency
|
|
//
|
|
// rdar://76038845
|
|
// REQUIRES: concurrency_runtime
|
|
// UNSUPPORTED: back_deployment_runtime
|
|
|
|
import PlaygroundSupport
|
|
|
|
func factorial(_ x : Int) async -> Int {
|
|
if x < 1 {
|
|
return 1
|
|
}
|
|
return await x * factorial(x - 1)
|
|
}
|
|
|
|
async let fac4 = factorial(4)
|
|
print(await fac4)
|
|
|
|
// return await x * factorial(x - 1)
|
|
// CHECK: [20:{{[[:digit:]]+}}-20:{{[[:digit:]]+}}] __builtin_log[='1']
|
|
|
|
// return await x * factorial(x - 1)
|
|
// CHECK: [22:{{[[:digit:]]+}}-22:{{[[:digit:]]+}}] __builtin_log[='1']
|
|
|
|
// return await x * factorial(x - 1)
|
|
// CHECK: [22:{{[[:digit:]]+}}-22:{{[[:digit:]]+}}] __builtin_log[='2']
|
|
|
|
// return await x * factorial(x - 1)
|
|
// CHECK: [22:{{[[:digit:]]+}}-22:{{[[:digit:]]+}}] __builtin_log[='6']
|
|
|
|
// return await x * factorial(x - 1)
|
|
// CHECK: [22:{{[[:digit:]]+}}-22:{{[[:digit:]]+}}] __builtin_log[='24']
|
|
|
|
// func factorial(_ x : Int) { ... }
|
|
// CHECK-NEXT: [18:{{[[:digit:]]+}}-23:{{[[:digit:]]+}}] __builtin_log_scope_exit
|
|
|
|
// (actually print the thing)
|
|
// CHECK-NEXT: 24
|
|
|
|
// print(await fac4)
|
|
// CHECK-NEXT: [26:{{[[:digit:]]+}}-26:{{[[:digit:]]+}}] __builtin_postPrint
|