Sha256: 43cf189fc03123932089319c3fc601dd08ee372025059eabb8d66cdbc748a67e

Contents?: true

Size: 1.76 KB

Versions: 303

Compression:

Stored size: 1.76 KB

Contents

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

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

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 "${dir}${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

303 entries across 303 versions & 1 rubygems

Version Path
trackler-2.0.8.2 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.8.1 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.7.0 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.44 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.43 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.42 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.41 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.40 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.39 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.38 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.37 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.36 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.35 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.34 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.33 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.32 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.31 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.30 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.29 tracks/perl5/exercises/pig-latin/piglatin.t
trackler-2.0.6.28 tracks/perl5/exercises/pig-latin/piglatin.t