Chemistry-Mol-0.35/t/mem.t

filter: Statementstmt 100% 34 / 34 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 42 / 42 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Chemistry-Mol-0.35/t/graph.t ↑ Summary Chemistry-Mol-0.35/t/safe_clone.t »
1 1 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 # These tests try to make sure that objects are destroyed when they
4 # fall out of scope; these requires avoiding circular strong references
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #plan 'no_plan';
10 1 plan tests => 8;
11  
12 1 ▶use Chemistry::File::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 my $dead_atoms = 0;
14 1 my $dead_bonds = 0;
15 1 my $dead_mols = 0;
16  
17 {
18 1 my $mol = Chemistry::Mol->read("t/mol.pl");
19 1 isa_ok( $mol, 'Chemistry::Mol' );
20 1 is( scalar $mol->atoms, 8, 'atoms before');
21  
22 # make sure cloned molecules are also gc'ed
23 1 my $mol2 = $mol->clone;
24  
25 # atom deletion garbage collection test
26 1 $mol->atoms(2)->delete;
27 1 is( $dead_atoms, 1, "delete one atom - atoms" );
28 1 is( $dead_bonds, 4, "delete one atom - bonds" );
29 1 is( $dead_mols, 0, "delete one atom - mols" );
30 }
31  
32 1 is( $dead_atoms, 16, "out of scope - atoms" );
33 1 is( $dead_bonds, 14, "out of scope - bonds" );
34 1 is( $dead_mols, 2, "out of scope - mols" );
35  
36 2 ▶sub Chemistry::Mol::DESTROY { $dead_mols++ }
Subroutine DESTROY: called CC=1 SCAR=0.0
37 16 ▶sub Chemistry::Atom::DESTROY { $dead_atoms++ }
Subroutine DESTROY: called CC=1 SCAR=0.0
38 14 ▶sub Chemistry::Bond::DESTROY { $dead_bonds++ }
Subroutine DESTROY: called CC=1 SCAR=0.0
39  
« Chemistry-Mol-0.35/t/graph.t ↑ Summary Chemistry-Mol-0.35/t/safe_clone.t »