Lots of consting
[p5sagit/p5-mst-13.2.git] / t / op / do.t
index 1d6fb90..b611d0d 100755 (executable)
--- a/t/op/do.t
+++ b/t/op/do.t
@@ -31,7 +31,7 @@ sub ok {
     return $ok;
 }
 
-print "1..20\n";
+print "1..22\n";
 
 # Test do &sub and proper @_ handling.
 $_[0] = 0;
@@ -61,39 +61,38 @@ unshift @INC, '.';
 
 if (open(DO, ">$$.16")) {
     print DO "ok(1, 'do in scalar context') if defined wantarray && not wantarray\n";
-    close DO;
+    close DO or die "Could not close: $!";
 }
 
 my $a = do "$$.16";
 
 if (open(DO, ">$$.17")) {
     print DO "ok(1, 'do in list context') if defined wantarray &&     wantarray\n";
-    close DO;
+    close DO or die "Could not close: $!";
 }
 
 my @a = do "$$.17";
 
 if (open(DO, ">$$.18")) {
     print DO "ok(1, 'do in void context') if not defined wantarray\n";
-    close DO;
+    close DO or die "Could not close: $!";
 }
 
 do "$$.18";
 
 # bug ID 20010920.007
 eval qq{ do qq(a file that does not exist); };
-ok( !$@ );
+ok( !$@, "do on a non-existing file, first try" );
 
 eval qq{ do uc qq(a file that does not exist); };
-ok( !$@ );
+ok( !$@, "do on a non-existing file, second try"  );
 
-eval qq{ do qq(a file that does not exist); };
-print "not " if $@;
-print "ok 19\n";
+# 6 must be interpreted as a file name here
+ok( (!defined do 6) && $!, "'do 6' : $!" );
 
-eval qq{ do uc qq(a file that does not exist); };
-print "not " if $@;
-print "ok 20\n";
+# [perl #19545]
+push @t, ($u = (do {} . "This should be pushed."));
+ok( $#t == 0, "empty do result value" );
 
 END {
     1 while unlink("$$.16", "$$.17", "$$.18");