Resolve $rsrc instance duality on metadata traversal
[dbsrgits/DBIx-Class.git] / t / 36double_destroy.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use DBICTest::Util 'capture_stderr';
9
10 use DBICTest;
11
12 my $output;
13
14 # ensure Devel::StackTrace-refcapture-like effects are countered
15 {
16   my $s = DBICTest::Schema->connect('dbi:SQLite::memory:');
17   my $g = $s->txn_scope_guard;
18
19   my @arg_capture;
20   {
21     local $SIG{__WARN__} = sub {
22       package DB;
23       my $frnum;
24       while (my @f = CORE::caller(++$frnum) ) {
25         push @arg_capture, @DB::args;
26       }
27     };
28
29     undef $g;
30     1;
31   }
32
33   # this should emit on stderr
34   $output = capture_stderr { @arg_capture = () };
35 };
36
37 like(
38   $output,
39   qr/\QPreventing *MULTIPLE* DESTROY() invocations on DBIx::Class::Storage::TxnScopeGuard/,
40   'Proper warning emitted on STDERR'
41 );
42
43 done_testing;