This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] t/op/crypt.t
[perl5.git] / t / op / runlevel.t
index 623ca42..1364801 100755 (executable)
@@ -3,13 +3,14 @@
 ##
 ## Many of these tests are originally from Michael Schroeder
 ## <Michael.Schroeder@informatik.uni-erlangen.de>
-## Adapted and expanded by Gurusamy Sarathy <gsar@umich.edu>
+## Adapted and expanded by Gurusamy Sarathy <gsar@activestate.com>
 ##
 
 chdir 't' if -d 't';
-unshift @INC, "../lib";
+@INC = '../lib';
 $Is_VMS = $^O eq 'VMS';
 $Is_MSWin32 = $^O eq 'MSWin32';
+$Is_NetWare = $^O eq 'NetWare';
 $ENV{PERL5LIB} = "../lib" unless $Is_VMS;
 
 $|=1;
@@ -32,10 +33,12 @@ for (@prgs){
     print TEST "$prog\n";
     close TEST;
     my $results = $Is_VMS ?
-                 `MCR $^X "-I[-.lib]" $switch $tmpfile` :
+                  `MCR $^X "-I[-.lib]" $switch $tmpfile 2>&1` :
                      $Is_MSWin32 ?  
                          `.\\perl -I../lib $switch $tmpfile 2>&1` :
-                             `sh -c './perl $switch $tmpfile' 2>&1`;
+                     $Is_NetWare ?  
+                         `perl -I../lib $switch $tmpfile 2>&1` :
+                             `./perl $switch $tmpfile 2>&1`;
     my $status = $?;
     $results =~ s/\n+$//;
     # allow expected output to be written as if $prog is on STDIN
@@ -57,7 +60,7 @@ __END__
   @a = sort { last ; } @a;
 }
 EXPECT
-Can't "last" outside a block at - line 3.
+Can't "last" outside a loop block at - line 3.
 ########
 package TEST;
  
@@ -174,13 +177,15 @@ exit;
 bar:
 print "bar reached\n";
 EXPECT
-Can't "goto" outside a block at - line 2.
+Can't "goto" out of a pseudo block at - line 2.
 ########
+%seen = ();
 sub sortfn {
   (split(/./, 'x'x10000))[0];
   my (@y) = ( 4, 6, 5);
   @y = sort { $a <=> $b } @y;
-  print "sortfn ".join(', ', @y)."\n";
+  my $t = "sortfn ".join(', ', @y)."\n";
+  print $t if ($seen{$t}++ == 0);
   return $_[0] <=> $_[1];
 }
 @x = ( 3, 2, 1 );
@@ -188,8 +193,6 @@ sub sortfn {
 print "---- ".join(', ', @x)."\n";
 EXPECT
 sortfn 4, 5, 6
-sortfn 4, 5, 6
-sortfn 4, 5, 6
 ---- 1, 2, 3
 ########
 @a = (3, 2, 1);
@@ -227,7 +230,7 @@ tie $bar, TEST;
 }
 print "OK\n";
 EXPECT
-Can't "next" outside a block at - line 8.
+Can't "next" outside a loop block at - line 8.
 ########
 package TEST;
  
@@ -285,7 +288,7 @@ package main;
 tie $bar, TEST;
 }
 EXPECT
-Can't "next" outside a block at - line 4.
+Can't "next" outside a loop block at - line 4.
 ########
 @a = (1, 2, 3);
 foo:
@@ -335,3 +338,32 @@ tie my @bar, 'TEST';
 print join('|', @bar[0..3]), "\n"; 
 EXPECT
 foo|fee|fie|foe
+########
+package TH;
+sub TIEHASH { bless {}, TH }
+sub STORE { eval { print "@_[1,2]\n" }; die "bar\n" }
+tie %h, TH;
+eval { $h{A} = 1; print "never\n"; };
+print $@;
+eval { $h{B} = 2; };
+print $@;
+EXPECT
+A 1
+bar
+B 2
+bar
+########
+sub n { 0 }
+sub f { my $x = shift; d(); }
+f(n());
+f();
+
+sub d {
+    my $i = 0; my @a;
+    while (do { { package DB; @a = caller($i++) } } ) {
+        @a = @DB::args;
+        for (@a) { print "$_\n"; $_ = '' }
+    }
+}
+EXPECT
+0