OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 import "package:expect/expect.dart"; | |
6 | |
7 main() { | |
8 var dt = new DateTime.now(); | |
9 Expect.isTrue(dt is Comparable); | |
10 | |
11 var dt2 = new DateTime.fromMillisecondsSinceEpoch(100); | |
12 var dt3 = new DateTime.fromMillisecondsSinceEpoch(200, isUtc: true); | |
13 var dt3b = new DateTime.fromMillisecondsSinceEpoch(200); | |
14 var dt4 = new DateTime.fromMillisecondsSinceEpoch(300); | |
15 var dt5 = new DateTime.fromMillisecondsSinceEpoch(400, isUtc: true); | |
16 var dt5b = new DateTime.fromMillisecondsSinceEpoch(400); | |
17 | |
18 Expect.isTrue(dt2.compareTo(dt2) == 0); | |
19 Expect.isTrue(dt3.compareTo(dt3) == 0); | |
20 Expect.isTrue(dt3b.compareTo(dt3b) == 0); | |
21 Expect.isTrue(dt4.compareTo(dt4) == 0); | |
22 Expect.isTrue(dt5.compareTo(dt5) == 0); | |
23 Expect.isTrue(dt5b.compareTo(dt5b) == 0); | |
24 | |
25 // Time zones don't have any effect. | |
26 Expect.isTrue(dt3.compareTo(dt3b) == 0); | |
27 Expect.isTrue(dt5.compareTo(dt5b) == 0); | |
28 | |
29 Expect.isTrue(dt2.compareTo(dt3) < 0); | |
30 Expect.isTrue(dt3.compareTo(dt4) < 0); | |
31 Expect.isTrue(dt4.compareTo(dt5) < 0); | |
32 | |
33 Expect.isTrue(dt2.compareTo(dt3b) < 0); | |
34 Expect.isTrue(dt4.compareTo(dt5b) < 0); | |
35 | |
36 Expect.isTrue(dt3.compareTo(dt2) > 0); | |
37 Expect.isTrue(dt4.compareTo(dt3) > 0); | |
38 Expect.isTrue(dt5.compareTo(dt4) > 0); | |
39 | |
40 Expect.isTrue(dt3b.compareTo(dt2) > 0); | |
41 Expect.isTrue(dt5b.compareTo(dt4) > 0); | |
42 } | |
OLD | NEW |