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

[svn:parrot] r34491 - trunk/languages/pipp/t/php

From:
bernhard
Date:
December 28, 2008 07:01
Subject:
[svn:parrot] r34491 - trunk/languages/pipp/t/php
Message ID:
20081228150135.D05F7CB9F9@x12.develooper.com
Author: bernhard
Date: Sun Dec 28 07:01:34 2008
New Revision: 34491

Modified:
   trunk/languages/pipp/t/php/closures.t

Log:
[Pipp] add two test cases, where a function returns an anonymous sub


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 07:01:34 2008
@@ -20,7 +20,7 @@
 use FindBin;
 use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
 
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 5;
 
 =for perl6
 
@@ -85,3 +85,42 @@
 CODE
 'one', 'two', 'three' was passed to anon_three_args().
 OUT
+
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'create an anonymous sub' );
+<?php
+
+function generator () {
+
+    $anon_no_arg = function ()  {
+        echo "anon_no_arg() was called.\n";
+    };
+}
+
+$sub = generator();
+
+$sub();
+
+?>
+CODE
+anon_no_arg() was called.
+OUT
+
+
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'create an anonymous sub with two args' );
+<?php
+
+function generator () {
+
+    $anon_no_arg = function ($arg_1, $arg_2)  {
+        echo "'$arg_1', '$arg_2' was passed to anon_two_args().\n";
+    };
+}
+
+$sub = generator();
+
+$sub('one', 'two');
+
+?>
+CODE
+'one', 'two' was passed to anon_two_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