Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some tests for the new container stuff.
  • Loading branch information
jnthn committed Mar 19, 2013
1 parent 7ca7a40 commit 61011ea
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions t/nqp/67-container.t
@@ -0,0 +1,24 @@
plan(4);

# code_pair container spec
{
my $value := 42;
sub fetch($cont) { $value }
sub store($cont, $new) { $value := $new }

class SomeCont { }
nqp::setcontspec(SomeCont, 'code_pair', nqp::hash(
'fetch', &fetch,
'store', &store
));

my $cont := nqp::create(SomeCont);
ok(nqp::iscont($cont), 'correct result from iscont');

ok(nqp::decont($cont) == 42, 'initial decontainerization OK');

nqp::assign($cont, 101);
ok(nqp::decont($cont) == 101, 'assigned value stuck');

ok($value == 101, 'updated captured value also');
}

0 comments on commit 61011ea

Please sign in to comment.