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.25 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.24 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.23 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.22 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.21 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.20 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.19 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.18 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.17 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.16 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.15 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.14 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.13 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.12 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.11 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.10 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.9 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.8 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.7 tracks/perl5/exercises/matrix/matrix.t
trackler-2.2.1.6 tracks/perl5/exercises/matrix/matrix.t