Skip to content

Commit 1586ca8

Browse files
committed
add execution test for ObjC-imported effectful properties
1 parent 3041694 commit 1586ca8

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

test/Concurrency/Runtime/Inputs/objc_async.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@
77
- (void)butt:(NSInteger)x completionHandler:(void (^ _Nonnull)(NSInteger))handler;
88

99
@end
10+
11+
@interface Farm: NSObject
12+
13+
-(void)getDogWithCompletion:(void (^ _Nonnull)(NSInteger))completionHandler
14+
__attribute__((swift_async_name("getter:doggo()")));
15+
16+
-(void)obtainCat:(void (^ _Nonnull)(NSInteger, NSError* _Nullable))completionHandler
17+
__attribute__((swift_async_name("getter:catto()")));
18+
19+
@end

test/Concurrency/Runtime/Inputs/objc_async.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,17 @@ - (void)butt:(NSInteger)x completionHandler:(void (^)(NSInteger))handler {
1313
}
1414

1515
@end
16+
17+
@implementation Farm
18+
19+
-(void)getDogWithCompletion:(void (^ _Nonnull)(NSInteger))completionHandler {
20+
printf("getting dog\n");
21+
completionHandler(123);
22+
}
23+
24+
-(void)obtainCat:(void (^ _Nonnull)(NSInteger, NSError* _Nullable))completionHandler {
25+
printf("obtaining cat has failed!\n");
26+
completionHandler(nil, [NSError errorWithDomain:@"obtainCat" code:456 userInfo:nil]);
27+
}
28+
29+
@end

test/Concurrency/Runtime/objc_async.swift

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,35 @@
1010
// rdar://76038845
1111
// UNSUPPORTED: use_os_stdlib
1212

13-
@main struct Main {
14-
static func main() async {
13+
func buttTest() async {
1514
let butt = Butt()
1615
let result = await butt.butt(1738)
1716
print("finishing \(result)")
17+
}
18+
19+
func farmTest() async {
20+
let farm = Farm()
21+
let dogNumber = await farm.doggo
22+
print("dog number = \(dogNumber)")
23+
do {
24+
let _ = try await farm.catto
25+
} catch {
26+
print("caught exception")
1827
}
1928
}
2029

21-
// CHECK: starting 1738
22-
// CHECK-NEXT: finishing 679
30+
@main struct Main {
31+
static func main() async {
32+
// CHECK: starting 1738
33+
// CHECK-NEXT: finishing 679
34+
await buttTest()
35+
36+
// CHECK-NEXT: getting dog
37+
// CHECK-NEXT: dog number = 123
38+
// CHECK-NEXT: obtaining cat has failed!
39+
// CHECK-NEXT: caught exception
40+
await farmTest()
41+
}
42+
}
43+
44+

0 commit comments

Comments
 (0)