Adjust view-dependency tests to work on newer libsqlite
[dbsrgits/DBIx-Class.git] / t / 33exception_wrap.t
CommitLineData
c6d30d5e 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
84e4e006 6use Test::Warn;
c6d30d5e 7
8use lib qw(t/lib);
9
10use DBICTest;
11my $schema = DBICTest->init_schema;
12
13throws_ok (sub {
14 $schema->txn_do (sub { die 'lol' } );
15}, 'DBIx::Class::Exception', 'a DBIC::Exception object thrown');
16
17throws_ok (sub {
18 $schema->txn_do (sub { die [qw/lol wut/] });
19}, qr/ARRAY\(0x/, 'An arrayref thrown');
20
21is_deeply (
22 $@,
23 [qw/ lol wut /],
24 'Exception-arrayref contents preserved',
25);
26
84e4e006 27for 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 43done_testing;