Sha256: f01387553ee34630952fef719cdda75903e87dbea3e0bbaf1e00b6c150e9e9d4

Contents?: true

Size: 1.73 KB

Versions: 73

Compression:

Stored size: 1.73 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 = '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

73 entries across 73 versions & 1 rubygems

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