exercism-perl5

Repository for my Perl 5 Exercism exercises
git clone git://git.samirparikh.com/exercism-perl5
Log | Files | Refs | README

rna-transcription.t (1294B) - raw


      1 #!/usr/bin/env perl
      2 use Test2::V0;
      3 use JSON::PP;
      4 use constant JSON => JSON::PP->new;
      5 
      6 use FindBin qw<$Bin>;
      7 use lib $Bin, "$Bin/local/lib/perl5";
      8 
      9 use RNA qw<to_rna>;
     10 
     11 my @test_cases = do { local $/; @{ JSON->decode(<DATA>) }; };
     12 plan 7;
     13 
     14 imported_ok qw<to_rna> or bail_out;
     15 
     16 for my $case (@test_cases) {
     17   is to_rna( $case->{input}{dna} ), $case->{expected},
     18     $case->{description};
     19 }
     20 
     21 __DATA__
     22 [
     23   {
     24     "description": "Empty RNA sequence",
     25     "expected": "",
     26     "input": {
     27       "dna": ""
     28     },
     29     "property": "toRna"
     30   },
     31   {
     32     "description": "RNA complement of cytosine is guanine",
     33     "expected": "G",
     34     "input": {
     35       "dna": "C"
     36     },
     37     "property": "toRna"
     38   },
     39   {
     40     "description": "RNA complement of guanine is cytosine",
     41     "expected": "C",
     42     "input": {
     43       "dna": "G"
     44     },
     45     "property": "toRna"
     46   },
     47   {
     48     "description": "RNA complement of thymine is adenine",
     49     "expected": "A",
     50     "input": {
     51       "dna": "T"
     52     },
     53     "property": "toRna"
     54   },
     55   {
     56     "description": "RNA complement of adenine is uracil",
     57     "expected": "U",
     58     "input": {
     59       "dna": "A"
     60     },
     61     "property": "toRna"
     62   },
     63   {
     64     "description": "RNA complement",
     65     "expected": "UGCACCAGAAUU",
     66     "input": {
     67       "dna": "ACGTGGTCTTAA"
     68     },
     69     "property": "toRna"
     70   }
     71 ]