6 use Variable::Temp 'set_temp';
8 use Test::More tests => 16;
11 use VPIT::TestHelpers;
13 my $x_is_destroyed = 0;
14 my $x_temp1_is_destroyed = 0;
15 my $x_temp2_is_destroyed = 0;
18 my $x = VPIT::TestHelpers::Guard->new(sub {
19 is $x_temp1_is_destroyed, 1;
20 is $x_temp2_is_destroyed, 1;
23 is $x_is_destroyed, 0;
25 set_temp $x => VPIT::TestHelpers::Guard->new(sub {
26 is $x_is_destroyed, 0;
27 is $x_temp2_is_destroyed, 1;
28 ++$x_temp1_is_destroyed;
30 is $x_is_destroyed, 0;
31 is $x_temp1_is_destroyed, 0;
32 is $x_temp2_is_destroyed, 0;
34 set_temp $x => VPIT::TestHelpers::Guard->new(sub {
35 is $x_is_destroyed, 0;
36 is $x_temp1_is_destroyed, 0;
37 ++$x_temp2_is_destroyed;
39 is $x_is_destroyed, 0;
40 is $x_temp1_is_destroyed, 0;
41 is $x_temp2_is_destroyed, 0;
44 is $x_is_destroyed, 1;
45 is $x_temp1_is_destroyed, 1;
46 is $x_temp2_is_destroyed, 1;