Sha256: be1bf1b429ec6ad8009596d773c11298c461a62dd9919417b0ff782e217c7221

Contents?: true

Size: 1.66 KB

Versions: 20

Compression:

Stored size: 1.66 KB

Contents

use strict;
use warnings;

use Test::More;

my @cases = (
    {
        input    => "apple",
        expected => "appleay"
    },
    {
        input    => "pig",
        expected => "igpay"
    },
    {
        input    => "koala",
        expected => "oalakay"
    },
    {
        input    => "chair",
        expected => "airchay"
    },
    {
        input    => "queen",
        expected => "eenquay"
    },
    {
        input    => "square",
        expected => "aresquay"
    },
    {
        input    => "therapy",
        expected => "erapythay"
    },
    {
        input    => "thrush",
        expected => "ushthray"
    },
    {
        input    => "school",
        expected => "oolschay"
    },
    {
        input    => "quick fast run",
        expected => "ickquay astfay unray"
    },
    {
        input    => "yellow",
        expected => "ellowyay"
    },
    {
        input    => "yttria",
        expected => "yttriaay"
    },
    {
        input    => "xenon",
        expected => "enonxay"
    },
    {
        input    => "xray",
        expected => "xrayay"
    }
);

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

plan tests => 3 + @cases;

ok -e "$module.pm", "Missing file $module.pm",
        or BAIL_OUT "You need to create file: $module.pm";

eval "use $module";

ok !$@, "Cannot load $module.pm",
        or BAIL_OUT "Does $module.pm compile? Does it end with 1;?"; 

can_ok $module, "translate" or BAIL_OUT "Missing packge $module; or missing sub translate()";

foreach my $c ( @cases ) {
    no strict 'refs';
    my $sub = "${module}::translate";
    is $sub->($c->{input}), $c->{expected}, "translate " . $c->{input} . " to " . $c->{expected};
}

Version data entries

20 entries across 20 versions & 1 rubygems

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