This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update the Change log in Module::CoreList to include recent commits
[perl5.git] / cpan / autodie / t / blog_hints.t
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
4 use Test::More 'no_plan';
5
6 use FindBin;
7 use lib "$FindBin::Bin/lib";
8
9 use Some::Module qw(some_sub);
10 use my::autodie qw(! some_sub);
11
12 eval { some_sub() };
13
14 isnt("$@", "", "some_sub should die in void/scalar context");
15
16 isa_ok($@, 'autodie::exception');
17 is($@->context, 'scalar');
18 is($@->function, 'Some::Module::some_sub');
19 like("$@", qr/can't be called in scalar context/);
20
21 my @returns = eval { some_sub(0); };
22 is($@, "", "Good call to some_sub");
23 is_deeply(\@returns, [1,2,3], "Returns unmolested");
24
25 @returns = eval { some_sub(1) };
26
27 isnt("$@","");
28 is($@->return->[0], undef);
29 is($@->return->[1], 'Insufficient credit');
30 like("$@", qr/Insufficient credit/);