This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use alternative URLs for links which are now broken (link rot)
[perl5.git] / t / io / say.t
CommitLineData
0d863452
RH
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
8# Just a few very basic tests cribbed from t/io/print.t,
9# with some minor additions. say is actually compiled to
10# a print opcode, so it's more or less guaranteed to behave
11# the same way as print in any case.
12
13use strict 'vars';
14eval 'use Errno';
15die $@ if $@ and !$ENV{PERL_CORE_MINITEST};
16
17use feature "say";
18
cfc4a7da 19say "1..12";
0d863452
RH
20
21my $foo = 'STDOUT';
22say $foo "ok 1";
23
24say "ok 2\n","ok 3\n","ok 4";
25say STDOUT "ok 5";
26
27open(FOO,">-");
28say FOO "ok 6";
29
30open(my $bar,">-");
31say $bar "ok 7";
32
33say {"STDOUT"} "ok 8";
34
35if (!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";
46say;
47
48$_ = "ok 11";
49say STDOUT;
cfc4a7da
GA
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}