Skip to content

Commit 661f368

Browse files
authoredAug 5, 2024
Merge pull request #75620 from tbkka/tbkka-remotemirror-checkedcontinuation
Basic test for RemoteMirror reflecting checked continuations

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_CheckedContinuation
3+
// RUN: %target-codesign %t/reflect_CheckedContinuation
4+
5+
// RUN: %target-run %target-swift-reflection-test %t/reflect_CheckedContinuation | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
6+
7+
// REQUIRES: reflection_test_support
8+
// REQUIRES: executable_test
9+
// UNSUPPORTED: use_os_stdlib
10+
// UNSUPPORTED: ASAN
11+
// UNSUPPORTED: back_deployment_runtime
12+
13+
import SwiftReflectionTest
14+
15+
struct MyValue {
16+
let u: UInt
17+
}
18+
19+
struct MyError: Error {
20+
let i: Int
21+
}
22+
23+
@available(SwiftStdlib 5.1, *)
24+
class MyClass {
25+
let cont: CheckedContinuation<MyValue, any Error>
26+
27+
init(cont: CheckedContinuation<MyValue, any Error>) {
28+
self.cont = cont
29+
}
30+
}
31+
32+
if #available(SwiftStdlib 5.1, *) {
33+
_ = try await withCheckedThrowingContinuation { checkedContinuation in
34+
let myClass = MyClass(cont: checkedContinuation)
35+
reflect(object: myClass)
36+
checkedContinuation.resume(returning: MyValue(u: 1))
37+
}
38+
}
39+
40+
// CHECK: Reflecting an object.
41+
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
42+
// CHECK-NEXT: Type reference:
43+
// CHECK-NEXT: (class reflect_CheckedContinuation.MyClass)
44+
45+
// CHECK-64: Type info:
46+
// CHECK-64-NEXT: (class_instance size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
47+
// CHECK-64-NEXT: (field name=cont offset=16
48+
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=2147483647 bitwise_takable=1
49+
// CHECK-64-NEXT: (field name=canary offset=0
50+
// CHECK-64-NEXT: (reference kind=strong refcounting=native)))))
51+
52+
// TODO: 32-bit layout
53+
54+
doneReflecting()
55+
56+
// CHECK-64: Done.
57+
58+
// CHECK-32: Done.

0 commit comments

Comments
 (0)
Please sign in to comment.