Skip to content

Commit c92b752

Browse files
committed
Test for precompiled closures
In support of MoarMV/MoarVM#1209 Related to rakudo/rakudo#2897 and a number of other tickets.
1 parent ac0fcd6 commit c92b752

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

S10-packages/precompilation.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use Test;
33
use lib $?FILE.IO.parent(2).add("packages/Test-Helpers");
44
use Test::Util;
55

6-
plan 51;
6+
my $pkg-path = $?FILE.IO.parent(2).add("packages/S10-packages/lib");
7+
8+
plan 52;
79

810
my @*MODULES; # needed for calling CompUnit::Repository::need directly
911

@@ -309,3 +311,10 @@ with make-temp-dir() -> $dir {
309311
'is DEPRECATED does work on Routines in precomped modules';
310312
}
311313
}
314+
315+
# GH rakudo/rakudo#2897
316+
{
317+
is_run q<use lib '> ~ $pkg-path ~ q<'; use GH2897-B; (^3).map( { my-counter } ).join(",").print>,
318+
{ :err(''), :out('0,1,2'), :status => 0 },
319+
'closure is preserved after deserialzation';
320+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use v6;
2+
unit module GH2897-A;
3+
4+
sub gen-counter is export {
5+
my $foo = 0;
6+
sub counter { $foo++ }
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use v6;
2+
unit module GH2897-B;
3+
use GH2897-A;
4+
5+
our &my-counter is export;
6+
7+
BEGIN {
8+
&my-counter = gen-counter;
9+
}

0 commit comments

Comments
 (0)