summaryrefslogtreecommitdiff
path: root/t/basic.t
diff options
context:
space:
mode:
Diffstat (limited to 't/basic.t')
-rw-r--r--t/basic.t62
1 files changed, 31 insertions, 31 deletions
diff --git a/t/basic.t b/t/basic.t
index 42c0310..0fe5c13 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -6,47 +6,47 @@ use Test::Fatal;
use Variable::Disposition;
{
- my $x = [1,2,3];
- isa_ok($x, 'ARRAY');
- dispose $x;
- is($x, undef, 'was undefined correctly');
+ my $x = [1,2,3];
+ isa_ok($x, 'ARRAY');
+ dispose $x;
+ is($x, undef, 'was undefined correctly');
}
{
- my $x = [1,2,3];
- my $copy = $x;
- like(exception {
- dispose $x;
- }, qr/not released/, 'raise an exception if variable is still around');
- is($x, undef, 'was still undefined correctly');
- is(exception {
- dispose $copy;
- }, undef, 'no exception when last copy goes');
+ my $x = [1,2,3];
+ my $copy = $x;
+ like(exception {
+ dispose $x;
+ }, qr/not released/, 'raise an exception if variable is still around');
+ is($x, undef, 'was still undefined correctly');
+ is(exception {
+ dispose $copy;
+ }, undef, 'no exception when last copy goes');
}
{
- my $x = 'test';
- like(exception {
- dispose $x;
- }, qr/not a ref/, 'raise an exception when called on non-ref');
- is($x, 'test', 'still defined');
- undef $x;
- like(exception {
- dispose $x;
- }, qr/not defined/, 'raise an exception when called on undef');
+ my $x = 'test';
+ like(exception {
+ dispose $x;
+ }, qr/not a ref/, 'raise an exception when called on non-ref');
+ is($x, 'test', 'still defined');
+ undef $x;
+ like(exception {
+ dispose $x;
+ }, qr/not defined/, 'raise an exception when called on undef');
}
my $destroyed = 0;
{
- {
- package Local::Test;
- sub DESTROY { ++$destroyed }
- }
- my $x = bless {}, 'Local::Test';
- is($destroyed, 0, 'not yet destroyed');
- dispose $x;
- is($destroyed, 1, 'destroyed after dispose()');
- is($x, undef, 'was undef');
+ {
+ package Local::Test;
+ sub DESTROY { ++$destroyed }
+ }
+ my $x = bless {}, 'Local::Test';
+ is($destroyed, 0, 'not yet destroyed');
+ dispose $x;
+ is($destroyed, 1, 'destroyed after dispose()');
+ is($x, undef, 'was undef');
}
is($destroyed, 1, 'still only a single DESTROY called when leaving scope');