This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
change warn.t to use test.pl
[perl5.git] / t / op / warn.t
CommitLineData
c5df3096
Z
1#!./perl
2#line 3 warn.t
3
95961f2b
FC
4BEGIN {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 require './test.pl';
c5df3096
Z
8}
9
95961f2b
FC
10plan 18;
11
c5df3096
Z
12my @warnings;
13my $wa = []; my $ea = [];
14$SIG{__WARN__} = sub { push @warnings, $_[0] };
15
16@warnings = ();
17$@ = "";
18warn "foo\n";
19ok @warnings==1 && $warnings[0] eq "foo\n";
20
21@warnings = ();
22$@ = "";
23warn "foo", "bar\n";
24ok @warnings==1 && $warnings[0] eq "foobar\n";
25
26@warnings = ();
27$@ = "";
28warn "foo";
95961f2b 29ok @warnings==1 && $warnings[0] eq "foo at warn.t line 28.\n";
c5df3096
Z
30
31@warnings = ();
32$@ = "";
33warn $wa;
34ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $wa;
35
36@warnings = ();
37$@ = "";
38warn "";
39ok @warnings==1 &&
95961f2b 40 $warnings[0] eq "Warning: something's wrong at warn.t line 38.\n";
c5df3096
Z
41
42@warnings = ();
43$@ = "";
44warn;
45ok @warnings==1 &&
95961f2b 46 $warnings[0] eq "Warning: something's wrong at warn.t line 44.\n";
c5df3096
Z
47
48@warnings = ();
49$@ = "ERR\n";
50warn "foo\n";
51ok @warnings==1 && $warnings[0] eq "foo\n";
52
53@warnings = ();
54$@ = "ERR\n";
55warn "foo", "bar\n";
56ok @warnings==1 && $warnings[0] eq "foobar\n";
57
58@warnings = ();
59$@ = "ERR\n";
60warn "foo";
95961f2b 61ok @warnings==1 && $warnings[0] eq "foo at warn.t line 60.\n";
c5df3096
Z
62
63@warnings = ();
64$@ = "ERR\n";
65warn $wa;
66ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $wa;
67
68@warnings = ();
69$@ = "ERR\n";
70warn "";
71ok @warnings==1 &&
95961f2b 72 $warnings[0] eq "ERR\n\t...caught at warn.t line 70.\n";
c5df3096
Z
73
74@warnings = ();
75$@ = "ERR\n";
76warn;
77ok @warnings==1 &&
95961f2b 78 $warnings[0] eq "ERR\n\t...caught at warn.t line 76.\n";
c5df3096
Z
79
80@warnings = ();
81$@ = $ea;
82warn "foo\n";
83ok @warnings==1 && $warnings[0] eq "foo\n";
84
85@warnings = ();
86$@ = $ea;
87warn "foo", "bar\n";
88ok @warnings==1 && $warnings[0] eq "foobar\n";
89
90@warnings = ();
91$@ = $ea;
92warn "foo";
95961f2b 93ok @warnings==1 && $warnings[0] eq "foo at warn.t line 92.\n";
c5df3096
Z
94
95@warnings = ();
96$@ = $ea;
97warn $wa;
98ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $wa;
99
100@warnings = ();
101$@ = $ea;
102warn "";
103ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $ea;
104
105@warnings = ();
106$@ = $ea;
107warn;
108ok @warnings==1 && ref($warnings[0]) eq "ARRAY" && $warnings[0] == $ea;
109
1101;