Sha256: 99942823ea6d474b7aed2a977857740f57aed23e1b9b5bb2266ffa3a484b0a8c

Contents?: true

Size: 897 Bytes

Versions: 20

Compression:

Stored size: 897 Bytes

Contents

use strict;
use warnings;

use Test::More;

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

use JSON qw(from_json);

my $cases_file = '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 "$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

20 entries across 20 versions & 1 rubygems

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