OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Dart test program for DateTime. | 7 // Dart test program for DateTime. |
8 | 8 |
9 bool get supportsMicroseconds => | 9 bool get supportsMicroseconds => |
10 new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; | 10 new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; |
(...skipping 20 matching lines...) Expand all Loading... | |
31 | 31 |
32 void testMillisecondsSinceEpoch() { | 32 void testMillisecondsSinceEpoch() { |
33 var dt1 = new DateTime.now(); | 33 var dt1 = new DateTime.now(); |
34 var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch; | 34 var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch; |
35 var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); | 35 var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); |
36 Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); | 36 Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); |
37 } | 37 } |
38 | 38 |
39 void testMicrosecondsSinceEpoch() { | 39 void testMicrosecondsSinceEpoch() { |
40 var dt1 = new DateTime.fromMillisecondsSinceEpoch(1); | 40 var dt1 = new DateTime.fromMillisecondsSinceEpoch(1); |
41 var microsecondsSinceEpoch = dt1.millisecondsSinceEpoch; | 41 var microsecondsSinceEpoch = dt1.microsecondsSinceEpoch; |
42 var dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); | 42 var dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); |
43 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); | 43 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); |
44 | 44 |
45 if (!supportsMicroseconds) return; | 45 if (!supportsMicroseconds) return; |
Lasse Reichstein Nielsen
2015/12/09 06:11:28
Why test this here, and not above? Why test it at
floitsch
2015/12/09 06:17:55
The tests above should work for independently if m
| |
46 dt1 = new DateTime.now(); | 46 dt1 = new DateTime.now(); |
47 microsecondsSinceEpoch = dt1.millisecondsSinceEpoch; | 47 microsecondsSinceEpoch = dt1.millisecondsSinceEpoch; |
Lasse Reichstein Nielsen
2015/12/09 06:11:28
Same here?
floitsch
2015/12/09 06:17:55
argh.
Will do a follow-up CL.
| |
48 dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); | 48 dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); |
49 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); | 49 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); |
50 } | 50 } |
51 | 51 |
52 void testFarAwayDates() { | 52 void testFarAwayDates() { |
53 DateTime dt = | 53 DateTime dt = |
54 new DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true); | 54 new DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true); |
55 Expect.equals(33658, dt.year); | 55 Expect.equals(33658, dt.year); |
56 Expect.equals(9, dt.month); | 56 Expect.equals(9, dt.month); |
57 Expect.equals(27, dt.day); | 57 Expect.equals(27, dt.day); |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 testSubAdd(); | 1336 testSubAdd(); |
1337 testUnderflowAndOverflow(); | 1337 testUnderflowAndOverflow(); |
1338 testDateStrings(); | 1338 testDateStrings(); |
1339 testEquivalentYears(); | 1339 testEquivalentYears(); |
1340 testExtremes(); | 1340 testExtremes(); |
1341 testFarAwayDates(); | 1341 testFarAwayDates(); |
1342 testWeekday(); | 1342 testWeekday(); |
1343 testToStrings(); | 1343 testToStrings(); |
1344 testIsoString(); | 1344 testIsoString(); |
1345 } | 1345 } |
OLD | NEW |