develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34488 - in trunk/languages/pipp: src/pct t/php

From:
bernhard
Date:
December 28, 2008 05:49
Subject:
[svn:parrot] r34488 - in trunk/languages/pipp: src/pct t/php
Message ID:
20081228134936.A67FCCB9F9@x12.develooper.com
Author: bernhard
Date: Sun Dec 28 05:49:35 2008
New Revision: 34488

Modified:
   trunk/languages/pipp/src/pct/actions.pm
   trunk/languages/pipp/t/php/closures.t

Log:
[Pipp] Fix passing of arguments to anonymous functions.


Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm	(original)
+++ trunk/languages/pipp/src/pct/actions.pm	Sun Dec 28 05:49:35 2008
@@ -163,7 +163,7 @@
 
 method closure_call($/) {
     my $past := $( $<arguments> );
-    $past.push( $( $<var> ) );
+    $past.unshift( $( $<var> ) );
 
     make $past;
 }

Modified: trunk/languages/pipp/t/php/closures.t
==============================================================================
--- trunk/languages/pipp/t/php/closures.t	(original)
+++ trunk/languages/pipp/t/php/closures.t	Sun Dec 28 05:49:35 2008
@@ -20,7 +20,7 @@
 use FindBin;
 use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
 
-use Parrot::Test tests => 2;
+use Parrot::Test tests => 3;
 
 =for perl6
 
@@ -46,7 +46,18 @@
 The function anon_no_args() has been called.
 OUT
 
-language_output_is( 'Pipp', <<'CODE', <<'OUT', 'anonymous function with one arg', todo => 'broken' );
+
+=for perl6
+
+my $anon_one_arg = sub ($arg_1)  {
+  print "'$arg_1' was passed to anon_one_arg().\n";
+};
+
+$anon_one_arg('one');
+
+=cut
+
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'anonymous function with one arg' );
 <?php
 
 $anon_one_arg = function ($arg_1)  {
@@ -59,3 +70,18 @@
 CODE
 'one' was passed to anon_one_arg().
 OUT
+
+
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'anonymous function with three args' );
+<?php
+
+$anon_three_args = function ($arg_1, $arg_2, $arg_3)  {
+  echo "'$arg_1', '$arg_2', '$arg_3' was passed to anon_three_args().\n";
+};
+
+$anon_three_args('one', 'two', 'three');
+
+?>
+CODE
+'one', 'two', 'three' was passed to anon_three_args().
+OUT



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About