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

Side by Side Diff: tests/corelib/date_time_test.dart

Issue 759753010: Fix date_time_test to not assume a particular slowness of running code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 while (true) {
17 var t2 = new DateTime.now(); 17 var t2 = new DateTime.now();
ricow1 2014/12/03 06:55:46 I would add a count, and print to stdout for every
Lasse Reichstein Nielsen 2014/12/03 07:14:47 Done.
18 if (t1.millisecondsSinceEpoch < t2.millisecondsSinceEpoch) { 18 if (t1.millisecondsSinceEpoch < t2.millisecondsSinceEpoch) {
19 timeMovedForward = true;
20 break; 19 break;
21 } 20 }
22 } 21 }
23 Expect.equals(true, timeMovedForward);
24 Expect.isFalse(t1.isUtc); 22 Expect.isFalse(t1.isUtc);
25 } 23 }
26 24
27 void testValue() { 25 void testValue() {
28 var dt1 = new DateTime.now(); 26 var dt1 = new DateTime.now();
29 var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch; 27 var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch;
30 var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); 28 var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
31 Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); 29 Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch);
32 } 30 }
33 31
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 testSubAdd(); 960 testSubAdd();
963 testUnderflowAndOverflow(); 961 testUnderflowAndOverflow();
964 testDateStrings(); 962 testDateStrings();
965 testEquivalentYears(); 963 testEquivalentYears();
966 testExtremes(); 964 testExtremes();
967 testFarAwayDates(); 965 testFarAwayDates();
968 testWeekday(); 966 testWeekday();
969 testToStrings(); 967 testToStrings();
970 testIsoString(); 968 testIsoString();
971 } 969 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698