File: cycle-exists.t

package info (click to toggle)
libtest-memory-cycle-perl 1.06-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 136 kB
  • sloc: perl: 420; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,190 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!perl -T

use warnings FATAL => 'all';
use strict;

use Test::Builder::Tester tests => 5;
use Test::More;

BEGIN {
    use_ok( 'Test::Memory::Cycle' );
}

{
my $cycle_less_hash = {};
test_out( "not ok 1 - A hash reference has no cycles" );
test_fail( +1 );
memory_cycle_exists( $cycle_less_hash, "A hash reference has no cycles" );
test_test( "Testing for lack of cycles in hash reference" );
}

{
my $cycle_less_array = [];
test_out( "not ok 1 - An array reference has no cycles" );
test_fail( +1 );
memory_cycle_exists( $cycle_less_array, "An array reference has no cycles" );
test_test( "Testing for lack of cycles in array reference" );
}

{
my $var = 0;
my $cycle_less_scalar = \$var;
test_out( "not ok 1 - A scalar reference has no cycles" );
test_fail( +1 );
memory_cycle_exists( $cycle_less_scalar, "A scalar reference has no cycles" );
test_test( "Testing for lack of cycles in scalar reference" );
}

{
my $cycle_less_object = bless({}, 'NoCyclesHere');
test_out( "not ok 1 - A blessed reference has no cycles" );
test_fail( +1 );
memory_cycle_exists( $cycle_less_object, "A blessed reference has no cycles" );
test_test( "Testing for lack of cycles in blessed reference" );
}