File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 44
55using 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+ }
Original file line number Diff line number Diff line change @@ -12,12 +12,25 @@ import Cxx
1212var StdPairTestSuite = TestSuite ( " StdPair " )
1313
1414StdPairTestSuite . 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+
2336runAllTests ( )
You can’t perform that action at this time.
0 commit comments