Sha256: 384504f283b39676fa630d17ffd2ab0e99198578eb2d53389cb00314068f2313

Contents?: true

Size: 1.2 KB

Versions: 303

Compression:

Stored size: 1.2 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' : 'Matrix';

plan tests => 11;

ok -e "${dir}${module}.pm", "Missing $module.pm" or BAIL_OUT "You need to create the 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, "rows"    or BAIL_OUT "Missing package $module; or missing sub rows()";
can_ok $module, "columns" or BAIL_OUT "Missing package $module; or missing sub columns()";

is_deeply $module->new("1 2\n10 20")->rows(0), [1, 2], "extract a row";
is_deeply $module->new("9 7\n8 6")->rows(0), [9, 7], "extract another row";
is_deeply $module->new("9 8 7\n19 18 17")->rows(1), [19, 18, 17], "extract 2nd row";
is_deeply $module->new("1 4 9\n16 25 36")->rows(1), [16, 25, 36], "extract 2nd row";
is_deeply $module->new("1 2 3\n4 5 6\n7 8 9\n8 7 6")->columns(0), [1, 4, 7, 8], "extract a column";
is_deeply $module->new("89 1903 3\n18 3 1\n9 4 800")->columns(1), [1903, 3, 4], "extract another column";

Version data entries

303 entries across 303 versions & 1 rubygems

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