Make some casts explicit to keep VC++ 7 happy
[p5sagit/p5-mst-13.2.git] / t / op / grep.t
index 6e60813..3e5d716 100755 (executable)
@@ -4,7 +4,7 @@
 # grep() and map() tests
 #
 
-print "1..33\n";
+print "1..38\n";
 
 $test = 1;
 
@@ -135,3 +135,35 @@ sub ok {
     $test++;
 }
 
+{
+    sub add_an_x(@){
+        map {"${_}x"} @_;
+    };
+    ok join("-",add_an_x(1,2,3,4)), "1x-2x-3x-4x";
+    $test++;
+}
+
+{
+    my $gimme;
+
+    sub gimme {
+       my $want = wantarray();
+       if (defined $want) {
+           $gimme = $want ? 'list' : 'scalar';
+       } else {
+           $gimme = 'void';
+       }
+    }
+
+    my @list = 0..9;
+
+    undef $gimme; gimme for @list;      ok($gimme, 'void');   $test++;
+    undef $gimme; grep { gimme } @list; ok($gimme, 'scalar'); $test++;
+    undef $gimme; map { gimme } @list;  ok($gimme, 'list');   $test++;
+}
+
+{
+    # This shouldn't loop indefinitively.
+    my @empty = map { while (1) {} } ();
+    ok("@empty", '');
+}