#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use Leap;

for Date, DateTime {
    .^method_table<new>.wrap: sub (|) {
        bail-out 'Creating a Date(Time) object is not allowed for this exercise.';
    };
}

cmp-ok( # begin: 6466b30d-519c-438e-935d-388224ab5223
    is-leap-year(2015),
    "eqv",
    False,
    "year not divisible by 4 in common year",
); # end: 6466b30d-519c-438e-935d-388224ab5223

cmp-ok( # begin: ac227e82-ee82-4a09-9eb6-4f84331ffdb0
    is-leap-year(1970),
    "eqv",
    False,
    "year divisible by 2, not divisible by 4 in common year",
); # end: ac227e82-ee82-4a09-9eb6-4f84331ffdb0

cmp-ok( # begin: 4fe9b84c-8e65-489e-970b-856d60b8b78e
    is-leap-year(1996),
    "eqv",
    True,
    "year divisible by 4, not divisible by 100 in leap year",
); # end: 4fe9b84c-8e65-489e-970b-856d60b8b78e

cmp-ok( # begin: 7fc6aed7-e63c-48f5-ae05-5fe182f60a5d
    is-leap-year(1960),
    "eqv",
    True,
    "year divisible by 4 and 5 is still a leap year",
); # end: 7fc6aed7-e63c-48f5-ae05-5fe182f60a5d

cmp-ok( # begin: 78a7848f-9667-4192-ae53-87b30c9a02dd
    is-leap-year(2100),
    "eqv",
    False,
    "year divisible by 100, not divisible by 400 in common year",
); # end: 78a7848f-9667-4192-ae53-87b30c9a02dd

cmp-ok( # begin: 9d70f938-537c-40a6-ba19-f50739ce8bac
    is-leap-year(1900),
    "eqv",
    False,
    "year divisible by 100 but not by 3 is still not a leap year",
); # end: 9d70f938-537c-40a6-ba19-f50739ce8bac

cmp-ok( # begin: 42ee56ad-d3e6-48f1-8e3f-c84078d916fc
    is-leap-year(2000),
    "eqv",
    True,
    "year divisible by 400 is leap year",
); # end: 42ee56ad-d3e6-48f1-8e3f-c84078d916fc

cmp-ok( # begin: 57902c77-6fe9-40de-8302-587b5c27121e
    is-leap-year(2400),
    "eqv",
    True,
    "year divisible by 400 but not by 125 is still a leap year",
); # end: 57902c77-6fe9-40de-8302-587b5c27121e

cmp-ok( # begin: c30331f6-f9f6-4881-ad38-8ca8c12520c1
    is-leap-year(1800),
    "eqv",
    False,
    "year divisible by 200, not divisible by 400 in common year",
); # end: c30331f6-f9f6-4881-ad38-8ca8c12520c1

done-testing;
