Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
c6d30d5e |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | use Test::Exception; |
84e4e006 |
8 | use Test::Warn; |
c6d30d5e |
9 | |
c6d30d5e |
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'; |
35cf7d1a |
41 | |
42 | warnings_are { |
43 | $@ = $ap->new; |
44 | $schema->txn_do (sub { 1 }); |
45 | |
46 | $@ = $ap->new; |
47 | $schema->txn_scope_guard->commit; |
48 | } [], 'No spurious PSA warnings on pre-existing antipatterns in $@'; |
49 | |
84e4e006 |
50 | } |
51 | |
c6d30d5e |
52 | done_testing; |