| 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
| |||||||||||
| 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 | } | ||||||||||