Sha256: c5e5e596c89b280105e13079f7ff143a1c068f19d70ef124fb97ed451b60363f

Contents?: true

Size: 1.44 KB

Versions: 303

Compression:

Stored size: 1.44 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' : 'Squares';

plan tests => 15;

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, "sum_of_squares"
        or BAIL_OUT "Missing package $module; or missing sub sum_of_squares()";

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

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

is $module->new(5)->square_of_sums, 225, "square_of_sums to 5";
is $module->new(5)->sum_of_squares, 55, "sum_of_squares to 5";
is $module->new(5)->difference, 170, "difference of 5";

is $module->new(10)->square_of_sums, 3025, "square_of_sums to 10";
is $module->new(10)->sum_of_squares, 385, "sum_of_squares to 10";
is $module->new(10)->difference, 2640, "difference of 10";

is $module->new(100)->square_of_sums, 25_502_500, "square_of_sums to 100";
is $module->new(100)->sum_of_squares, 338_350, "sum_of_squares to 100";
is $module->new(100)->difference, 25_164_150, "difference of 100";

Version data entries

303 entries across 303 versions & 1 rubygems

Version Path
trackler-2.2.1.45 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.44 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.43 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.42 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.41 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.40 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.39 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.38 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.37 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.36 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.35 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.34 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.33 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.32 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.31 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.30 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.29 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.28 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.27 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.26 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t