Sha256: 2361dfb57f6e35ad9a2609ab38ba4478279595893d5d98326e156d4a36c01d03

Contents?: true

Size: 1.15 KB

Versions: 20

Compression:

Stored size: 1.15 KB

Contents

use warnings;
use strict;

use Test::More tests => 10;

my $module = $ENV{EXERCISM} ? 'Example' : 'NucleotideCount';

use_ok($module) or BAIL_OUT "You need to create a module called $module.pm";

sub new_dna {
  no strict 'refs';
  $module->new(@_);
}

is new_dna('')->count('A'), 0, 'empty dna string has no adenosine';

is_deeply new_dna('')->nucleotide_counts, { A => 0, T => 0, C => 0, G => 0, },
'empty dna tring has no nucleotides';

is new_dna('CCCCC')->count('C'), 5, 'repetitive cytidine gets counted';

is_deeply new_dna('GGGGGGGG')->nucleotide_counts, { A => 0, T => 0, C => 0, G => 8, },
'repititve sequence has only guanosine';

is new_dna('GGGGGTAACCCGG')->count('T'), 1, 'counts only thymidine';

for (1) {
  my $dna = new_dna('CGATTGGG');
  $dna->count('T');
  is $dna->count('T'), 2, 'counts a nucleotide only once';
}

eval { new_dna('GACT')->count('X') };
like $@, qr/invalid/i, 'validates nucleotides';

eval { new_dna('JOHNNYAPPLESEED') };
like $@, qr/invalid/i, 'validates dna';

is_deeply new_dna('AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC')->nucleotide_counts,
{ A => 20, T => 21, G => 17, C => 12, },
'counts all nucleotides';

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
trackler-2.0.0.9 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.8 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.7 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.6 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.5 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.4 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.3 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.2 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.1 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-2.0.0.0 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.4.1 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.4.0 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.3.0 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.2.1 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.2.0 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.1.2 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.1.1 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.1.0 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.0.1 tracks/perl5/nucleotide-count/nucleotide_count.t
trackler-1.0.0 tracks/perl5/nucleotide-count/nucleotide_count.t