X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fon_destroy.t;h=0de67d0bcde10c116e49270dd20a7dff3b1ea72e;hb=4eee5af6011cc8cdefb66c9729952c7eff5c0b0b;hp=8b85b48ecb7b361ff2b056d53f3e45a197f6c4ee;hpb=7e7f4bfca5f2ef0d123445e074280f5e65cdfb85;p=public-inbox.git diff --git a/t/on_destroy.t b/t/on_destroy.t index 8b85b48e..0de67d0b 100644 --- a/t/on_destroy.t +++ b/t/on_destroy.t @@ -16,6 +16,15 @@ $od = PublicInbox::OnDestroy->new(sub { @x = @_ }, qw(x y)); undef $od; is_deeply(\@x, [ 'x', 'y' ], '2 args passed'); +open my $tmp, '+>>', undef or BAIL_OUT $!; +$tmp->autoflush(1); +$od = PublicInbox::OnDestroy->new(1, sub { print $tmp "$$ DESTROY\n" }); +undef $od; +is(-s $tmp, 0, '$tmp is empty on pid mismatch'); +$od = PublicInbox::OnDestroy->new($$, sub { $tmp = $$ }); +undef $od; +is($tmp, $$, '$tmp set to $$ by callback'); + if (my $nr = $ENV{TEST_LEAK_NR}) { for (0..$nr) { $od = PublicInbox::OnDestroy->new(sub { @x = @_ }, qw(x y));