This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
officially support Visual C++ 2022
[perl5.git] / t / io / defout.t
CommitLineData
099be4f1
DM
1#!./perl
2#
3# tests for default output handle
4
5# DAPM 30/4/10 this area seems to have been undertested. For now, the only
6# tests are ensuring things don't crash when PL_defoutgv isn't a GV;
7# it probably needs expanding at some point to cover other stuff.
8
9BEGIN {
a817e89d 10 chdir 't' if -d 't';
099be4f1 11 require './test.pl';
624c42e2 12 set_up_inc('../lib');
099be4f1
DM
13}
14
470e8f06
KW
15$|=0; # test.pl makes it 1, and that conflicts with the below.
16
8ff33955
FC
17plan tests => 16;
18
099be4f1 19
53b7400f
FC
20my $stdout = *STDOUT;
21select($stdout);
22$stdout = 1; # whoops, PL_defoutgv no longer a GV!
2acc3314 23# XXX It is a GV as of 5.13.7. Is this test file needed any more?
099be4f1
DM
24
25# note that in the tests below, the return values aren't as important
26# as the fact that they don't crash
27
2acc3314
FC
28ok print(""), 'print';
29ok select(), 'select';
021897e0 30
8ff33955 31$a = 'fooo';
53b7400f 32format STDOUT =
021897e0
JH
33@ @<<
34"#", $a
099be4f1 35.
021897e0 36ok((write())[0], 'write');
099be4f1 37
2acc3314
FC
38ok($^, '$^');
39ok($~, '$~');
40ok($=, '$=');
41ok($-, '$-');
42is($%, 0, '$%');
099be4f1
DM
43is($|, 0, '$|');
44$^ = 1; pass '$^ = 1';
45$~ = 1; pass '$~ = 1';
46$= = 1; pass '$= = 1';
47$- = 1; pass '$- = 1';
48$% = 1; pass '$% = 1';
49$| = 1; pass '$| = 1';
099be4f1 50
53b7400f
FC
51# Switch to STDERR for this test, so we do not lose our test output
52my $stderr = *STDERR;
53select($stderr);
54$stderr = 1;
55ok close(), 'close';