Skip to content

Commit

Permalink
Add some DateTime subclassing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Feb 20, 2016
1 parent e1449d6 commit edaa353
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion S32-temporal/DateTime.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 247;
plan 268;

my $orwell = DateTime.new(year => 1984);

Expand Down Expand Up @@ -672,3 +672,20 @@ is ds("2016-02-29T00:00:00").later(:1year), "2017-02-28T00:00:00Z",
class BarDate is DateTime does Foo {}
is BarDate.now.a, [7,8,9], 'did role attributes get initialized ok';
}

{
class FooDateTime is DateTime { has $.foo };
for (2016,2,20,21,53,7),
'2016-02-20T21:53:07',
\(:2016year,:2month,:20day,:21hour,:53minute,:7second)
-> $datetime {
my $fdt = FooDateTime.new(|$datetime, foo => 42);
is $fdt.year, 2016, "is year in FooDateTime ok";
is $fdt.month, 2, "is month in FooDateTime ok";
is $fdt.day, 20, "is day in FooDateTime ok";
is $fdt.hour, 21, "is hour in FooDateTime ok";
is $fdt.minute, 53, "is minute in FooDateTime ok";
is $fdt.second, 7, "is second in FooDateTime ok";
is $fdt.foo, 42, "is foo in FooDateTime ok";
}
}

0 comments on commit edaa353

Please sign in to comment.