File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend -enable-experimental-feature Embedded -target %target-cpu-apple-macos14 -parse-as-library %s -c -o %t/a.o
3
+ // RUN: %target-clang %t/a.o -o %t/a.out -L%swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos -lswift_Concurrency -lswift_ConcurrencyDefaultExecutor -dead_strip
4
+ // RUN: %target-run %t/a.out | %FileCheck %s
5
+
6
+ // REQUIRES: executable_test
7
+ // REQUIRES: swift_in_compiler
8
+ // REQUIRES: optimized_stdlib
9
+ // REQUIRES: OS=macosx
10
+ // REQUIRES: swift_feature_Embedded
11
+
12
+ import _Concurrency
13
+
14
+ enum MyError : Error {
15
+ case badN( n: Int )
16
+ }
17
+
18
+ func foo( _ n: Int ) async throws ( MyError) -> Int {
19
+ let t = Task {
20
+ return n
21
+ }
22
+
23
+ if n >= 0 { return n }
24
+ else { throw . badN( n: n) }
25
+ }
26
+
27
+ @main struct Main {
28
+ static func main( ) async {
29
+ do {
30
+ let n = try await foo ( 10 )
31
+ print ( n)
32
+ } catch {
33
+ print ( " FAIL " )
34
+ }
35
+ // CHECK-NOT: FAIL
36
+ // CHECK: 10
37
+
38
+ do {
39
+ let n = try await foo ( - 10 )
40
+ print ( " FAIL " )
41
+ } catch {
42
+ guard case . badN( let n) = error else { print ( " FAIL " ) ; return }
43
+ print ( " badN( \( n) ) " )
44
+ }
45
+ // CHECK-NOT: FAIL
46
+ // CHECK: badN(-10)
47
+
48
+ // CHECK-NOT: FAIL
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments