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; |
b1ddf169 |
14 | use Test::More tests => 18; |
89c1e84a |
15 | use TieOut; |
d020a79a |
16 | |
17 | BEGIN { $^W = 1; } |
18 | |
19 | my $warnings = ''; |
a9153838 |
20 | local $SIG{__WARN__} = sub { $warnings .= join '', @_ }; |
d020a79a |
21 | |
b1ddf169 |
22 | my $TB = Test::Builder->new; |
23 | sub no_warnings { |
24 | $TB->is_eq($warnings, '', ' no warnings'); |
25 | $warnings = ''; |
26 | } |
27 | |
28 | sub warnings_is { |
29 | $TB->is_eq($warnings, $_[0]); |
30 | $warnings = ''; |
31 | } |
32 | |
33 | sub warnings_like { |
34 | $TB->like($warnings, "/$_[0]/"); |
35 | $warnings = ''; |
36 | } |
37 | |
38 | |
39 | my $Filename = quotemeta $0; |
40 | |
41 | |
d020a79a |
42 | is( undef, undef, 'undef is undef'); |
b1ddf169 |
43 | no_warnings; |
d020a79a |
44 | |
45 | isnt( undef, 'foo', 'undef isnt foo'); |
b1ddf169 |
46 | no_warnings; |
d020a79a |
47 | |
a9153838 |
48 | isnt( undef, '', 'undef isnt an empty string' ); |
49 | isnt( undef, 0, 'undef isnt zero' ); |
50 | |
b1ddf169 |
51 | #line 45 |
d020a79a |
52 | like( undef, '/.*/', 'undef is like anything' ); |
b1ddf169 |
53 | warnings_like("Use of uninitialized value.* at $Filename line 45\\.\n"); |
d020a79a |
54 | |
55 | eq_array( [undef, undef], [undef, 23] ); |
b1ddf169 |
56 | no_warnings; |
d020a79a |
57 | |
58 | eq_hash ( { foo => undef, bar => undef }, |
59 | { foo => undef, bar => 23 } ); |
b1ddf169 |
60 | no_warnings; |
d020a79a |
61 | |
62 | eq_set ( [undef, undef, 12], [29, undef, undef] ); |
b1ddf169 |
63 | no_warnings; |
d020a79a |
64 | |
65 | |
66 | eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } }, |
67 | { foo => undef, bar => { baz => undef, moo => 23 } } ); |
b1ddf169 |
68 | no_warnings; |
69 | |
70 | |
71 | #line 64 |
72 | cmp_ok( undef, '<=', 2, ' undef <= 2' ); |
73 | warnings_like("Use of uninitialized value.* at $Filename line 64\\.\n"); |
74 | |
d020a79a |
75 | |
76 | |
89c1e84a |
77 | my $tb = Test::More->builder; |
78 | |
79 | use TieOut; |
80 | my $caught = tie *CATCH, 'TieOut'; |
81 | my $old_fail = $tb->failure_output; |
82 | $tb->failure_output(\*CATCH); |
83 | diag(undef); |
84 | $tb->failure_output($old_fail); |
85 | |
86 | is( $caught->read, "# undef\n" ); |
b1ddf169 |
87 | no_warnings; |
0257f296 |
88 | |
89 | |
90 | $tb->maybe_regex(undef); |
91 | is( $caught->read, '' ); |
b1ddf169 |
92 | no_warnings; |