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.65 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.64 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.63 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.62 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.61 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.60 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.59 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.58 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.57 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.56 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.55 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.54 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.53 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.52 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.51 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.50 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.49 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.48 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.47 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t
trackler-2.2.1.46 tracks/perl5/exercises/difference-of-squares/difference_of_squares.t