Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

RT #81962, re-binding my &return

  • Loading branch information...
commit dec32f3ffbfefd17c25ef0c2008b664db632d8e6 1 parent ab9c613
Moritz Lenz authored May 29, 2012

Showing 1 changed file with 16 additions and 1 deletion. Show diff stats Hide diff stats

  1. 17  S04-statements/return.t
17  S04-statements/return.t
... ...
@@ -1,6 +1,6 @@
1 1
 use v6;
2 2
 use Test;
3  
-plan 15;
  3
+plan 17;
4 4
 
5 5
 # Is there a better reference for the spec for how return return works? 
6 6
 # There is "return function" but that's a more advanced feature.
@@ -53,4 +53,19 @@ is( try { sub foo { my $x = 1; while $x-- { return 24; }; return 42; }; foo() },
53 53
     is($bar, '42 1', 'Should not return empty string');
54 54
 }
55 55
 
  56
+# RT #81962
  57
+{
  58
+    my $tracker = '';
  59
+    my &r = &return;
  60
+    sub f {
  61
+        my &return := -> $v {
  62
+            $tracker ~= 'LOL';
  63
+            &r($v * 2);
  64
+        };
  65
+        return(21);
  66
+    }
  67
+    is f(), 42, 'proxied return produces the correct value';
  68
+    is $tracker, 'LOL', 'proxied return produced the right side effect';
  69
+}
  70
+
56 71
 # vim: ft=perl6

0 notes on commit dec32f3

Please sign in to comment.
Something went wrong with that request. Please try again.