Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 41 lines (28 sloc) 1.057 kb
786d4af [t/spec] Added some tests for Instants and Durations.
Kodi authored
1 use v6;
2 use Test;
3
ea701e8 Moritz Lenz [instants-and-durations.t] test Durations with integers to avoid occasio...
moritz authored
4 plan 12;
786d4af [t/spec] Added some tests for Instants and Durations.
Kodi authored
5
6 # L<S02/Immutable types/'term now'>
7
8 {
9 my $i = now;
10 isa_ok $i, Instant, 'now returns an Instant';
11 isa_ok 5 + $i, Instant, 'Int + Instant ~~ Instant';
12 isa_ok $i - 1/3, Instant, 'Instant - Rat ~~ Instant';
13 }
14
15 isa_ok eval('now +300'), Instant, 'now is a term, not a function';
16
17 # L<S02/Immutable types/'you may not add two instants'>
18
19 {
ea701e8 Moritz Lenz [instants-and-durations.t] test Durations with integers to avoid occasio...
moritz authored
20 my $t0 = Instant.from-posix(1295002122);
21
22 my $t1 = Instant.from-posix(1303059935);
23
786d4af [t/spec] Added some tests for Instants and Durations.
Kodi authored
24 my $d = $t1 - $t0;
25
61aae6f [t/spec] More tests for Instants and Durations.
Kodi authored
26 ok $t0 < $t1, 'later Instants are greater';
786d4af [t/spec] Added some tests for Instants and Durations.
Kodi authored
27 dies_ok { $t0 + $t1 }, 'Instant + Instant is illegal';
28 isa_ok $d, Duration, 'Instant - Instant ~~ Duration';
29 ok $d ~~ Real, 'Durations are Real';
30 isa_ok $d + $t0, Instant, 'Instant + Duration ~~ Instant';
31 isa_ok $d + $t0, Instant, 'Duration + Instant ~~ Instant';
32 isa_ok $t0 - $d, Instant, 'Instant - Duration ~~ Instant';
b3ef08d Moritz Lenz get rid of .perl for Instant comparison
moritz authored
33 is $t0 + ($t1 - $t0), $t1, 'Instant A + (Instant B - Instant A) == Instant B';
786d4af [t/spec] Added some tests for Instants and Durations.
Kodi authored
34 }
35
e76dd4c Moritz Lenz s/done_testing/done/ as per recent S24 changes
moritz authored
36 done;
786d4af [t/spec] Added some tests for Instants and Durations.
Kodi authored
37
61aae6f [t/spec] More tests for Instants and Durations.
Kodi authored
38 # See S32-temporal/DateTime-Instant-Duration.t for more.
39
786d4af [t/spec] Added some tests for Instants and Durations.
Kodi authored
40 # vim: ft=perl6
Something went wrong with that request. Please try again.