This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Convert t/op/anonsub.t to test.pl, strict and warnings.
[perl5.git] / t / io / print.t
old mode 100755 (executable)
new mode 100644 (file)
index 180b1e8..321eb1e
@@ -1,10 +1,18 @@
 #!./perl
 
-# $RCSfile: print.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:32 $
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require './test.pl';
+    eval 'use Errno';
+    die $@ if $@ and !is_miniperl();
+}
 
-print "1..16\n";
+use strict 'vars';
 
-$foo = 'STDOUT';
+print "1..21\n";
+
+my $foo = 'STDOUT';
 print $foo "ok 1\n";
 
 print "ok 2\n","ok 3\n","ok 4\n";
@@ -16,7 +24,7 @@ print foo "ok 6\n";
 printf "ok %d\n",7;
 printf("ok %d\n",8);
 
-@a = ("ok %d%c",9,ord("\n"));
+my @a = ("ok %d%c",9,ord("\n"));
 printf @a;
 
 $a[1] = 10;
@@ -27,6 +35,34 @@ $\ = "\n";
 
 print "ok","11";
 
-@x = ("ok","12\nok","13\nok");
-@y = ("15\nok","16");
+my @x = ("ok","12\nok","13\nok");
+my @y = ("15\nok","16");
 print @x,"14\nok",@y;
+{
+    local $\ = "ok 17\n# null =>[\000]\nok 18\n";
+    print "";
+}
+
+$\ = '';
+
+if (!exists &Errno::EBADF) {
+    print "ok 19 # skipped: no EBADF\n";
+} else {
+    $! = 0;
+    no warnings 'unopened';
+    print NONEXISTENT "foo";
+    print "not " if ($! != &Errno::EBADF);
+    print "ok 19\n";
+}
+
+{
+    # Change 26009: pp_print didn't extend the stack
+    #               before pushing its return value
+    # to make sure only that these obfuscated sentences will not crash.
+
+    map print(reverse), ('')x68;
+    print "ok 20\n";
+
+    map print(+()), ('')x68;
+    print "ok 21\n";
+}