This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new regression tests for bug ID 20010920.007
[perl5.git] / t / op / do.t
index 3fc4441..b70fae1 100755 (executable)
--- a/t/op/do.t
+++ b/t/op/do.t
@@ -16,7 +16,7 @@ sub foo2
     $x;
 }
 
-print "1..15\n";
+print "1..20\n";
 
 $_[0] = "not ok 1\n";
 $result = do foo1("ok 1\n");
@@ -42,3 +42,38 @@ do blather("ok 9\n","ok 10\n");
 @x = ("ok 11\n", "ok 12\n");
 @y = ("ok 14\n", "ok 15\n");
 do blather(@x,"ok 13\n",@y);
+
+unshift @INC, '.';
+
+if (open(DO, ">$$.16")) {
+    print DO "print qq{ok 16\n} if defined wantarray && not wantarray\n";
+    close DO;
+}
+
+my $a = do "$$.16";
+
+if (open(DO, ">$$.17")) {
+    print DO "print qq{ok 17\n} if defined wantarray &&     wantarray\n";
+    close DO;
+}
+
+my @a = do "$$.17";
+
+if (open(DO, ">$$.18")) {
+    print DO "print qq{ok 18\n} if not defined wantarray\n";
+    close DO;
+}
+
+do "$$.18";
+
+eval qq{ do qq(a file that does not exist); };
+print "not " if $@;
+print "ok 19\n";
+
+eval qq{ do uc qq(a file that does not exist); };
+print "not " if $@;
+print "ok 20\n";
+
+END {
+    1 while unlink("$$.16", "$$.17", "$$.18");
+}