This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor podcheck.t to slurp files into scalars, instead of an array of lines.
[perl5.git] / t / io / say.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';
7     eval 'use Errno';
8     die $@ if $@ and !is_miniperl();
9 }
10
11 # Just a few very basic tests cribbed from t/io/print.t,
12 # with some minor additions. say is actually compiled to
13 # a print opcode, so it's more or less guaranteed to behave
14 # the same way as print in any case.
15
16 use strict 'vars';
17 use feature "say";
18
19 say "1..12";
20
21 my $foo = 'STDOUT';
22 say $foo "ok 1";
23
24 say "ok 2\n","ok 3\n","ok 4";
25 say STDOUT "ok 5";
26
27 open(FOO,">-");
28 say FOO "ok 6";
29
30 open(my $bar,">-");
31 say $bar "ok 7";
32
33 say {"STDOUT"} "ok 8";
34
35 if (!exists &Errno::EBADF) {
36     print "ok 9 # skipped: no EBADF\n";
37 } else {
38     $! = 0;
39     no warnings 'unopened';
40     say NONEXISTENT "foo";
41     print "not " if ($! != &Errno::EBADF);
42     say "ok 9";
43 }
44
45 $_ = "ok 10";
46 say;
47
48 $_ = "ok 11";
49 say STDOUT;
50
51 {
52     # test that $, doesn't show up before the trailing \n
53     local $, = "\nnot ok 13"; # how to fool Test::Harness
54     say "ok 12";
55 }