summaryrefslogtreecommitdiff
path: root/t/io/say.t
blob: 1da7a18d8f3eac26d7fb21b693141ef2ab44e107 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!./perl

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
}

# Just a few very basic tests cribbed from t/io/print.t,
# with some minor additions. say is actually compiled to
# a print opcode, so it's more or less guaranteed to behave
# the same way as print in any case.

use strict 'vars';
eval 'use Errno';
die $@ if $@ and !$ENV{PERL_CORE_MINITEST};

use feature "say";

say "1..12";

my $foo = 'STDOUT';
say $foo "ok 1";

say "ok 2\n","ok 3\n","ok 4";
say STDOUT "ok 5";

open(FOO,">-");
say FOO "ok 6";

open(my $bar,">-");
say $bar "ok 7";

say {"STDOUT"} "ok 8";

if (!exists &Errno::EBADF) {
    print "ok 9 # skipped: no EBADF\n";
} else {
    $! = 0;
    no warnings 'unopened';
    say NONEXISTENT "foo";
    print "not " if ($! != &Errno::EBADF);
    say "ok 9";
}

$_ = "ok 10";
say;

$_ = "ok 11";
say STDOUT;

{
    # test that $, doesn't show up before the trailing \n
    local $, = "\nnot ok 13"; # how to fool Test::Harness
    say "ok 12";
}