Permalink
Browse files

[t/spec] Test for RT 66658: .wrap gets lexicals confused

git-svn-id: http://svn.pugscode.org/pugs@29109 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 33cbda4 commit d33a201893c0ca4a35b43e93269a67d1bc6ecc35 kyle committed Nov 17, 2009
Showing with 24 additions and 0 deletions.
  1. +24 −0 S06-advanced_subroutine_features/wrap.t
@@ -169,6 +169,30 @@ is( functionA(), "xz", "First wrapper and final function only, middle removed."
#?rakudo todo 'RT 70267: call to nextsame with nowhere to go'
dies_ok { {nextsame}() }, '{nextsame}() dies properly';
+# RT #66658
+{
+ sub meet( $person ) { return "meet $person" }
+ sub greet( $person ) { return "greet $person" }
+
+ my $wrapped;
+
+ for &greet, &meet -> $wrap {
+ my $name = $wrap.name;
+ $wrap.wrap({ $wrapped = $name; callsame; });
+ }
+
+ ok ! $wrapped.defined, 'wrapper test variable is undefined';
+ is greet('japhb'), 'greet japhb', 'wrapped greet() works';
+ #?rakudo todo 'RT 66658: .wrap gets lexicals confused'
+ is $wrapped, 'greet', 'wrapper sees lexical from time of wrap (greet)';
+
+ undefine $wrapped;
+
+ ok ! $wrapped.defined, 'wrapper test variable is undefined';
+ is meet('masak'), 'meet masak', 'wrapped meet() works';
+ is $wrapped, 'meet', 'wrapper sees lexical from time of wrap (meet)';
+}
+
done_testing;
# vim: ft=perl6

0 comments on commit d33a201

Please sign in to comment.