xref: /openbsd/gnu/usr.bin/perl/t/op/print.t (revision 3d61058a)
1#!./perl
2
3BEGIN {
4    chdir 't' if -d 't';
5    require "./test.pl";
6}
7
8plan(3);
9
10fresh_perl_is('$_ = qq{OK\n}; print;', "OK\n", {},
11              'print without arguments outputs $_');
12fresh_perl_is('$_ = qq{OK\n}; print STDOUT;', "OK\n", {},
13              'print with only a filehandle outputs $_');
14{
15    if ($::IS_ASCII) {
16        fresh_perl_is(<<'EOF', "\xC1\xAF\xC1\xAF\xC1\xB0\xC1\xB3", {}, "print doesn't launder utf8 overlongs");
17use strict;
18use warnings;
19
20no warnings 'utf8';
21
22# These form overlong "oops"
23open my $fh, "<:utf8", \"\xC1\xAF\xC1\xAF\xC1\xB0\xC1\xB3"
24    or die "Could not open\n";
25read($fh, my $s, 10) or die "Could not read\n";
26print $s;
27EOF
28    }
29    else {
30        fresh_perl_is(<<'EOF', "\x76\x41\x76\x41\x77\x42\x77\x43", {}, "print doesn't launder utf8 overlongs");
31use strict;
32use warnings;
33
34no warnings 'utf8';
35
36# These form overlong "oops"
37open my $fh, "<:utf8", \"\x76\x41\x76\x41\x77\x42\x77\x43"
38    or die "Could not open\n";
39read($fh, my $s, 10) or die "Could not read\n";
40print $s;
41EOF
42    }
43}
44