10 return qw(foo bar baz);
15 return qw(foo bar baz);
18 # Returns a list presented to it, but also returns a single
19 # undef if given a list of a single undef. This mimics the
20 # behaviour of many user-defined subs and built-ins (eg: open) that
21 # always return undef regardless of context.
24 return undef if (@_ == 1 and not defined $_[0]);
29 use Fatal qw(list_return);
30 use Fatal qw(:void list_return2);
34 # Clobbering context was documented as a bug in the original
35 # Fatal, so we'll still consider it a bug here.
37 local $TODO = "Fatal clobbers context, just like it always has.";
39 my @list = list_return();
41 is_deeply(\@list,[qw(foo bar baz)],'fatal sub works in list context');
45 my @line = list_return(1); # Should die
48 ok($@,"List return fatalised");
50 ### Tests where we've fatalised our function with :void ###
52 my @list2 = list_return2();
54 is_deeply(\@list2,[qw(foo bar baz)],'fatal sub works in list context');
57 my @line = list_return2(1); # Shouldn't die
60 ok(! $@,"void List return fatalised survives when non-void");
66 ok($@,"void List return fatalised");