Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Unified Diff: tests/corelib/date_time9_test.dart

Issue 14858003: DateTime is Comparable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add more tests. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/date_time.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/date_time9_test.dart
diff --git a/tests/corelib/date_time9_test.dart b/tests/corelib/date_time9_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..40df97209f27d7f4d700f4ff926e0d348865c902
--- /dev/null
+++ b/tests/corelib/date_time9_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+main() {
+ var dt = new DateTime.now();
+ Expect.isTrue(dt is Comparable);
+
+ var dt2 = new DateTime.fromMillisecondsSinceEpoch(100);
+ var dt3 = new DateTime.fromMillisecondsSinceEpoch(200, isUtc: true);
+ var dt3b = new DateTime.fromMillisecondsSinceEpoch(200);
+ var dt4 = new DateTime.fromMillisecondsSinceEpoch(300);
+ var dt5 = new DateTime.fromMillisecondsSinceEpoch(400, isUtc: true);
+ var dt5b = new DateTime.fromMillisecondsSinceEpoch(400);
+
+ Expect.isTrue(dt2.compareTo(dt2) == 0);
+ Expect.isTrue(dt3.compareTo(dt3) == 0);
+ Expect.isTrue(dt3b.compareTo(dt3b) == 0);
+ Expect.isTrue(dt4.compareTo(dt4) == 0);
+ Expect.isTrue(dt5.compareTo(dt5) == 0);
+ Expect.isTrue(dt5b.compareTo(dt5b) == 0);
+
+ // Time zones don't have any effect.
+ Expect.isTrue(dt3.compareTo(dt3b) == 0);
+ Expect.isTrue(dt5.compareTo(dt5b) == 0);
+
+ Expect.isTrue(dt2.compareTo(dt3) < 0);
+ Expect.isTrue(dt3.compareTo(dt4) < 0);
+ Expect.isTrue(dt4.compareTo(dt5) < 0);
+
+ Expect.isTrue(dt2.compareTo(dt3b) < 0);
+ Expect.isTrue(dt4.compareTo(dt5b) < 0);
+
+ Expect.isTrue(dt3.compareTo(dt2) > 0);
+ Expect.isTrue(dt4.compareTo(dt3) > 0);
+ Expect.isTrue(dt5.compareTo(dt4) > 0);
+
+ Expect.isTrue(dt3b.compareTo(dt2) > 0);
+ Expect.isTrue(dt5b.compareTo(dt4) > 0);
+}
« no previous file with comments | « sdk/lib/core/date_time.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698