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 4
4
5
5
using PairInts = std::pair<int , int >;
6
6
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 };
10
9
return value;
11
10
}
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
12
12
var StdPairTestSuite = TestSuite ( " StdPair " )
13
13
14
14
StdPairTestSuite . test ( " StdPair.elements " ) {
15
- var pi = getIntPair ( ) . pointee
15
+ var pi = getIntPair ( )
16
16
expectEqual ( pi. first, - 5 )
17
17
expectEqual ( pi. second, 12 )
18
18
pi. first = 11
19
19
expectEqual ( pi. first, 11 )
20
20
expectEqual ( pi. second, 12 )
21
21
}
22
22
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
+
23
36
runAllTests ( )
You can’t perform that action at this time.
0 commit comments