13 my $wa = []; my $ea = [];
14 $SIG{__WARN__} = sub { push @warnings, $_[0] };
19 ok @warnings==1 && $warnings[0] eq "foo\n";
24 ok @warnings==1 && $warnings[0] eq "foobar\n";
29 ok @warnings==1 && $warnings[0] eq "foo at warn.t line 28.\n";
34 ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $wa;
40 $warnings[0] eq "Warning: something's wrong at warn.t line 38.\n";
46 $warnings[0] eq "Warning: something's wrong at warn.t line 44.\n";
51 ok @warnings==1 && $warnings[0] eq "foo\n";
56 ok @warnings==1 && $warnings[0] eq "foobar\n";
61 ok @warnings==1 && $warnings[0] eq "foo at warn.t line 60.\n";
66 ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $wa;
72 $warnings[0] eq "ERR\n\t...caught at warn.t line 70.\n";
78 $warnings[0] eq "ERR\n\t...caught at warn.t line 76.\n";
83 ok @warnings==1 && $warnings[0] eq "foo\n";
88 ok @warnings==1 && $warnings[0] eq "foobar\n";
93 ok @warnings==1 && $warnings[0] eq "foo at warn.t line 92.\n";
98 ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $wa;
103 ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $ea;
108 ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $ea;
113 print STDERR $a; warn $a;
115 print STDERR $a; warn $a;
117 qr/^\xee(?:\r?\n\xee){3}/,
118 { switches => [ "-C0" ] },
119 'warn emits logical characters, not internal bytes [perl #45549]'
123 skip_if_miniperl('miniperl ignores -C', 1);
127 print STDERR $a; warn $a;
129 print STDERR $a; warn $a;
131 qr/^\xc3\xae(?:\r?\n\xc3\xae){3}/,
132 { switches => ['-CE'] },
133 'warn respects :utf8 layer'
139 qr/^Wide character in warn .*\n\xc4\xac at /,
140 { switches => [ "-C0" ] },
141 'Wide character in warn (not print)'
146 qr/^ARRAY\(0x[\da-f]+\) at /a,
148 'warn stringifies in the absence of $SIG{__WARN__}'