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

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

Issue 1520613002: Enable more DateTime tests on dart2js. (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 19 matching lines...) Expand all
30 } 30 }
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 // We chose a millisecondSinceEpoch that is guaranteed to fit into 53
41 // bits when expressed as microseconds. Furthermore the microsecond part
42 // is equal to 0, which means that an implementation that discards (or
43 // rounds) microseconds should yield correct results for the following
44 // test.
45 var dt1 = new DateTime.fromMillisecondsSinceEpoch(1); 40 var dt1 = new DateTime.fromMillisecondsSinceEpoch(1);
46 var microsecondsSinceEpoch = dt1.microsecondsSinceEpoch; 41 var microsecondsSinceEpoch = dt1.microsecondsSinceEpoch;
47 var dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); 42 var dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch);
48 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); 43 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch);
49 44
50 if (!supportsMicroseconds) return;
51 dt1 = new DateTime.now(); 45 dt1 = new DateTime.now();
52 microsecondsSinceEpoch = dt1.microsecondsSinceEpoch; 46 microsecondsSinceEpoch = dt1.microsecondsSinceEpoch;
53 dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); 47 dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch);
54 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); 48 Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch);
55 } 49 }
56 50
57 void testFarAwayDates() { 51 void testFarAwayDates() {
58 DateTime dt = 52 DateTime dt =
59 new DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true); 53 new DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true);
60 Expect.equals(33658, dt.year); 54 Expect.equals(33658, dt.year);
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 testSubAdd(); 1335 testSubAdd();
1342 testUnderflowAndOverflow(); 1336 testUnderflowAndOverflow();
1343 testDateStrings(); 1337 testDateStrings();
1344 testEquivalentYears(); 1338 testEquivalentYears();
1345 testExtremes(); 1339 testExtremes();
1346 testFarAwayDates(); 1340 testFarAwayDates();
1347 testWeekday(); 1341 testWeekday();
1348 testToStrings(); 1342 testToStrings();
1349 testIsoString(); 1343 testIsoString();
1350 } 1344 }
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