Sha256: 6fd7d2c26f1a7428691d21bff221e055013e5c71e96d734fb3d8d7ca2fb594e3

Contents?: true

Size: 1.62 KB

Versions: 73

Compression:

Stored size: 1.62 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 = 'SpaceAge';

plan tests => 20;

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

is $module->new(1_000_000)->seconds, 1_000_000, "attribute->seconds match constructor param";
is $module->new(1_000_000_000)->on_earth, 31.69, "earth years";
is $module->new(2_134_835_688)->on_earth, 67.65, "earth years";
is $module->new(2_134_835_688)->on_mercury, 280.88, "mercury years";
is $module->new(189_839_836)->on_earth, 6.02, "earth years";
is $module->new(189_839_836)->on_venus, 9.78, "venus years";
is $module->new(2_329_871_239)->on_earth, 73.83, "earth years";
is $module->new(2_329_871_239)->on_mars, 39.25, "mars years";
is $module->new(901_876_382)->on_earth, 28.58, "earth years";
is $module->new(901_876_382)->on_jupiter, 2.41, "jupiter years";
is $module->new(3_000_000_000)->on_earth, 95.06, "earth years";
is $module->new(3_000_000_000)->on_saturn, 3.23, "saturn years";
is $module->new(3_210_123_456)->on_earth, 101.72, "earth years";
is $module->new(3_210_123_456)->on_uranus, 1.21, "uranus years";
is $module->new(8_210_123_456)->on_earth, 260.16, "earth years";
is $module->new(8_210_123_456)->on_neptune, 1.58, "neptune years";

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.179 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.178 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.177 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.176 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.175 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.174 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.173 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.172 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.171 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.170 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.169 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.167 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.166 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.165 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.164 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.163 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.162 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.161 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.160 tracks/perl5/exercises/space-age/space.t