- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathasync_dynamic.swift
42 lines (34 loc) · 848 Bytes
/
async_dynamic.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -target %target-swift-5.1-abi-triple %s -parse-as-library -module-name main -o %t/main
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s
// REQUIRES: concurrency
// REQUIRES: executable_test
// REQUIRES: concurrency_runtime
// UNSUPPORTED: back_deployment_runtime
publicdynamicfunc number()async->Int{
return100
}
enumSomeError:Error{
case err
}
classC{
dynamicfunc a()asyncthrows->Int?{
return0
}
dynamicfunc b()asyncthrows{
guardlet data =tryawaita()else{
throwSomeError.err
}
}
}
@mainstructMain{
staticfunc main()async{
do{
tryawaitC().b()
}catch _ {assertionFailure("should not throw")}
// CHECK: 100
letvalue=awaitnumber()
print(value)
}
}