1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 12:06:26 +00:00

Revert "Fix duration.toString() to conform the description"

This reverts commit 038e981f89.

Reason for revert: Breaks some tests; visible changes to some web UIs.

Original change's description:
> Fix duration.toString() to conform the description
> 
> Duration.toString() should return in a format of "HH:MM:SS.mmmmmm".
> But when `hours` is less than 10, toString() doesn't have the leading
> zero, which is "H:MM:SS.mmmmmm".
> 
> The corresponding co19 issue: https://github.com/dart-lang/co19/issues/733
> 
> Bug: https://github.com/dart-lang/sdk/issues/41737
> Change-Id: I2264171b2b37e89056695f7f821125a5f78d87fb
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151163
> Commit-Queue: Zichang Guo <zichangguo@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>

TBR=lrn@google.com,zichangguo@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/41737
Change-Id: I4d7ef5de9807e8e2b2a77c2171d1693b7527f671
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151848
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
This commit is contained in:
David Morgan 2020-06-22 10:29:15 +00:00 committed by commit-bot@chromium.org
parent ed0eeaebca
commit 1d3fbbed7c
6 changed files with 33 additions and 40 deletions

View File

@ -4,12 +4,6 @@
### Core libraries
#### `dart:core`
* `toString()` of Class `Duration` will strictly follow the format of
`HH:MM:SS.mmmmmm`. Previously when `hours` is less than 10, it will output
a single digit `H`.
#### `dart:io`
* [#42006][]: The signature of `exit` has been changed to return the

View File

@ -1,8 +1,8 @@
ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|3724|5|94|Const constructors can't throw exceptions.
ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|7914|5|97|Const constructors can't throw exceptions.
ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|3723|5|94|Const constructors can't throw exceptions.
ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|7913|5|97|Const constructors can't throw exceptions.
ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|940|5|95|Const constructors can't throw exceptions.
ERROR|COMPILE_TIME_ERROR|CONST_CONSTRUCTOR_THROWS_EXCEPTION|lib/core/core.dart|973|5|94|Const constructors can't throw exceptions.
ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|3722|3|5|Only redirecting factory constructors can be declared to be 'const'.
ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|7912|3|5|Only redirecting factory constructors can be declared to be 'const'.
ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|3721|3|5|Only redirecting factory constructors can be declared to be 'const'.
ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|7911|3|5|Only redirecting factory constructors can be declared to be 'const'.
ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|938|3|5|Only redirecting factory constructors can be declared to be 'const'.
ERROR|SYNTACTIC_ERROR|CONST_FACTORY|lib/core/core.dart|971|3|5|Only redirecting factory constructors can be declared to be 'const'.

View File

@ -3429,7 +3429,7 @@ TEST_CASE(IsolateReload_ConstFieldUpdate) {
Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
EXPECT_VALID(lib);
EXPECT_STREQ("value=00:00:01.000000", SimpleInvokeStr(lib, "main"));
EXPECT_STREQ("value=0:00:01.000000", SimpleInvokeStr(lib, "main"));
const char* kReloadScript =
"const value = const Duration(seconds: 2);\n"
@ -3439,7 +3439,7 @@ TEST_CASE(IsolateReload_ConstFieldUpdate) {
lib = TestCase::ReloadTestScript(kReloadScript);
EXPECT_VALID(lib);
EXPECT_STREQ("value=00:00:02.000000", SimpleInvokeStr(lib, "main"));
EXPECT_STREQ("value=0:00:02.000000", SimpleInvokeStr(lib, "main"));
}
TEST_CASE(IsolateReload_RunNewFieldInitializers) {

View File

@ -264,8 +264,7 @@ class Duration implements Comparable<Duration> {
twoDigits(inSeconds.remainder(secondsPerMinute) as int);
String sixDigitUs =
sixDigits(inMicroseconds.remainder(microsecondsPerSecond) as int);
String twoDigitHours = twoDigits(inHours);
return "$twoDigitHours:$twoDigitMinutes:$twoDigitSeconds.$sixDigitUs";
return "$inHours:$twoDigitMinutes:$twoDigitSeconds.$sixDigitUs";
}
/**

View File

@ -243,43 +243,43 @@ main() {
// Regression test for http://dartbug.com/15678
d = const Duration(microseconds: 1);
Expect.equals("00:00:00.000001", d.toString());
Expect.equals("0:00:00.000001", d.toString());
d = const Duration(microseconds: 9);
Expect.equals("00:00:00.000009", d.toString());
Expect.equals("0:00:00.000009", d.toString());
d = const Duration(microseconds: 10);
Expect.equals("00:00:00.000010", d.toString());
Expect.equals("0:00:00.000010", d.toString());
d = const Duration(microseconds: 99);
Expect.equals("00:00:00.000099", d.toString());
Expect.equals("0:00:00.000099", d.toString());
d = const Duration(microseconds: 100);
Expect.equals("00:00:00.000100", d.toString());
Expect.equals("0:00:00.000100", d.toString());
d = const Duration(microseconds: 999);
Expect.equals("00:00:00.000999", d.toString());
Expect.equals("0:00:00.000999", d.toString());
d = const Duration(microseconds: 1000);
Expect.equals("00:00:00.001000", d.toString());
Expect.equals("0:00:00.001000", d.toString());
d = const Duration(microseconds: 9999);
Expect.equals("00:00:00.009999", d.toString());
Expect.equals("0:00:00.009999", d.toString());
d = const Duration(microseconds: 10000);
Expect.equals("00:00:00.010000", d.toString());
Expect.equals("0:00:00.010000", d.toString());
d = const Duration(microseconds: 99999);
Expect.equals("00:00:00.099999", d.toString());
Expect.equals("0:00:00.099999", d.toString());
d = const Duration(microseconds: 100000);
Expect.equals("00:00:00.100000", d.toString());
Expect.equals("0:00:00.100000", d.toString());
d = const Duration(microseconds: 999999);
Expect.equals("00:00:00.999999", d.toString());
Expect.equals("0:00:00.999999", d.toString());
d = const Duration(microseconds: 1000000);
Expect.equals("00:00:01.000000", d.toString());
Expect.equals("0:00:01.000000", d.toString());
d1 = const Duration(hours: 1);
d2 = const Duration(hours: -1);

View File

@ -243,43 +243,43 @@ main() {
// Regression test for http://dartbug.com/15678
d = const Duration(microseconds: 1);
Expect.equals("00:00:00.000001", d.toString());
Expect.equals("0:00:00.000001", d.toString());
d = const Duration(microseconds: 9);
Expect.equals("00:00:00.000009", d.toString());
Expect.equals("0:00:00.000009", d.toString());
d = const Duration(microseconds: 10);
Expect.equals("00:00:00.000010", d.toString());
Expect.equals("0:00:00.000010", d.toString());
d = const Duration(microseconds: 99);
Expect.equals("00:00:00.000099", d.toString());
Expect.equals("0:00:00.000099", d.toString());
d = const Duration(microseconds: 100);
Expect.equals("00:00:00.000100", d.toString());
Expect.equals("0:00:00.000100", d.toString());
d = const Duration(microseconds: 999);
Expect.equals("00:00:00.000999", d.toString());
Expect.equals("0:00:00.000999", d.toString());
d = const Duration(microseconds: 1000);
Expect.equals("00:00:00.001000", d.toString());
Expect.equals("0:00:00.001000", d.toString());
d = const Duration(microseconds: 9999);
Expect.equals("00:00:00.009999", d.toString());
Expect.equals("0:00:00.009999", d.toString());
d = const Duration(microseconds: 10000);
Expect.equals("00:00:00.010000", d.toString());
Expect.equals("0:00:00.010000", d.toString());
d = const Duration(microseconds: 99999);
Expect.equals("00:00:00.099999", d.toString());
Expect.equals("0:00:00.099999", d.toString());
d = const Duration(microseconds: 100000);
Expect.equals("00:00:00.100000", d.toString());
Expect.equals("0:00:00.100000", d.toString());
d = const Duration(microseconds: 999999);
Expect.equals("00:00:00.999999", d.toString());
Expect.equals("0:00:00.999999", d.toString());
d = const Duration(microseconds: 1000000);
Expect.equals("00:00:01.000000", d.toString());
Expect.equals("0:00:01.000000", d.toString());
d1 = const Duration(hours: 1);
d2 = const Duration(hours: -1);