|
1 | 1 | #! nqp
|
2 | 2 |
|
3 |
| -plan(1489); |
| 3 | +plan(1494); |
4 | 4 |
|
5 | 5 | {
|
6 | 6 | my $sc := nqp::createsc('exampleHandle');
|
@@ -412,6 +412,9 @@ sub add_to_sc($sc, $idx, $obj) {
|
412 | 412 | ok(nqp::atpos_s(nqp::scgetobj($dsc, 0).a, 2) eq 'pig', 'string array third element is correct');
|
413 | 413 | }
|
414 | 414 |
|
| 415 | + |
| 416 | + |
| 417 | + |
415 | 418 | # Serializing an SC with a P6opaque containing a MultiCache
|
416 | 419 | {
|
417 | 420 | my $sc := nqp::createsc('TEST_SC_13_IN');
|
@@ -450,6 +453,31 @@ sub add_to_sc($sc, $idx, $obj) {
|
450 | 453 | ok(nqp::isnull(nqp::scgetobj($dsc, 0).fh), 'File handle ends up null');
|
451 | 454 | }
|
452 | 455 |
|
| 456 | +# Serializing an SC with a VMArray |
| 457 | +{ |
| 458 | + my $sc := nqp::createsc('TEST_SC_14_IN'); |
| 459 | + my $sh := nqp::list_s(); |
| 460 | + |
| 461 | + class VMArrayClass is repr('VMArray') { |
| 462 | + } |
| 463 | + |
| 464 | + my $v := VMArrayClass.new(); |
| 465 | + nqp::push($v, 123); |
| 466 | + nqp::push($v, 456); |
| 467 | + add_to_sc($sc, 0, $v); |
| 468 | + |
| 469 | + my $serialized := nqp::serialize($sc, $sh); |
| 470 | + |
| 471 | + my $dsc := nqp::createsc('TEST_SC_14_OUT'); |
| 472 | + nqp::deserialize($serialized, $dsc, $sh, nqp::list(), nqp::null()); |
| 473 | + |
| 474 | + ok(nqp::scobjcount($dsc) == 1, 'deserialized SC has a single object'); |
| 475 | + ok(nqp::istype(nqp::scgetobj($dsc, 0), VMArrayClass), 'deserialized array has correct type'); |
| 476 | + is(nqp::elems(nqp::scgetobj($dsc, 0)), 2, 'deserialize array has correct number of elements'); |
| 477 | + is(nqp::scgetobj($dsc, 0)[0], 123, '0th element of array is correct'); |
| 478 | + is(nqp::scgetobj($dsc, 0)[1], 456, '1st element of array is correct'); |
| 479 | +} |
| 480 | + |
453 | 481 | # integers
|
454 | 482 | sub round_trip_int_array($seq, $desc, @a) {
|
455 | 483 | $seq := 'TEST_SC_' ~ $seq;
|
@@ -491,7 +519,7 @@ sub round_trip_int_array($seq, $desc, @a) {
|
491 | 519 | nqp::push(@a, $i);
|
492 | 520 | $i := $i + 1;
|
493 | 521 | }
|
494 |
| - round_trip_int_array(13, 'small integers', @a); |
| 522 | + round_trip_int_array(14, 'small integers', @a); |
495 | 523 | }
|
496 | 524 |
|
497 | 525 | {
|
|
0 commit comments