Sha256: 0bda8f7842ee0c1b96d00bc06cb639a5063d2816d9f339ae038f8ef253422e78

Contents?: true

Size: 1.33 KB

Versions: 303

Compression:

Stored size: 1.33 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' : 'Trinary';

my @cases = (
    {
        input    => 1,
        expected => 1,
    },
    {
        input    => 2,
        expected => 2,
    },
    {
        input    => 10,
        expected => 3,
    },
    {
        input    => 11,
        expected => 4,
    },
    {
        input    => 100,
        expected => 9,
    },
    {
        input    => 10,
        expected => 3,
    },
    {
        input    => 112,
        expected => 14,
    },
    {
        input    => 222,
        expected => 26,
    },
    {
        input    => 1122000120,
        expected => 32091,
    },
    {
        input    => "carrot",
        expected => 0,
    }
);

plan tests => 3 + @cases;

ok -e "${dir}${module}.pm", "Missing $module.pm",
        or BAIL_OUT "You need to create a file: $module.pm";

eval "use $module";

ok !$@, "Cannot load $module",
        or BAIL_OUT "Cannot load $module; Does it end with 1;?";

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

foreach my $c (@cases) {
    my $trinary = $module->new($c->{input});
    is $trinary->to_decimal, $c->{expected}, "test Trinary(" . $c->{input} . ") to_decimal(" . $c->{expected} . ")";
}

Version data entries

303 entries across 303 versions & 1 rubygems

Version Path
trackler-2.2.1.105 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.104 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.103 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.102 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.101 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.100 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.99 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.98 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.97 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.96 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.95 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.94 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.93 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.92 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.91 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.90 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.89 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.88 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.87 tracks/perl5/exercises/trinary/trinary.t
trackler-2.2.1.86 tracks/perl5/exercises/trinary/trinary.t