Update Module::Build to 0.33_05
[p5sagit/p5-mst-13.2.git] / lib / autodie / t / context_lexical.t
1 #!/usr/bin/perl -w
2 use strict;
3
4 use Test::More;
5
6 plan 'no_plan';
7
8 # Returns a list presented to it, but also returns a single
9 # undef if given a list of a single undef.  This mimics the
10 # behaviour of many user-defined subs and built-ins (eg: open) that
11 # always return undef regardless of context.
12
13 sub list_mirror {
14     return undef if (@_ == 1 and not defined $_[0]);
15     return @_;
16
17 }
18
19 ### autodie clobbering tests ###
20
21 eval {
22     list_mirror();
23 };
24
25 is($@, "", "No autodie, no fatality");
26
27 eval {
28     use autodie qw(list_mirror);
29     list_mirror();
30 };
31
32 ok($@, "Autodie fatality for empty return in void context");
33
34 eval {
35     list_mirror();
36 };
37
38 is($@, "", "No autodie, no fatality (after autodie used)");
39
40 eval {
41     use autodie qw(list_mirror);
42     list_mirror(undef);
43 };
44
45 ok($@, "Autodie fatality for undef return in void context");
46
47 eval {
48     use autodie qw(list_mirror);
49     my @list = list_mirror();
50 };
51
52 ok($@,"Autodie fatality for empty list return");
53
54 eval {
55     use autodie qw(list_mirror);
56     my @list = list_mirror(undef);
57 };
58
59 ok($@,"Autodie fatality for undef list return");
60
61 eval {
62     use autodie qw(list_mirror);
63     my @list = list_mirror("tada");
64 };
65
66 ok(! $@,"No Autodie fatality for defined list return");
67
68 eval {
69     use autodie qw(list_mirror);
70     my $single = list_mirror("tada");
71 };
72
73 ok(! $@,"No Autodie fatality for defined scalar return");
74
75 eval {
76     use autodie qw(list_mirror);
77     my $single = list_mirror(undef);
78 };
79
80 ok($@,"Autodie fatality for undefined scalar return");