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

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

Issue 1514483003: Fix datetime test. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« 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 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
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
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 }
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