diff --git a/tests/corelib/date_time4_test.dart b/tests/corelib/date_time4_test.dart index 4342019f8c67..06a8a3a0465e 100644 --- a/tests/corelib/date_time4_test.dart +++ b/tests/corelib/date_time4_test.dart @@ -6,60 +6,7 @@ import "package:expect/expect.dart"; // Test fromString with 6 digits after the decimal point. -bool get supportsMicroseconds => - new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; - main() { - if (supportsMicroseconds) { - testMicrosecondPrecision(); - } else { - testMillisecondPrecision(); - } -} - -void testMillisecondPrecision() { - // We only support milliseconds. If the user supplies more data (the "51" - // here), we round. - DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519"); - Expect.equals(1999, dt1.year); - Expect.equals(1, dt1.month); - Expect.equals(3, dt1.day); - Expect.equals(0, dt1.hour); - Expect.equals(0, dt1.minute); - Expect.equals(0, dt1.second); - Expect.equals(0, dt1.millisecond); - Expect.equals(false, dt1.isUtc); - dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z"); - Expect.equals(1999, dt1.year); - Expect.equals(1, dt1.month); - Expect.equals(2, dt1.day); - Expect.equals(23, dt1.hour); - Expect.equals(59, dt1.minute); - Expect.equals(0, dt1.second); - Expect.equals(0, dt1.millisecond); - Expect.equals(true, dt1.isUtc); - dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z"); - Expect.equals(9, dt1.year); - Expect.equals(9, dt1.month); - Expect.equals(9, dt1.day); - Expect.equals(9, dt1.hour); - Expect.equals(9, dt1.minute); - Expect.equals(9, dt1.second); - Expect.equals(9, dt1.millisecond); - Expect.equals(true, dt1.isUtc); - String svnDate = "2012-03-30T04:28:13.752341Z"; - dt1 = DateTime.parse(svnDate); - Expect.equals(2012, dt1.year); - Expect.equals(3, dt1.month); - Expect.equals(30, dt1.day); - Expect.equals(4, dt1.hour); - Expect.equals(28, dt1.minute); - Expect.equals(13, dt1.second); - Expect.equals(752, dt1.millisecond); - Expect.equals(true, dt1.isUtc); -} - -void testMicrosecondPrecision() { DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519"); Expect.equals(1999, dt1.year); Expect.equals(1, dt1.month); diff --git a/tests/corelib/date_time_extremes_test.dart b/tests/corelib/date_time_extremes_test.dart index ad5316fc30b8..329db67eea4e 100644 --- a/tests/corelib/date_time_extremes_test.dart +++ b/tests/corelib/date_time_extremes_test.dart @@ -6,9 +6,6 @@ import "package:expect/expect.dart"; // Dart test program for DateTime, extreme values. -bool get supportsMicroseconds => - DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; - // Identical to _maxMillisecondsSinceEpoch in date_time.dart const int _MAX_MILLISECONDS = 8640000000000000; @@ -61,8 +58,6 @@ void testExtremes() { Expect.throws( () => DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1)); - if (!supportsMicroseconds) return; - /// The nearest value to [base] in the direction [delta]. For native `int`s, /// this is just `base + delta`. For web `int`s outside the safe range, the /// next value might differ by some power of two. diff --git a/tests/corelib/date_time_far_away_dates_test.dart b/tests/corelib/date_time_far_away_dates_test.dart index 6a810f722a0b..d5ab6bb68ca3 100644 --- a/tests/corelib/date_time_far_away_dates_test.dart +++ b/tests/corelib/date_time_far_away_dates_test.dart @@ -9,9 +9,6 @@ import "package:expect/expect.dart"; // TODO(37442): Find far-away dates with milliseconds-since-epoch values that // are 'web' integers. -bool get supportsMicroseconds => - DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; - void testFarAwayDates() { DateTime dt = DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true); @@ -66,8 +63,6 @@ void testFarAwayDates() { Expect.equals(999, dt.millisecond); Expect.equals(0, dt.microsecond); - if (!supportsMicroseconds) return; - // `1000000000000000128` is a valid web number, allowing this test to be // compiled by the web compilers. dt = DateTime.fromMicrosecondsSinceEpoch(1000000000000000128, isUtc: true); diff --git a/tests/corelib/date_time_parse_test.dart b/tests/corelib/date_time_parse_test.dart index 23b8b02ddd17..4fb377b7cc9c 100644 --- a/tests/corelib/date_time_parse_test.dart +++ b/tests/corelib/date_time_parse_test.dart @@ -10,22 +10,12 @@ check(DateTime expected, String str) { Expect.equals(expected.isUtc, actual.isUtc); } -bool get supportsMicroseconds => - new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; - main() { check(new DateTime(2012, 02, 27, 13, 27), "2012-02-27 13:27:00"); - if (supportsMicroseconds) { - check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456), - "2012-02-27 13:27:00.1234567891234z"); - check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456), - "2012-02-27 13:27:00,1234567891234z"); - } else { - check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 0), - "2012-02-27 13:27:00.1234567891234z"); - check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 0), - "2012-02-27 13:27:00,1234567891234z"); - } + check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456), + "2012-02-27 13:27:00.1234567891234z"); + check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456), + "2012-02-27 13:27:00,1234567891234z"); check(new DateTime(2012, 02, 27, 13, 27), "20120227 13:27:00"); check(new DateTime(2012, 02, 27, 13, 27), "20120227T132700"); check(new DateTime(2012, 02, 27), "20120227"); @@ -42,15 +32,8 @@ main() { check( new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11:00"); - if (supportsMicroseconds) { - check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 500, 500), - "2015-02-15T00:00:00.500500Z"); - check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 511, 500), - "2015-02-15T00:00:00.511500Z"); - } else { - check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 501), - "2015-02-15T00:00:00.501Z"); - check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 512), - "2015-02-15T00:00:00.512Z"); - } + check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 500, 500), + "2015-02-15T00:00:00.500500Z"); + check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 511, 500), + "2015-02-15T00:00:00.511500Z"); } diff --git a/tests/corelib/date_time_test.dart b/tests/corelib/date_time_test.dart index 63e8136c0f30..08f8323daca1 100644 --- a/tests/corelib/date_time_test.dart +++ b/tests/corelib/date_time_test.dart @@ -6,9 +6,6 @@ import "package:expect/expect.dart"; // Dart test program for DateTime. -bool get supportsMicroseconds => - new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; - // Identical to _maxMillisecondsSinceEpoch in date_time.dart const int _MAX_MILLISECONDS = 8640000000000000; @@ -271,8 +268,6 @@ void testEquivalentYears() { Expect.equals(0, dt.microsecond); Expect.equals("2036-07-18 13:20:00.000", dt.toString()); - if (!supportsMicroseconds) return; - dt = new DateTime.utc(2035, 1, 1, 0, 0, 0, 0, 1); Expect.equals(SECONDS_YEAR_2035 * 1000000 + 1, dt.microsecondsSinceEpoch); dt = new DateTime.utc(2034, 12, 31, 23, 59, 59, 999, 999); @@ -334,8 +329,6 @@ void testUTCGetters() { Expect.equals(1, dt.millisecond); Expect.equals(0, dt.microsecond); - if (!supportsMicroseconds) return; - dt = new DateTime.fromMicrosecondsSinceEpoch(-9999999999, isUtc: true); Expect.equals(1969, dt.year); Expect.equals(12, dt.month); @@ -493,8 +486,6 @@ void testSubAdd() { Expect.equals(true, dt1 == dt3); Expect.equals(false, dt1 == dt2); - if (!supportsMicroseconds) return; - dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true); dt2 = dt1 .add(new Duration(microseconds: 3 * Duration.microsecondsPerSecond + 5)); @@ -513,8 +504,7 @@ void testSubAdd() { } void testUnderflowAndOverflow() { - int microsecond = supportsMicroseconds ? 499 : 0; - final dtBase = new DateTime(2012, 6, 20, 12, 30, 30, 500, microsecond); + final dtBase = new DateTime(2012, 6, 20, 12, 30, 30, 500, 499); // Millisecond print(" >>> Millisecond+"); @@ -719,8 +709,6 @@ void testUnderflowAndOverflow() { Expect.equals(dtBase1.millisecond, dtTick.millisecond); Expect.equals(dtBase1.microsecond, dtTick.microsecond); - if (!supportsMicroseconds) return; - // Microsecond print(" >>> Microsecond+"); dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, @@ -943,48 +931,24 @@ void testDateStrings() { Expect.equals(0, dt1.microsecond); Expect.equals(true, dt1.isUtc); dt1 = DateTime.parse("1999-01-02 23:59:59.99951"); - if (supportsMicroseconds) { - Expect.equals(1999, dt1.year); - Expect.equals(1, dt1.month); - Expect.equals(2, dt1.day); - Expect.equals(23, dt1.hour); - Expect.equals(59, dt1.minute); - Expect.equals(59, dt1.second); - Expect.equals(999, dt1.millisecond); - Expect.equals(510, dt1.microsecond); - } else { - // We only support millisecond. If the user supplies more data (the "51" - // here), we round. - Expect.equals(1999, dt1.year); - Expect.equals(1, dt1.month); - Expect.equals(3, dt1.day); - Expect.equals(0, dt1.hour); - Expect.equals(0, dt1.minute); - Expect.equals(0, dt1.second); - Expect.equals(0, dt1.millisecond); - Expect.equals(0, dt1.microsecond); - } + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(59, dt1.minute); + Expect.equals(59, dt1.second); + Expect.equals(999, dt1.millisecond); + Expect.equals(510, dt1.microsecond); Expect.equals(false, dt1.isUtc); dt1 = DateTime.parse("1999-01-02 23:58:59.99951Z"); - if (supportsMicroseconds) { - Expect.equals(1999, dt1.year); - Expect.equals(1, dt1.month); - Expect.equals(2, dt1.day); - Expect.equals(23, dt1.hour); - Expect.equals(58, dt1.minute); - Expect.equals(59, dt1.second); - Expect.equals(999, dt1.millisecond); - Expect.equals(510, dt1.microsecond); - } else { - Expect.equals(1999, dt1.year); - Expect.equals(1, dt1.month); - Expect.equals(2, dt1.day); - Expect.equals(23, dt1.hour); - Expect.equals(59, dt1.minute); - Expect.equals(0, dt1.second); - Expect.equals(0, dt1.millisecond); - Expect.equals(0, dt1.microsecond); - } + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(58, dt1.minute); + Expect.equals(59, dt1.second); + Expect.equals(999, dt1.millisecond); + Expect.equals(510, dt1.microsecond); Expect.equals(true, dt1.isUtc); dt1 = DateTime.parse("0009-09-09 09:09:09.009Z"); Expect.equals(9, dt1.year); @@ -1079,22 +1043,15 @@ void testDateStrings() { () => DateTime.parse("275760-09-14T00:00:00.000Z")); Expect.throwsFormatException( () => DateTime.parse("275760-09-13T00:00:00.001Z")); - if (supportsMicroseconds) { - Expect.throwsFormatException( - () => DateTime.parse("275760-09-13T00:00:00.000001Z")); - } else { - dt1 = DateTime.parse("275760-09-13T00:00:00.000001Z"); - } - + Expect.throwsFormatException( + () => DateTime.parse("275760-09-13T00:00:00.000001Z")); // first valid time; should not throw. dt1 = DateTime.parse("-271821-04-20T00:00:00.000Z"); Expect.throwsFormatException( () => DateTime.parse("-271821-04-19T23:59:59.999Z")); - if (supportsMicroseconds) { - Expect.throwsFormatException( - () => DateTime.parse("-271821-04-19T23:59:59.999999Z")); - } + Expect.throwsFormatException( + () => DateTime.parse("-271821-04-19T23:59:59.999999Z")); } void testWeekday() { @@ -1159,14 +1116,11 @@ void testToStrings() { test("1970-01-01", "00:00:00.000"); test("1969-12-31", "23:59:59.999"); test("1969-09-09", "00:09:09.009"); - - if (supportsMicroseconds) { - test("2000-01-01", "12:00:00.000001"); - test("-2000-01-01", "12:00:00.000001"); - test("1970-01-01", "00:00:00.000001"); - test("1969-12-31", "23:59:59.999999"); - test("1969-09-09", "00:09:09.009999"); - } + test("2000-01-01", "12:00:00.000001"); + test("-2000-01-01", "12:00:00.000001"); + test("1970-01-01", "00:00:00.000001"); + test("1969-12-31", "23:59:59.999999"); + test("1969-09-09", "00:09:09.009999"); } void testIsoString() { @@ -1188,8 +1142,6 @@ void testIsoString() { d = new DateTime.utc(-10000, 1, 1, 23, 59, 59, 999); Expect.equals("-010000-01-01T23:59:59.999Z", d.toIso8601String()); - if (!supportsMicroseconds) return; - d = new DateTime(9999, 1, 1, 23, 59, 59, 999, 999); Expect.equals("9999-01-01T23:59:59.999999", d.toIso8601String()); d = new DateTime(-9999, 1, 1, 23, 59, 59, 999, 999);