X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F12-destroy.t;h=48217413507919fcae3c54859f228bc5f4ba52e2;hb=01ee034648a5f1116ca1233b7f987607f0b4576c;hp=1193f0714ca31fd8f48ce1e1eca29a465ce6900f;hpb=325778545db343888e4f002fd170c4eb557fdaa5;p=perl%2Fmodules%2FVariable-Temp.git diff --git a/t/12-destroy.t b/t/12-destroy.t index 1193f07..4821741 100644 --- a/t/12-destroy.t +++ b/t/12-destroy.t @@ -7,32 +7,22 @@ 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}->(); - } -} +use lib 't/lib'; +use VPIT::TestHelpers; 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;