Chemistry-Mol-0.35/t/graph.t

filter: Statementstmt 100% 36 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 41 / 41 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/delete.t ↑ Summary Chemistry-Mol-0.35/t/mem.t »
1 1 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 # Tests for miscelaneous methods that play around with the molecular graph
4 # as a whole, such as clone, combine, and separate
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 => 11;
11  
12 1 ▶use Chemistry::File::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my $mol = Chemistry::Mol->read("t/mol.pl");
15 1 $mol->bonds(7)->delete;
16  
17 # clone test
18 1 my $mol2 = $mol->clone;
19 1 is_deeply( $mol, $mol2, "clone" );
20  
21 # separate test
22 1 my @mols = $mol->separate;
23 1 is ( scalar @mols, 2, 'got 2 things' );
24 1 is ( scalar (grep $_->isa('Chemistry::Mol'), @mols), 2, 'separate: two mols' );
25 1 is ( $mols[0]->formula, 'CClH2', 'mol 1 is CClH2' );
26 1 is ( $mols[1]->formula, 'CHO2', 'mol 2 is CHO2' );
27 1 my $a1 = $mol->atoms(2);
28 1 my $a2 = $mols[0]->atoms(2);
29 1 my $nb_before = $a1->neighbors;
30 1 my $nb_after = $a2->neighbors;
31 1 is ( $nb_after, $nb_before, "bond count for $a2 equal to $a1 ($nb_before)?" );
32  
33 # combine - new
34 1 my $comb_new = Chemistry::Mol->combine(@mols);
35 1 isa_ok($comb_new, 'Chemistry::Mol');
36 1 for my $method (qw(atoms bonds formula)) {
37 3 is ( scalar $comb_new->$method, scalar $mol->$method, "combine-new; $method" );
38 }
39  
40 # combine - in place
41 1 my $comb_inplace = $mols[0]->combine($mols[1]);
42 1 is_deeply ( $comb_inplace, $mol, "combine-in place" );
43  
44 #use Chemistry::File::SMILES; $mol->printf("%S\n");
45 #$_->printf("%f\n") for @mols;
46  
« Chemistry-Mol-0.35/t/delete.t ↑ Summary Chemistry-Mol-0.35/t/mem.t »