|
2 | 2 |
|
3 | 3 | use nqpmo;
|
4 | 4 |
|
5 |
| -plan(48); |
| 5 | +plan(49); |
6 | 6 |
|
7 | 7 | sub add_to_sc($sc, $idx, $obj) {
|
8 | 8 | nqp::scsetobj($sc, $idx, $obj);
|
@@ -432,3 +432,36 @@ sub add_to_sc($sc, $idx, $obj) {
|
432 | 432 | ok(nqp::eqaddr(nqp::hllizefor($obj, "foo"), $obj), "correct hll prevents convertion");
|
433 | 433 | ok(nqp::eqaddr(nqp::hllizefor($obj, "baz"), Baz), "in this case it's converted anyway");
|
434 | 434 | }
|
| 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