File: family-scalar.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 (106 lines) | stat: -rw-r--r-- 2,761 bytes parent folder | download | duplicates (3)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!perl -T

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

use Scalar::Util qw( weaken );

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

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

my $me;
$me = \$me;

test_out( "not ok 1 - Scalar Family" ); 
test_fail( +3 );
test_diag( 'Cycle #1' );
test_diag( '    $A => $A' );
memory_cycle_ok( $me, "Scalar Family" );
test_test( "Simple loopback" );

test_out( "ok 1 - Scalar Family has Cycles" );
memory_cycle_exists( $me, "Scalar Family has Cycles" );
test_test( "Simple loopback testing for cycles" );

my $myself = \$me;
$me = \$myself;

test_out( "not ok 1" );
test_fail( +4 );
test_diag( 'Cycle #1' );
test_diag( '    $A => $B' );
test_diag( '    $B => $A' );
memory_cycle_ok( $myself ); # Test non-comments
test_test( "Simple loopback to myself" );

test_out( "ok 1" );
memory_cycle_exists( $myself ); # Test non-comments
test_test( "Simple loopback to myself with cycles" );

# Order matters
test_out( "not ok 1" );
test_fail( +4 );
test_diag( 'Cycle #1' );
test_diag( '    $B => $A' );
test_diag( '    $A => $B' );
memory_cycle_ok( $me ); # Test non-comments
test_test( "Flip-flopped the A/B" );


my $sybil;
$sybil = [ $sybil, \$sybil, $me, \$sybil ];
test_out( "not ok 1" );
test_fail( +11 );
test_diag( 'Cycle #1' );
test_diag( '    @C->[1] => $D' );
test_diag( '    $D => @C' );
test_diag( 'Cycle #2' );
test_diag( '    @C->[2] => $B' );
test_diag( '    $B => $A' );
test_diag( '    $A => $B' );
test_diag( 'Cycle #3' );
test_diag( '    @C->[3] => $D' );
test_diag( '    $D => @C' );
memory_cycle_ok( $sybil ); # Test non-comments
test_test( "Sybil and her sisters" );

test_out( "ok 1" );
memory_cycle_exists( $sybil ); # Test non-comments
test_test( "Sybil and her sisters have cycles" );

weaken($sybil->[1]);
weaken($sybil->[2]);
weaken($sybil->[3]);

test_out( "ok 1" );
memory_cycle_ok( $sybil ); # Test non-comments
test_test( "Sybil and her sisters (weakened) (no cycles found)" );

test_out( "not ok 1" );
test_fail( +11 );
test_diag( 'Cycle #1' );
test_diag( '    w->@C->[1] => $D' );
test_diag( '    $D => @C' );
test_diag( 'Cycle #2' );
test_diag( '    w->@C->[2] => $B' );
test_diag( '    $B => $A' );
test_diag( '    $A => $B' );
test_diag( 'Cycle #3' );
test_diag( '    w->@C->[3] => $D' );
test_diag( '    $D => @C' );
weakened_memory_cycle_ok( $sybil ); # Test non-comments
test_test( "Sybil and her sisters (weakened) (weakened cycles found)" );

test_out( "not ok 1" );
test_fail( +1 );
memory_cycle_exists( $sybil ); # Test non-comments
test_test( "Sybil and her sisters (weakened) have cycles (no cycles found)" );

test_out( "ok 1" );
weakened_memory_cycle_exists( $sybil ); # Test non-comments
test_test( "Sybil and her sisters (weakened) have cycles (weakened cycles found)" );