Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Some tests for the new container stuff.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'); | ||
| } |