Sha256: 3f95e8d3baf5e627faec71b204bb14118413691b8fcaefbe418f644ee872f25b

Contents?: true

Size: 1.22 KB

Versions: 73

Compression:

Stored size: 1.22 KB

Contents

#!/usr/bin/env perl
use warnings;
use strict;

use Test::More tests => 10;
use FindBin;
my $dir;
BEGIN { $dir = $FindBin::Bin . '/' };
use lib $dir;

my $module = '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

73 entries across 73 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.179 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.178 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.177 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.176 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.175 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.174 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.173 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.172 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.171 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.170 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.169 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.167 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.166 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.165 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.164 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.163 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.162 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.161 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t
trackler-2.2.1.160 tracks/perl5/exercises/nucleotide-count/nucleotide_count.t