Commit | Line | Data |
89c1e84a |
1 | #!/usr/bin/perl -w |
2 | |
33459055 |
3 | BEGIN { |
a9153838 |
4 | if( $ENV{PERL_CORE} ) { |
5 | chdir 't'; |
89c1e84a |
6 | @INC = ('../lib', 'lib'); |
7 | } |
8 | else { |
9 | unshift @INC, 't/lib'; |
a9153838 |
10 | } |
33459055 |
11 | } |
12 | |
d020a79a |
13 | use strict; |
3e887aae |
14 | use Test::More tests => 21; |
d020a79a |
15 | |
16 | BEGIN { $^W = 1; } |
17 | |
18 | my $warnings = ''; |
a9153838 |
19 | local $SIG{__WARN__} = sub { $warnings .= join '', @_ }; |
d020a79a |
20 | |
b1ddf169 |
21 | my $TB = Test::Builder->new; |
22 | sub no_warnings { |
23 | $TB->is_eq($warnings, '', ' no warnings'); |
24 | $warnings = ''; |
25 | } |
26 | |
27 | sub warnings_is { |
28 | $TB->is_eq($warnings, $_[0]); |
29 | $warnings = ''; |
30 | } |
31 | |
32 | sub warnings_like { |
82d700dc |
33 | $TB->like($warnings, $_[0]); |
b1ddf169 |
34 | $warnings = ''; |
35 | } |
36 | |
37 | |
38 | my $Filename = quotemeta $0; |
39 | |
40 | |
d020a79a |
41 | is( undef, undef, 'undef is undef'); |
b1ddf169 |
42 | no_warnings; |
d020a79a |
43 | |
44 | isnt( undef, 'foo', 'undef isnt foo'); |
b1ddf169 |
45 | no_warnings; |
d020a79a |
46 | |
a9153838 |
47 | isnt( undef, '', 'undef isnt an empty string' ); |
48 | isnt( undef, 0, 'undef isnt zero' ); |
49 | |
ccbd73a4 |
50 | Test::More->builder->is_num(undef, undef, 'is_num()'); |
51 | Test::More->builder->isnt_num(23, undef, 'isnt_num()'); |
52 | |
b1ddf169 |
53 | #line 45 |
3e887aae |
54 | like( undef, qr/.*/, 'undef is like anything' ); |
82d700dc |
55 | warnings_like(qr/Use of uninitialized value.* at $Filename line 45\.\n/); |
d020a79a |
56 | |
57 | eq_array( [undef, undef], [undef, 23] ); |
b1ddf169 |
58 | no_warnings; |
d020a79a |
59 | |
60 | eq_hash ( { foo => undef, bar => undef }, |
61 | { foo => undef, bar => 23 } ); |
b1ddf169 |
62 | no_warnings; |
d020a79a |
63 | |
64 | eq_set ( [undef, undef, 12], [29, undef, undef] ); |
b1ddf169 |
65 | no_warnings; |
d020a79a |
66 | |
67 | |
68 | eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } }, |
69 | { foo => undef, bar => { baz => undef, moo => 23 } } ); |
b1ddf169 |
70 | no_warnings; |
71 | |
72 | |
73 | #line 64 |
74 | cmp_ok( undef, '<=', 2, ' undef <= 2' ); |
82d700dc |
75 | warnings_like(qr/Use of uninitialized value.* at cmp_ok \[from $Filename line 64\] line 1\.\n/); |
b1ddf169 |
76 | |
d020a79a |
77 | |
78 | |
89c1e84a |
79 | my $tb = Test::More->builder; |
80 | |
3e887aae |
81 | my $err; |
82 | $tb->failure_output(\$err); |
89c1e84a |
83 | diag(undef); |
3e887aae |
84 | $tb->reset_outputs; |
89c1e84a |
85 | |
3e887aae |
86 | is( $err, "# undef\n" ); |
b1ddf169 |
87 | no_warnings; |
0257f296 |
88 | |
89 | |
90 | $tb->maybe_regex(undef); |
b1ddf169 |
91 | no_warnings; |
3e887aae |
92 | |
93 | |
94 | # test-more.googlecode.com #42 |
95 | { |
96 | is_deeply([ undef ], [ undef ]); |
97 | no_warnings; |
98 | } |