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.119 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.118 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.117 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.116 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.115 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.114 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.113 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.111 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.110 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.109 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.108 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.107 tracks/perl5/exercises/space-age/space.t
trackler-2.2.1.106 tracks/perl5/exercises/space-age/space.t