Skip to content

Commit 9a8dda4

Browse files
committed
Test nqp::getobjsc/nqp::scgetobjidx.
1 parent 0c8193d commit 9a8dda4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

t/serialization/01-basic.t

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! nqp
22

3-
plan(1482);
3+
plan(1485);
44

55
{
66
my $sc := nqp::createsc('exampleHandle');
@@ -22,6 +22,22 @@ sub add_to_sc($sc, $idx, $obj) {
2222
nqp::setobjsc($obj, $sc);
2323
}
2424

25+
# Test nqp::getobjsc/nqp::scgetobjidx
26+
{
27+
my $sc := nqp::createsc('TEST_SC_0_IN');
28+
class T0 is repr('P6int') { }
29+
my $v1 := nqp::box_i(42, T0);
30+
my $v2 := nqp::box_i(43, T0);
31+
32+
ok(nqp::isnull(nqp::getobjsc($v1)), 'nqp::getobjsc on an object without sc');
33+
34+
add_to_sc($sc, 0, $v1);
35+
add_to_sc($sc, 1, $v2);
36+
37+
ok(nqp::eqaddr(nqp::getobjsc($v1), $sc), 'nqp::getobjsc');
38+
ok(nqp::scgetobjidx($sc, $v2) == 1, 'nqp::scgetobjidx');
39+
}
40+
2541
# Serializing an empty SC.
2642
{
2743
my $sc := nqp::createsc('TEST_SC_1_IN');

0 commit comments

Comments
 (0)