This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Capitalise magic descriptions consistently
[perl5.git] / t / io / print.t
CommitLineData
8d063cd8
LW
1#!./perl
2
b5fe5ca2
SR
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
bcf53fae
NC
6 require './test.pl';
7 eval 'use Errno';
8 die $@ if $@ and !is_miniperl();
b5fe5ca2
SR
9}
10
11use strict 'vars';
b5fe5ca2 12
87385d72 13print "1..24\n";
8d063cd8 14
b5fe5ca2 15my $foo = 'STDOUT';
378cc40b
LW
16print $foo "ok 1\n";
17
18print "ok 2\n","ok 3\n","ok 4\n";
a687059c 19print STDOUT "ok 5\n";
8d063cd8
LW
20
21open(foo,">-");
22print foo "ok 6\n";
23
24printf "ok %d\n",7;
25printf("ok %d\n",8);
26
b5fe5ca2 27my @a = ("ok %d%c",9,ord("\n"));
8d063cd8
LW
28printf @a;
29
30$a[1] = 10;
a687059c 31printf STDOUT @a;
8d063cd8
LW
32
33$, = ' ';
34$\ = "\n";
35
36print "ok","11";
378cc40b 37
b5fe5ca2
SR
38my @x = ("ok","12\nok","13\nok");
39my @y = ("15\nok","16");
378cc40b 40print @x,"14\nok",@y;
009c130f
GS
41{
42 local $\ = "ok 17\n# null =>[\000]\nok 18\n";
43 print "";
44}
b5fe5ca2 45
43651d81
NC
46$\ = '';
47
b5fe5ca2
SR
48if (!exists &Errno::EBADF) {
49 print "ok 19 # skipped: no EBADF\n";
50} else {
51 $! = 0;
3fb41248 52 no warnings 'unopened';
b5fe5ca2
SR
53 print NONEXISTENT "foo";
54 print "not " if ($! != &Errno::EBADF);
55 print "ok 19\n";
56}
1937c63e
TS
57
58{
59 # Change 26009: pp_print didn't extend the stack
60 # before pushing its return value
61 # to make sure only that these obfuscated sentences will not crash.
62
63 map print(reverse), ('')x68;
64 print "ok 20\n";
65
66 map print(+()), ('')x68;
67 print "ok 21\n";
68}
69974ce6
FC
69
70# printf with %n
71my $n = "abc";
72printf "ok 22%n - not really a test; just printing\n", substr $n,1,1;
73print "not " x ($n ne "a5c") . "ok 23 - printf with %n (got $n)\n";
87385d72
FC
74
75# [perl #77094] printf with empty list
76() = ("not ");
77printf +();
78print "ok 24 - printf +() does not steal stack items\n";