Migrate test block 5 to Dart 2.0.

Unusual things in this block:
- date_time10_test.dart had no strong mode fork, and reveals what looks
like a legit DDC bug at first glance.  Excluded it for now in the status file.
- date_time_test.dart had small differences between the two forks that looked
like an error.  Fixed.

BUG=
R=bkonyi@google.com, rnystrom@google.com

Review-Url: https://codereview.chromium.org/2984063002 .
This commit is contained in:
Janice Collins 2017-07-24 14:18:53 -07:00
parent 211604d7a0
commit 998dd24dcc
22 changed files with 1 additions and 1792 deletions

View file

@ -41,6 +41,7 @@ const_list_literal_test: RuntimeError # Issue 29921
const_list_remove_range_test: RuntimeError # Issue 29921
const_list_set_range_test: RuntimeError # Issue 29921
compare_to2_test: RuntimeError # Issue 30170
date_time10_test: RuntimeError # Issue 29921
string_operations_with_null_test: RuntimeError # Issue 29921
string_replace_test: RuntimeError # Issue 29921
symbol_operator_test: RuntimeError # Issue 29921

View file

@ -1,16 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Dart test program for DateTime's hashCode.
main() {
var d = DateTime.parse("2000-01-01T00:00:00Z");
var d2 = DateTime.parse("2000-01-01T00:00:01Z");
// There is no guarantee that the hashcode for these two dates is different,
// but in the worst case we will have to fix this test.
// The important test here is, that DateTime .
Expect.isFalse(d.hashCode == d2.hashCode);
}

View file

@ -1,14 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// At some point dart was emitting a bad padding 0 for Dates where the ms were
// ending with 10.
main() {
String s = "2012-01-30 08:30:00.010";
DateTime d = DateTime.parse(s);
Expect.equals(s, d.toString());
}

View file

@ -1,104 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
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);
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(519, dt1.microsecond);
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(58, dt1.minute);
Expect.equals(59, dt1.second);
Expect.equals(999, dt1.millisecond);
Expect.equals(519, dt1.microsecond);
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(411, dt1.microsecond);
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(341, dt1.microsecond);
Expect.equals(true, dt1.isUtc);
}

View file

@ -1,81 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test DateTime constructor with optional arguments.
main() {
var d = new DateTime(2012);
Expect.equals(2012, d.year);
Expect.equals(1, d.month);
Expect.equals(1, d.day);
Expect.equals(0, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(2012, 1, 28);
Expect.equals(2012, d.year);
Expect.equals(1, d.month);
Expect.equals(28, d.day);
Expect.equals(0, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(1970, 3);
Expect.equals(1970, d.year);
Expect.equals(3, d.month);
Expect.equals(1, d.day);
Expect.equals(0, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(1970, 3, 1, 11);
Expect.equals(1970, d.year);
Expect.equals(3, d.month);
Expect.equals(1, d.day);
Expect.equals(11, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(0, 12, 24, 0, 12);
Expect.equals(0, d.year);
Expect.equals(12, d.month);
Expect.equals(24, d.day);
Expect.equals(0, d.hour);
Expect.equals(12, d.minute);
Expect.equals(0, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(-1, 2, 2, 3, 0, 0, 4);
Expect.equals(-1, d.year);
Expect.equals(2, d.month);
Expect.equals(2, d.day);
Expect.equals(3, d.hour);
Expect.equals(0, d.minute);
Expect.equals(0, d.second);
Expect.equals(4, d.millisecond);
d = new DateTime(-1, 2, 2, 3, 0, 4);
Expect.equals(-1, d.year);
Expect.equals(2, d.month);
Expect.equals(2, d.day);
Expect.equals(3, d.hour);
Expect.equals(0, d.minute);
Expect.equals(4, d.second);
Expect.equals(0, d.millisecond);
d = new DateTime(2012, 5, 15, 13, 21, 33, 12);
Expect.equals(2012, d.year);
Expect.equals(5, d.month);
Expect.equals(15, d.day);
Expect.equals(13, d.hour);
Expect.equals(21, d.minute);
Expect.equals(33, d.second);
Expect.equals(12, d.millisecond);
}

View file

@ -1,31 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test DateTime comparison operators.
main() {
var d = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
var d2 = new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true);
Expect.isTrue(d.isBefore(d2));
Expect.isTrue(!d.isAfter(d2));
Expect.isTrue(d2.isAfter(d));
Expect.isTrue(!d2.isBefore(d));
Expect.isFalse(d2.isBefore(d));
Expect.isFalse(!d2.isAfter(d));
Expect.isFalse(d.isAfter(d2));
Expect.isFalse(!d.isBefore(d2));
d = new DateTime.fromMillisecondsSinceEpoch(-1, isUtc: true);
d2 = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
Expect.isTrue(d.isBefore(d2));
Expect.isTrue(!d.isAfter(d2));
Expect.isTrue(d2.isAfter(d));
Expect.isTrue(!d2.isBefore(d));
Expect.isFalse(d2.isBefore(d));
Expect.isFalse(!d2.isAfter(d));
Expect.isFalse(d.isAfter(d2));
Expect.isFalse(!d.isBefore(d2));
}

View file

@ -1,50 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Test DateTime timeZoneName and timeZoneOffset getters.
testUtc() {
var d = DateTime.parse("2012-03-04T03:25:38.123Z");
Expect.equals("UTC", d.timeZoneName);
Expect.equals(0, d.timeZoneOffset.inSeconds);
}
testLocal() {
checkOffset(String name, Duration offset) {
// Timezone abbreviations are not in bijection with their timezones.
// For example AST stands for "Arab Standard Time" (UTC+03), as well as
// "Arabian Standard Time" (UTC+04), or PST stands for Pacific Standard Time
// and Philippine Standard Time.
//
// Hardcode some common timezones.
if (name == "CET") {
Expect.equals(1, offset.inHours);
} else if (name == "CEST") {
Expect.equals(2, offset.inHours);
} else if (name == "GMT") {
Expect.equals(0, offset.inSeconds);
} else if (name == "EST") {
Expect.equals(-5, offset.inHours);
} else if (name == "EDT") {
Expect.equals(-4, offset.inHours);
} else if (name == "PDT") {
Expect.equals(-7, offset.inHours);
}
}
var d = DateTime.parse("2012-01-02T13:45:23");
String name = d.timeZoneName;
checkOffset(name, d.timeZoneOffset);
d = DateTime.parse("2012-07-02T13:45:23");
name = d.timeZoneName;
checkOffset(name, d.timeZoneOffset);
}
main() {
testUtc();
testLocal();
}

View file

@ -1,22 +0,0 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
// Make sure the year 0 is correctly printed.
testUtc() {
var d = new DateTime.utc(0, 1, 1);
Expect.equals("0000-01-01 00:00:00.000Z", d.toString());
}
testLocal() {
var d = new DateTime(0, 1, 1);
Expect.equals("0000-01-01 00:00:00.000", d.toString());
}
main() {
testUtc();
testLocal();
}

View file

@ -1,42 +0,0 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
main() {
var dt = new DateTime.now();
Expect.isTrue(dt is Comparable);
var dt2 = new DateTime.fromMillisecondsSinceEpoch(100);
var dt3 = new DateTime.fromMillisecondsSinceEpoch(200, isUtc: true);
var dt3b = new DateTime.fromMillisecondsSinceEpoch(200);
var dt4 = new DateTime.fromMillisecondsSinceEpoch(300);
var dt5 = new DateTime.fromMillisecondsSinceEpoch(400, isUtc: true);
var dt5b = new DateTime.fromMillisecondsSinceEpoch(400);
Expect.isTrue(dt2.compareTo(dt2) == 0);
Expect.isTrue(dt3.compareTo(dt3) == 0);
Expect.isTrue(dt3b.compareTo(dt3b) == 0);
Expect.isTrue(dt4.compareTo(dt4) == 0);
Expect.isTrue(dt5.compareTo(dt5) == 0);
Expect.isTrue(dt5b.compareTo(dt5b) == 0);
// Time zones don't have any effect.
Expect.isTrue(dt3.compareTo(dt3b) == 0);
Expect.isTrue(dt5.compareTo(dt5b) == 0);
Expect.isTrue(dt2.compareTo(dt3) < 0);
Expect.isTrue(dt3.compareTo(dt4) < 0);
Expect.isTrue(dt4.compareTo(dt5) < 0);
Expect.isTrue(dt2.compareTo(dt3b) < 0);
Expect.isTrue(dt4.compareTo(dt5b) < 0);
Expect.isTrue(dt3.compareTo(dt2) > 0);
Expect.isTrue(dt4.compareTo(dt3) > 0);
Expect.isTrue(dt5.compareTo(dt4) > 0);
Expect.isTrue(dt3b.compareTo(dt2) > 0);
Expect.isTrue(dt5b.compareTo(dt4) > 0);
}

View file

@ -1,52 +0,0 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "package:expect/expect.dart";
check(DateTime expected, String str) {
DateTime actual = DateTime.parse(str);
Expect.equals(expected, actual); // Only checks if they are at the same time.
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.123456z");
} else {
check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456),
"2012-02-27 13:27:00.123z");
}
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");
check(new DateTime(2012, 02, 27), "+20120227");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14Z");
check(new DateTime.utc(-12345, 1, 1), "-123450101 00:00:00 Z");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+0000");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00:00");
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14 +00:00");
check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00+11");
check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11");
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");
}
}

File diff suppressed because it is too large Load diff