Permalink
Browse files

[spec] test for $_ being treated as formal parameter of a block

git-svn-id: http://svn.pugscode.org/pugs@21067 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent cc1d39f commit de174b3b429122f08fd00bd09314c6087a1490d0 moritz committed Jun 26, 2008
Showing with 18 additions and 0 deletions.
  1. +18 −0 S04-declarations/implicit-parameter.t
@@ -0,0 +1,18 @@
+use v6;
+use Test;
+plan 2;
+
+# L<S04/The Relationship of Blocks and Declarations/"A bare closure without
+# placeholder arguments that uses $_">
+
+{
+ # test with explicit $_
+ my $f1 = { 2*$_ };
+ is $f1(2), 4, 'Block with explit $_ has one formal paramter';
+}
+
+{
+ # test with implicit $_
+ my $f2 = { .sqrt };
+ is_approx $f2(4), 2, 'Block with implict $_ has one formal parameter';
+}

0 comments on commit de174b3

Please sign in to comment.