Commit | Line | Data |
c6d30d5e |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use Test::Exception; |
84e4e006 |
6 | use Test::Warn; |
c6d30d5e |
7 | |
8 | use lib qw(t/lib); |
9 | |
10 | use DBICTest; |
11 | my $schema = DBICTest->init_schema; |
12 | |
13 | throws_ok (sub { |
14 | $schema->txn_do (sub { die 'lol' } ); |
15 | }, 'DBIx::Class::Exception', 'a DBIC::Exception object thrown'); |
16 | |
17 | throws_ok (sub { |
18 | $schema->txn_do (sub { die [qw/lol wut/] }); |
19 | }, qr/ARRAY\(0x/, 'An arrayref thrown'); |
20 | |
21 | is_deeply ( |
22 | $@, |
23 | [qw/ lol wut /], |
24 | 'Exception-arrayref contents preserved', |
25 | ); |
26 | |
84e4e006 |
27 | for my $ap (qw( |
28 | DBICTest::AntiPattern::TrueZeroLen |
29 | DBICTest::AntiPattern::NullObject |
30 | )) { |
31 | eval "require $ap"; |
32 | |
33 | warnings_like { |
34 | eval { |
35 | $schema->txn_do (sub { die $ap->new }); |
36 | }; |
37 | |
38 | isa_ok $@, $ap; |
39 | } qr/\QObjects of external exception class '$ap' stringify to '' (the empty string)/, |
40 | 'Proper warning on encountered antipattern'; |
41 | } |
42 | |
c6d30d5e |
43 | done_testing; |