Sha256: ff72e6aac4b738b261ef1d1fe3091712c23296b1cc2ea72c1fbe4a7cfcc8f4cf

Contents?: true

Size: 1005 Bytes

Versions: 303

Compression:

Stored size: 1005 Bytes

Contents

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

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

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

use JSON qw(from_json);

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 => 4 + @$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, "encode" or BAIL_OUT "Missing package $module; or missing sub encode()";
can_ok $module, "decode" or BAIL_OUT "Missing package $module; or missing sub decode()";

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

Version data entries

303 entries across 303 versions & 1 rubygems

Version Path
trackler-2.2.1.25 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.24 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.23 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.22 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.21 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.20 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.19 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.18 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.17 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.16 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.15 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.14 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.13 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.12 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.11 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.10 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.9 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.8 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.7 tracks/perl5/exercises/atbash-cipher/cipher.t
trackler-2.2.1.6 tracks/perl5/exercises/atbash-cipher/cipher.t