]> git.vpit.fr Git - perl/modules/Variable-Temp.git/blobdiff - t/12-destroy.t
This is 0.04
[perl/modules/Variable-Temp.git] / t / 12-destroy.t
index 1193f0714ca31fd8f48ce1e1eca29a465ce6900f..5fdc85339f961bf611c6fe354b30b24afaf5cbda 100644 (file)
@@ -3,36 +3,26 @@
 use strict;
 use warnings;
 
-use Variable::Temp 'temp';
+use Variable::Temp 'set_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 {
set_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 {
set_temp $x => VPIT::TestHelpers::Guard->new(sub {
   is $x_is_destroyed,       0;
   is $x_temp1_is_destroyed, 0;
   ++$x_temp2_is_destroyed;