Skip to content

Commit ac38b5f

Browse files
committed
Test serializing the hll role.
1 parent 70a863d commit ac38b5f

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

t/serialization/02-types.t

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use nqpmo;
44

5-
plan(48);
5+
plan(49);
66

77
sub add_to_sc($sc, $idx, $obj) {
88
nqp::scsetobj($sc, $idx, $obj);
@@ -432,3 +432,36 @@ sub add_to_sc($sc, $idx, $obj) {
432432
ok(nqp::eqaddr(nqp::hllizefor($obj, "foo"), $obj), "correct hll prevents convertion");
433433
ok(nqp::eqaddr(nqp::hllizefor($obj, "baz"), Baz), "in this case it's converted anyway");
434434
}
435+
436+
# Serializing a type with HLL role
437+
{
438+
439+
my $type := NQPClassHOW.new_type(:name('hll test'), :repr('P6opaque'));
440+
$type.HOW.add_parent($type, NQPMu);
441+
$type.HOW.compose($type);
442+
443+
nqp::settypehllrole($type, 4);
444+
445+
nqp::sethllconfig('somelang', nqp::hash(
446+
'foreign_transform_array', -> $array {
447+
'fooifed';
448+
}
449+
));
450+
my $sc := nqp::createsc('TEST_SC_12_IN');
451+
my $sh := nqp::list_s();
452+
453+
my $cr := nqp::list();
454+
455+
add_to_sc($sc, 0, $type);
456+
457+
my $serialized := nqp::serialize($sc, $sh);
458+
459+
my $dsc := nqp::createsc('TEST_SC_12_OUT');
460+
nqp::deserialize($serialized, $dsc, $sh, $cr, nqp::null());
461+
462+
my $obj := nqp::scgetobj($dsc, 0).new;
463+
464+
465+
my $hllized := nqp::hllizefor($obj, "somelang");
466+
ok(nqp::isstr($hllized) && $hllized eq "fooifed", "hll role is preserved correctly");
467+
}

0 commit comments

Comments
 (0)