Skip to content

Commit 93b6e1b

Browse files
committed
[interop][SwiftToCxx] NFC, add test coverage for resilient mutating method
1 parent bb7ba7c commit 93b6e1b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

test/Interop/SwiftToCxx/structs/resilient-struct-in-cxx-execution.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ int main() {
4040
// CHECK: find - small dump
4141
// CURRENT-NEXT: x = 66
4242
// CHANGE-NEXT: x&y = 0&65
43+
copySmallStruct.mutate();
44+
copySmallStruct.dump();
45+
// CHECK: find - small dump
46+
// CURRENT-NEXT: x = 132
47+
// CHANGE-NEXT: x&y = 0&4294967230
4348

4449
printSmallAndLarge(smallStruct, largeStruct);
4550
// CHECK: find - small dump

test/Interop/SwiftToCxx/structs/resilient-struct-in-cxx.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ public struct FirstSmallStruct {
1616
print("x&y = \(x)&\(y)")
1717
#else
1818
print("x = \(x)")
19+
#endif
20+
}
21+
22+
public mutating func mutate() {
23+
x = x * 2
24+
#if CHANGE_LAYOUT
25+
y = ~y
1926
#endif
2027
}
2128
}
@@ -61,6 +68,9 @@ public struct FirstSmallStruct {
6168
// CHECK-NEXT: inline void FirstSmallStruct::dump() const {
6269
// CHECK-NEXT: return _impl::$s7Structs16FirstSmallStructV4dumpyyF(_getOpaquePointer());
6370
// CHECK-NEXT: }
71+
// CHECK-NEXT: inline void FirstSmallStruct::mutate() {
72+
// CHECK-NEXT: return _impl::$s7Structs16FirstSmallStructV6mutateyyF(_getOpaquePointer());
73+
// CHECK-NEXT: }
6474

6575
@frozen public struct FrozenStruct {
6676
private let storedInt: Int32

0 commit comments

Comments
 (0)