Skip to content

Commit 861d99f

Browse files
committed
[interop] expand std.pair tests after non-trivial record fix
1 parent 863f987 commit 861d99f

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

test/Interop/Cxx/stdlib/Inputs/std-pair.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44

55
using PairInts = std::pair<int, int>;
66

7-
// FIXME: return pair by value, but it causes IRGen crash atm.
8-
inline const PairInts &getIntPair() {
9-
static PairInts value = { -5, 12 };
7+
inline const PairInts &getIntPairPointer() {
8+
static PairInts value = { 4, 9 };
109
return value;
1110
}
11+
12+
inline PairInts getIntPair() {
13+
return { -5, 12 };
14+
}
15+
16+
struct StructInPair {
17+
int x;
18+
int y;
19+
};
20+
21+
using PairStructInt = std::pair<StructInPair, int>;
22+
23+
inline PairStructInt getPairStructInt(int x) {
24+
return { { x * 2, -x}, x };
25+
}

test/Interop/Cxx/stdlib/use-std-pair.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ import Cxx
1212
var StdPairTestSuite = TestSuite("StdPair")
1313

1414
StdPairTestSuite.test("StdPair.elements") {
15-
var pi = getIntPair().pointee
15+
var pi = getIntPair()
1616
expectEqual(pi.first, -5)
1717
expectEqual(pi.second, 12)
1818
pi.first = 11
1919
expectEqual(pi.first, 11)
2020
expectEqual(pi.second, 12)
2121
}
2222

23+
StdPairTestSuite.test("StdPair.ref.elements") {
24+
let pi = getIntPairPointer().pointee
25+
expectEqual(pi.first, 4)
26+
expectEqual(pi.second, 9)
27+
}
28+
29+
StdPairTestSuite.test("PairStructInt.elements") {
30+
let pair = getPairStructInt(11)
31+
expectEqual(pair.first.x, 22)
32+
expectEqual(pair.first.y, -11)
33+
expectEqual(pair.second, 11)
34+
}
35+
2336
runAllTests()

0 commit comments

Comments
 (0)