| 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 // Identical to _MAX_MILLISECONDS_SINCE_EPOCH in date_time.dart | 9 // Identical to _MAX_MILLISECONDS_SINCE_EPOCH in date_time.dart |
| 10 const int _MAX_MILLISECONDS = 8640000000000000; | 10 const int _MAX_MILLISECONDS = 8640000000000000; |
| 11 | 11 |
| 12 // Tests if the time moves eventually forward. | 12 // Tests if the time moves eventually forward. |
| 13 void testNow() { | 13 void testNow() { |
| 14 var t1 = new DateTime.now(); | 14 var t1 = new DateTime.now(); |
| 15 bool timeMovedForward = false; | 15 bool timeMovedForward = false; |
| 16 for (int i = 0; i < 1000000; i++) { | 16 const int N = 1000000; |
| 17 var t2 = new DateTime.now(); | 17 outer: while (true) { |
| 18 if (t1.millisecondsSinceEpoch < t2.millisecondsSinceEpoch) { | 18 for (int i = N; i > 0; i--) { |
| 19 timeMovedForward = true; | 19 var t2 = new DateTime.now(); |
| 20 break; | 20 if (t1.millisecondsSinceEpoch < t2.millisecondsSinceEpoch) { |
| 21 break outer; |
| 22 } |
| 21 } | 23 } |
| 24 print("testNow: No Date.now() progress in $N loops. Time: $t1"); |
| 22 } | 25 } |
| 23 Expect.equals(true, timeMovedForward); | |
| 24 Expect.isFalse(t1.isUtc); | 26 Expect.isFalse(t1.isUtc); |
| 25 } | 27 } |
| 26 | 28 |
| 27 void testValue() { | 29 void testValue() { |
| 28 var dt1 = new DateTime.now(); | 30 var dt1 = new DateTime.now(); |
| 29 var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch; | 31 var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch; |
| 30 var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); | 32 var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); |
| 31 Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); | 33 Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); |
| 32 } | 34 } |
| 33 | 35 |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 testSubAdd(); | 964 testSubAdd(); |
| 963 testUnderflowAndOverflow(); | 965 testUnderflowAndOverflow(); |
| 964 testDateStrings(); | 966 testDateStrings(); |
| 965 testEquivalentYears(); | 967 testEquivalentYears(); |
| 966 testExtremes(); | 968 testExtremes(); |
| 967 testFarAwayDates(); | 969 testFarAwayDates(); |
| 968 testWeekday(); | 970 testWeekday(); |
| 969 testToStrings(); | 971 testToStrings(); |
| 970 testIsoString(); | 972 testIsoString(); |
| 971 } | 973 } |
| OLD | NEW |