Sha256: bad771c5229470b3b5dadd35a76b19bf35fe25a02ac3b377607d2a973aa02041

Contents?: true

Size: 1.83 KB

Versions: 303

Compression:

Stored size: 1.83 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 $module = $ENV{EXERCISM} ? 'Example' : 'SecretHandshake';

plan tests => 12;

ok -e "${dir}${module}.pm", "Missing $module.pm" or BAIL_OUT "You need to create file: $module.pm";
eval "use $module";
ok !$@, "Cannot load $module" or BAIL_OUT "Cannot load $module. Does it compile? Does it end with 1;?";

can_ok $module, "new"      or BAIL_OUT "Missing package $module; or missing sub new()";
can_ok $module, "commands" or BAIL_OUT "Missing package $module; or missing sub commands()";

is_deeply $module->new(1)->commands, ["wink"], "handshake '1' is wink"
                        or diag explain $module->new(1)->commands;
is_deeply $module->new(2)->commands, ["double blink"], "handshake '2' is double blink"
                        or diag explain $module->new(2)->commands;
is_deeply $module->new(4)->commands, ["close your eyes"], "handshake '4' is close your eyes"
                        or diag explain $module->new(4)->commands;
is_deeply $module->new(8)->commands, ["jump"], "handshake '8' is jump"
                        or diag explain $module->new(8)->commands;
is_deeply $module->new(3)->commands, ["wink","double blink"], "handshake '11' is wink, double blink"
                        or diag explain $module->new(3)->commands;
is_deeply $module->new(19)->commands, ["double blink","wink"], "reverse order of handshake commands"
                        or diag explain $module->new(19)->commands;
is_deeply $module->new(31)->commands, ["jump","close your eyes","double blink","wink"], "all handshake commands in reverse"
                        or diag explain $module->new(31)->commands;
is_deeply $module->new('piggies')->commands, [], "invalid input"
                        or diag explain $module->new('piggies');

Version data entries

303 entries across 303 versions & 1 rubygems

Version Path
trackler-2.2.1.105 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.104 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.103 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.102 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.101 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.100 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.99 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.98 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.97 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.96 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.95 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.94 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.93 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.92 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.91 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.90 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.89 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.88 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.87 tracks/perl5/exercises/secret-handshake/handshake.t
trackler-2.2.1.86 tracks/perl5/exercises/secret-handshake/handshake.t