Skip to content

Commit 7ced180

Browse files
committed
Further pir:: removal in serialization tests.
1 parent 6d196e4 commit 7ced180

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

t/serialization/01-basic.t

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
plan(66);
44

5+
sub add_to_sc($sc, $idx, $obj) {
6+
nqp::scsetobj($sc, $idx, $obj);
7+
nqp::setobjsc($obj, $sc);
8+
}
9+
510
# Serializing an empty SC.
611
{
712
my $sc := nqp::createsc('TEST_SC_1_IN');
@@ -24,7 +29,7 @@ plan(66);
2429

2530
class T1 is repr('P6int') { }
2631
my $v1 := nqp::box_i(42, T1);
27-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v1);
32+
add_to_sc($sc, 0, $v1);
2833

2934
my $serialized := nqp::serialize($sc, $sh);
3035
ok(nqp::chars($serialized) > 36, 'serialized SC with P6int output longer than a header');
@@ -44,7 +49,7 @@ plan(66);
4449

4550
class T2 is repr('P6num') { }
4651
my $v := nqp::box_n(6.9, T2);
47-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
52+
add_to_sc($sc, 0, $v);
4853

4954
my $serialized := nqp::serialize($sc, $sh);
5055
ok(nqp::chars($serialized) > 36, 'serialized SC with P6num output longer than a header');
@@ -64,7 +69,7 @@ plan(66);
6469

6570
class T3 is repr('P6str') { }
6671
my $v := nqp::box_s('dugong', T3);
67-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
72+
add_to_sc($sc, 0, $v);
6873

6974
my $serialized := nqp::serialize($sc, $sh);
7075
ok(nqp::chars($serialized) > 36, 'serialized SC with P6str output longer than a header');
@@ -101,7 +106,7 @@ plan(66);
101106
method c() { $!c }
102107
}
103108
my $v := T4.new();
104-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
109+
add_to_sc($sc, 0, $v);
105110

106111
my $serialized := nqp::serialize($sc, $sh);
107112
ok(nqp::chars($serialized) > 36, 'serialized SC with P6opaque output longer than a header');
@@ -132,8 +137,8 @@ plan(66);
132137
my $v2 := T5.new();
133138
$v1.set_x($v2);
134139
$v2.set_x($v1);
135-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v1);
136-
pir::nqp_add_object_to_sc__vPiP($sc, 1, $v2);
140+
add_to_sc($sc, 0, $v1);
141+
add_to_sc($sc, 1, $v2);
137142

138143
my $serialized := nqp::serialize($sc, $sh);
139144
ok(nqp::chars($serialized) > 36, 'serialized SC with P6opaque output longer than a header');
@@ -174,7 +179,7 @@ plan(66);
174179
$v3.set_v(40);
175180

176181
# Here, we only add *one* of the three explicitly to the SC.
177-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v1);
182+
add_to_sc($sc, 0, $v1);
178183
my $serialized := nqp::serialize($sc, $sh);
179184

180185
my $dsc := nqp::createsc('TEST_SC_7_OUT');
@@ -215,7 +220,7 @@ plan(66);
215220
method c() { $!c }
216221
}
217222
my $v := T7.new();
218-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
223+
add_to_sc($sc, 0, $v);
219224

220225
my $serialized := nqp::serialize($sc, $sh);
221226

@@ -250,7 +255,7 @@ plan(66);
250255
method b() { $!b }
251256
}
252257
my $v := T8.new();
253-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
258+
add_to_sc($sc, 0, $v);
254259

255260
my $serialized := nqp::serialize($sc, $sh);
256261

@@ -291,7 +296,7 @@ plan(66);
291296
method a() { $!a }
292297
}
293298
my $v := T9.new();
294-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
299+
add_to_sc($sc, 0, $v);
295300

296301
my $serialized := nqp::serialize($sc, $sh);
297302

@@ -326,7 +331,7 @@ plan(66);
326331
method a() { $!a }
327332
}
328333
my $v := T10.new();
329-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
334+
add_to_sc($sc, 0, $v);
330335

331336
my $serialized := nqp::serialize($sc, $sh);
332337

@@ -362,7 +367,7 @@ plan(66);
362367
method a() { $!a }
363368
}
364369
my $v := T11.new();
365-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $v);
370+
add_to_sc($sc, 0, $v);
366371

367372
my $serialized := nqp::serialize($sc, $sh);
368373

t/serialization/02-types.t

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ use nqpmo;
44

55
plan(31);
66

7+
sub add_to_sc($sc, $idx, $obj) {
8+
nqp::scsetobj($sc, $idx, $obj);
9+
nqp::setobjsc($obj, $sc);
10+
}
11+
712
# Serializing a knowhow with no attributes and no methods; P6int REPR
813
# (very simple REPR).
914
{
@@ -12,8 +17,8 @@ plan(31);
1217

1318
my $type := pir::get_knowhow__P().new_type(:name('Badger'), :repr('P6int'));
1419
$type.HOW.compose($type);
15-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $type);
16-
pir::nqp_add_object_to_sc__vPiP($sc, 1, nqp::box_i(42, $type));
20+
add_to_sc($sc, 0, $type);
21+
add_to_sc($sc, 1, nqp::box_i(42, $type));
1722

1823
my $serialized := nqp::serialize($sc, $sh);
1924

@@ -37,11 +42,11 @@ plan(31);
3742
my $type := pir::get_knowhow__P().new_type(:name('Dugong'), :repr('P6opaque'));
3843
$type.HOW.add_attribute($type, pir::get_knowhow_attribute__P().new(name => '$!home'));
3944
$type.HOW.compose($type);
40-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $type);
45+
add_to_sc($sc, 0, $type);
4146

4247
my $instance := nqp::create($type);
4348
nqp::bindattr($instance, $type, '$!home', 'Sea');
44-
pir::nqp_add_object_to_sc__vPiP($sc, 1, $instance);
49+
add_to_sc($sc, 1, $instance);
4550

4651
my $serialized := nqp::serialize($sc, $sh);
4752

@@ -68,13 +73,13 @@ plan(31);
6873
$type.HOW.add_attribute($type, NQPAttribute.new(name => '$!weight', type => num));
6974
$type.HOW.add_parent($type, NQPMu);
7075
$type.HOW.compose($type);
71-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $type);
76+
add_to_sc($sc, 0, $type);
7277

7378
my $instance := nqp::create($type);
7479
nqp::bindattr_s($instance, $type, '$!eats', 'mushrooms');
7580
nqp::bindattr_i($instance, $type, '$!age', 5);
7681
nqp::bindattr_n($instance, $type, '$!weight', 2.3);
77-
pir::nqp_add_object_to_sc__vPiP($sc, 1, $instance);
82+
add_to_sc($sc, 1, $instance);
7883

7984
my $serialized := nqp::serialize($sc, $sh);
8085

@@ -125,11 +130,11 @@ plan(31);
125130
$type.HOW.add_method($type, 'intro', $m2);
126131
$type.HOW.add_parent($type, NQPMu);
127132
$type.HOW.compose($type);
128-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $type);
133+
add_to_sc($sc, 0, $type);
129134

130135
my $instance := nqp::create($type);
131136
nqp::bindattr($instance, $type, '$!name', 'Bob');
132-
pir::nqp_add_object_to_sc__vPiP($sc, 1, $instance);
137+
add_to_sc($sc, 1, $instance);
133138

134139
my $serialized := nqp::serialize($sc, $sh);
135140

t/serialization/03-closures.t

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ use nqpmo;
44

55
plan(9);
66

7+
sub add_to_sc($sc, $idx, $obj) {
8+
nqp::scsetobj($sc, $idx, $obj);
9+
nqp::setobjsc($obj, $sc);
10+
}
11+
712
# Serializing a type where some methods are clones; no dependency on outers
813
# just yet.
914
{
@@ -21,7 +26,7 @@ plan(9);
2126
$type.HOW.add_method($type, 'original', $m1);
2227
$type.HOW.add_method($type, 'cloned', $m2);
2328
$type.HOW.compose($type);
24-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $type);
29+
add_to_sc($sc, 0, $type);
2530

2631
my $serialized := nqp::serialize($sc, $sh);
2732

@@ -62,12 +67,12 @@ plan(9);
6267
my $type1 := pir::get_knowhow__P().new_type(:name('RoleLikeTest1'), :repr('P6opaque'));
6368
$type1.HOW.add_method($type1, 'm', $m1);
6469
$type1.HOW.compose($type1);
65-
pir::nqp_add_object_to_sc__vPiP($sc, 0, $type1);
70+
add_to_sc($sc, 0, $type1);
6671

6772
my $type2 := pir::get_knowhow__P().new_type(:name('RoleLikeTest2'), :repr('P6opaque'));
6873
$type2.HOW.add_method($type2, 'm', $m2);
6974
$type2.HOW.compose($type2);
70-
pir::nqp_add_object_to_sc__vPiP($sc, 1, $type2);
75+
add_to_sc($sc, 1, $type2);
7176

7277
my $serialized := nqp::serialize($sc, $sh);
7378

0 commit comments

Comments
 (0)