Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[DateTime.t] Added tests for RT #77910.
  • Loading branch information
Kodi Arfer authored and Kodi Arfer committed Sep 18, 2010
1 parent 6a09536 commit a32217d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion S32-temporal/DateTime.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 149;
plan 167;

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

Expand Down Expand Up @@ -437,6 +437,34 @@ is dt(timezone => 3661).offset, 3661, 'DateTime.offset (1 hour, 1 minute, 1 seco
is ~$dt, '2007-03-11T03:02:00-0700', 'DateTime.in-timezone (NYC to LAX, just after LAX DST)';
}

# --------------------------------------------------------------------
# Miscellany
# --------------------------------------------------------------------

# RT #77910
# Ensure that any method of producing a DateTime keeps attributes
# that should be Ints Ints.
{
isa_ok dt(second => 1/3).year, Int, 'DateTime.new(...).year isa Int';
isa_ok dt(second => 1/3).hour, Int, 'DateTime.new(...).hour isa Int';
isa_ok dt(hour => 13, second => 1/3).hour, Int, 'DateTime.new(..., hour => 13).hour isa Int';
isa_ok dtc(second => 1/3).year, Int, '$dt.clone(...).year isa Int';
isa_ok dtc(second => 1/3).hour, Int, '$dt.clone(...).hour isa Int';
isa_ok dtc(hour => 13, second => 1/3).hour, Int, '$dt.clone(..., hour => 13).hour isa Int';
isa_ok DateTime.new(5).year, Int, 'DateTime.new(Int).year isa Int';
isa_ok DateTime.new(5).hour, Int, 'DateTime.new(Int).hour isa Int';
isa_ok DateTime.new(now).year, Int, 'DateTime.new(Instant).year isa Int';
isa_ok DateTime.new(now).hour, Int, 'DateTime.new(Instant).hour isa Int';
isa_ok ds('2005-02-04T15:25:00Z').year, Int, 'ds(Str).year isa Int';
isa_ok ds('2005-02-04T15:25:00Z').hour, Int, 'ds(Str).hour isa Int';
isa_ok dt.in-timezone(60*60).year, Int, 'dt.in-timezone(Int).year isa Int';
isa_ok dt.in-timezone(60*60).hour, Int, 'dt.in-timezone(Int).hour isa Int';
isa_ok dt.truncated-to(:week).year, Int, 'dt.truncated-to(:week).year isa Int';
isa_ok dt.truncated-to(:week).hour, Int, 'dt.truncated-to(:week).hour isa Int';
isa_ok DateTime.now.year, Int, 'DateTime.now.year isa Int';
isa_ok DateTime.now.hour, Int, 'DateTime.now.hour isa Int';
}

done_testing;

# vim: ft=perl6

0 comments on commit a32217d

Please sign in to comment.