Skip to content

Commit 7ed46b1

Browse files
committed
Add a runtime test for ObjC interop.
1 parent 579274b commit 7ed46b1

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <Foundation/Foundation.h>
2+
3+
@interface Butt: NSObject
4+
5+
- (instancetype _Nonnull)init;
6+
7+
- (void)butt:(NSInteger)x completionHandler:(void (^ _Nonnull)(NSInteger))handler;
8+
9+
@end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "objc_async.h"
2+
#include <stdio.h>
3+
4+
@implementation Butt
5+
6+
- (instancetype)init {
7+
return [super init];
8+
}
9+
10+
- (void)butt:(NSInteger)x completionHandler:(void (^)(NSInteger))handler {
11+
printf("starting %ld\n", (long)x);
12+
handler(679);
13+
}
14+
15+
@end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-clang %S/Inputs/objc_async.m -c -o %t/objc_async_objc.o
3+
// RUN: %target-build-swift -Xfrontend -enable-experimental-concurrency %import-libdispatch -import-objc-header %S/Inputs/objc_async.h %s %t/objc_async_objc.o -o %t/objc_async
4+
// RUN: %target-run %t/objc_async | %FileCheck %s
5+
6+
// REQUIRES: executable_test
7+
// REQUIRES: concurrency
8+
// REQUIRES: libdispatch
9+
// REQUIRES: objc_interop
10+
11+
import _Concurrency
12+
13+
let task = Task.runDetached {
14+
let butt = Butt()
15+
let result = await butt.butt(1738)
16+
print("finishing \(result)")
17+
// FIXME: with a proper task runtime, we should exit naturally once all tasks
18+
// complete
19+
exit(0)
20+
}
21+
22+
// FIXME: use the real task runtime facilities
23+
task.run()
24+
25+
dispatchMain()
26+
27+
// CHECK: starting 1738
28+
// CHECK-NEXT: finishing 679

0 commit comments

Comments
 (0)