Sha256: 50c456540cf8fb85c2dd7703b464671f13f8200f392ef67348edfffd4118149a

Contents?: true

Size: 1.37 KB

Versions: 78

Compression:

Stored size: 1.37 KB

Contents

#!/usr/bin/env perl6
use v6;
use Test;
use JSON::Fast;
use lib $?FILE.IO.dirname;
use Leap;
plan 4;

my Version:D $version = v4;

if Leap.^ver !~~ $version {
  warn "\nExercise version mismatch. Further tests may fail!"
    ~ "\nLeap is {Leap.^ver.gist}. "
    ~ "Test is {$version.gist}.\n";
}

my $c-data = from-json $=pod.pop.contents;
for $c-data<cases>.values {
  given is-leap-year .<input><year> -> $result {
    subtest .<description>, {
      plan 2;
      isa-ok $result, Bool;
      is-deeply $result, .<expected>, 'Result matches expected';
    }
  }
}

=head2 Canonical Data
=begin code
{
  "exercise": "leap",
  "version": "1.3.0",
  "cases": [
    {
      "description": "year not divisible by 4: common year",
      "property": "leapYear",
      "input": {
        "year": 2015
      },
      "expected": false
    },
    {
      "description": "year divisible by 4, not divisible by 100: leap year",
      "property": "leapYear",
      "input": {
        "year": 1996
      },
      "expected": true
    },
    {
      "description": "year divisible by 100, not divisible by 400: common year",
      "property": "leapYear",
      "input": {
        "year": 2100
      },
      "expected": false
    },
    {
      "description": "year divisible by 400: leap year",
      "property": "leapYear",
      "input": {
        "year": 2000
      },
      "expected": true
    }
  ]
}
=end code

Version data entries

78 entries across 78 versions & 1 rubygems

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