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.139 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.138 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.137 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.136 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.135 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.134 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.133 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.132 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.131 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.130 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.129 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.128 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.127 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.126 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.125 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.124 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.123 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.122 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.121 tracks/perl6/exercises/leap/leap.t
trackler-2.2.1.120 tracks/perl6/exercises/leap/leap.t