Chemistry-Mol-0.35/t/Formula.t

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 97.1% 34 / 35 CC 2 SCAR 3.4
CC
2
Cov
97%
BEGIN
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Chemistry-Mol-0.35/t/zlib.t ↑ Summary blib/lib/Chemistry/Pattern/Atom.pm »
1 1 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 my @lines;
3  
4 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
5 1 ▶ open F, "<", "formula_tests.txt"
Branch: 1 branch
BranchTrueFalseTotal
open F, "<", "formula_tests.txt" or die "couldn't open formula_tests.txt; $!" 1 0 1
6 or die "couldn't open formula_tests.txt; $!";
7 1 @lines = <F>;
8 1 close F;
9 1 plan tests => 5 + @lines;
10 1 ▶ use_ok('Chemistry::File::Formula');
Subroutine BEGIN: called CC=1 SCAR=0.0
11 };
12  
13 # Constructors
14 1 my $mol = Chemistry::Mol->parse("CH4O", format => "formula");
15 1 isa_ok($mol, 'Chemistry::Mol', 'parse isa mol');
16 1 ok($mol->atoms == 6, "enough atoms");
17 1 my $formula = $mol->formula("%s%d{<sub>%d</sub>}");
18 1 is($formula, "CH<sub>4</sub>O", "formula format");
19  
20 1 $mol = Chemistry::Mol->parse("1[Ph(Me)3]2", format => "formula");
21 1 my $fh = $mol->formula_hash;
22 1 is_deeply($fh, {C => 18, H => 28}, "formula hash 1[Ph(Me)3]2");
23  
24 1 for my $line (@lines) {
25 6 chomp $line;
26 6 my ($test_formula, $expected) = split /\t/, $line;
27 6 my $got = Chemistry::Mol->parse($test_formula, format => "formula")
28 ->print(format=>'formula');
29 6 is($got, $expected, "$test_formula = $expected");
30 }
« Chemistry-Mol-0.35/t/zlib.t ↑ Summary blib/lib/Chemistry/Pattern/Atom.pm »