Sha256: a406bfeab2e243cd19e8f8f11f426e05c809f7b6770b56e0563eef93a1ce1e80

Contents?: true

Size: 998 Bytes

Versions: 303

Compression:

Stored size: 998 Bytes

Contents

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

use Test::More;
use JSON qw(from_json);
use FindBin;
my $dir;
BEGIN { $dir = $FindBin::Bin . '/' };
use lib $dir;

my $module = $ENV{EXERCISM} ? 'Example' : 'Proverb';
my $sub = 'proverb';

my $cases_file = "${dir}cases.json";
my $cases;
if (open my $fh, '<', $cases_file) {
    local $/ = undef;
    $cases = from_json scalar <$fh>;
} else {
    die "Could not open '$cases_file' $!";
}

plan tests => 3 + @$cases;

ok -e "${dir}${module}.pm", "missing $module.pm"
    or BAIL_OUT("You need to create a class called $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, 'proverb') or BAIL_OUT("Missing package $module; or missing sub proverb()");

$sub = "${module}::proverb";

foreach my $c (@$cases) {
    no strict 'refs';
    my $expected = join "" => @{$c->{expected}};
    is $sub->($c->{param}, $c->{qualifier} || ""), $expected, $c->{name};
}

Version data entries

303 entries across 303 versions & 1 rubygems

Version Path
trackler-2.2.1.85 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.84 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.83 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.82 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.81 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.80 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.79 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.78 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.77 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.76 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.75 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.74 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.73 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.72 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.71 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.70 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.69 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.68 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.67 tracks/perl5/exercises/proverb/proverb.t
trackler-2.2.1.66 tracks/perl5/exercises/proverb/proverb.t