From: Vincent Pit Date: Mon, 9 Mar 2015 14:37:31 +0000 (-0300) Subject: Use VPIT::TestHelpers::Guard in t/12-destroy.t X-Git-Tag: v0.02~20 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=814870f9ed8669571ee7f95cce05765d45b7cf43;p=perl%2Fmodules%2FVariable-Temp.git Use VPIT::TestHelpers::Guard in t/12-destroy.t --- diff --git a/t/12-destroy.t b/t/12-destroy.t index 1193f07..359add1 100644 --- a/t/12-destroy.t +++ b/t/12-destroy.t @@ -3,36 +3,26 @@ use strict; use warnings; +use lib 't/lib'; +use VPIT::TestHelpers; + use Variable::Temp 'temp'; use Test::More tests => 16; -{ - package Variable::Temp::TestDestructor; - - sub new { - my ($class, $code) = @_; - bless { code => $code }, $class; - } - - sub DESTROY { - $_[0]->{code}->(); - } -} - my $x_is_destroyed = 0; my $x_temp1_is_destroyed = 0; my $x_temp2_is_destroyed = 0; { - my $x = Variable::Temp::TestDestructor->new(sub { + my $x = VPIT::TestHelpers::Guard->new(sub { is $x_temp1_is_destroyed, 1; is $x_temp2_is_destroyed, 1; ++$x_is_destroyed; }); is $x_is_destroyed, 0; - temp $x = Variable::Temp::TestDestructor->new(sub { + temp $x = VPIT::TestHelpers::Guard->new(sub { is $x_is_destroyed, 0; is $x_temp2_is_destroyed, 1; ++$x_temp1_is_destroyed; @@ -41,7 +31,7 @@ my $x_temp2_is_destroyed = 0; is $x_temp1_is_destroyed, 0; is $x_temp2_is_destroyed, 0; - temp $x = Variable::Temp::TestDestructor->new(sub { + temp $x = VPIT::TestHelpers::Guard->new(sub { is $x_is_destroyed, 0; is $x_temp1_is_destroyed, 0; ++$x_temp2_is_destroyed;