Migrate language_2/double to NNBD.

Change-Id: I72b95b7d84847c1b7c4e89ba607dfca6d9069854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142212
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
diff --git a/tests/language/double/comparison_test.dart b/tests/language/double/comparison_test.dart
new file mode 100644
index 0000000..cf00962
--- /dev/null
+++ b/tests/language/double/comparison_test.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2011, 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.
+// Tests VM optimizing compiler negate condition for doubles (bug 5376516).
+
+loop() {
+  for (double d = 0.0; d < 1100.0; d++) {}
+  for (double d = 0.0; d <= 1100.0; d++) {}
+  for (double d = 1000.0; d > 0.0; d--) {}
+  for (double d = 1000.0; d >= 0.0; d--) {}
+}
+
+main() {
+  loop();
+  loop();
+}
diff --git a/tests/language/double/identical_test.dart b/tests/language/double/identical_test.dart
new file mode 100644
index 0000000..16b99fe
--- /dev/null
+++ b/tests/language/double/identical_test.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2018, 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() {
+  Expect.isTrue(identical(42.0, 42.0));
+  Expect.isTrue(identical(-0.0, -0.0));
+  Expect.isTrue(identical(0.0, 0.0));
+  Expect.isTrue(identical(1.234E9, 1.234E9));
+  Expect.isFalse(identical(0.0, -0.0));
+  Expect.isTrue(identical(double.nan, double.nan));
+}
diff --git a/tests/language/double/int_addition_test.dart b/tests/language/double/int_addition_test.dart
new file mode 100644
index 0000000..809fec5
--- /dev/null
+++ b/tests/language/double/int_addition_test.dart
@@ -0,0 +1,20 @@
+// 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.
+// VMOptions=--optimization-counter-threshold=10 --no-use-osr
+
+import "package:expect/expect.dart";
+
+// Test that optimized code does not silently convert integers to doubles.
+
+main() {
+  // Optimize add-op
+  for (int i = 0; i < 20; i++) {
+    addOp(1.1, 2.1);
+  }
+
+  Expect.isTrue(addOp(1.1, 2.1) is double);
+  Expect.isTrue(addOp(1, 2) is int);
+}
+
+addOp(a, b) => a + b;
diff --git a/tests/language/double/int_to_string_test.dart b/tests/language/double/int_to_string_test.dart
new file mode 100644
index 0000000..04c7ef7
--- /dev/null
+++ b/tests/language/double/int_to_string_test.dart
@@ -0,0 +1,20 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  Expect.equals("0.0", (0.0).toString());
+  Expect.equals("9.0", (9.0).toString());
+  Expect.equals("90.0", (90.0).toString());
+  Expect.equals(
+      "111111111111111110000.0", (111111111111111111111.0).toString());
+  Expect.equals("-9.0", (-9.0).toString());
+  Expect.equals("-90.0", (-90.0).toString());
+  Expect.equals(
+      "-111111111111111110000.0", (-111111111111111111111.0).toString());
+  Expect.equals("1000.0", (1000.0).toString());
+  Expect.equals("1000000000000000100.0", (1000000000000000128.0).toString());
+}
diff --git a/tests/language/double/invalid_runtime_test.dart b/tests/language/double/invalid_runtime_test.dart
new file mode 100644
index 0000000..a47bfc7
--- /dev/null
+++ b/tests/language/double/invalid_runtime_test.dart
@@ -0,0 +1,13 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, 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.
+
+// Test an invalid double format
+
+main() {
+
+  ;
+}
diff --git a/tests/language/double/invalid_test.dart b/tests/language/double/invalid_test.dart
new file mode 100644
index 0000000..dcfe3f4
--- /dev/null
+++ b/tests/language/double/invalid_test.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2017, 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.
+
+// Test an invalid double format
+
+main() {
+  3457e
+//^
+// [cfe] Numbers in exponential notation should always contain an exponent (an integer number with an optional sign).
+//    ^
+// [analyzer] SYNTACTIC_ERROR.MISSING_DIGIT
+  ;
+}
diff --git a/tests/language/double/modulo_test.dart b/tests/language/double/modulo_test.dart
new file mode 100644
index 0000000..d17bcc5
--- /dev/null
+++ b/tests/language/double/modulo_test.dart
@@ -0,0 +1,19 @@
+// 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.
+// Dart test optimization of modulo operator on Double.
+// VMOptions=--optimization-counter-threshold=10
+
+import "package:expect/expect.dart";
+
+main() {
+  double k = -0.33333;
+  double firstResPos = doMod(k, 1.0);
+  double firstResNeg = doMod(k, -1.0);
+  for (int i = 0; i < 20; i++) {
+    Expect.equals(firstResPos, doMod(k, 1.0));
+    Expect.equals(firstResNeg, doMod(k, -1.0));
+  }
+}
+
+doMod(a, b) => a % b;
diff --git a/tests/language/double/nan_comparison_test.dart b/tests/language/double/nan_comparison_test.dart
new file mode 100644
index 0000000..64eb038
--- /dev/null
+++ b/tests/language/double/nan_comparison_test.dart
@@ -0,0 +1,32 @@
+// 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.
+// Tests double comparisons with NaN in different contexts.
+// VMOptions=--optimization-counter-threshold=10
+
+import "package:expect/expect.dart";
+
+test_expr(a, b) => a != b;
+
+test_conditional(a, b) => a != b ? true : false;
+
+test_branch(a, b) {
+  if (a != b) {
+    return true;
+  }
+  return false;
+}
+
+main() {
+  Expect.equals(true, test_expr(0.5, double.nan));
+  for (var i = 0; i < 20; i++) test_expr(0.5, double.nan);
+  Expect.equals(true, test_expr(0.5, double.nan));
+
+  Expect.equals(true, test_conditional(0.5, double.nan));
+  for (var i = 0; i < 20; i++) test_conditional(0.5, double.nan);
+  Expect.equals(true, test_conditional(0.5, double.nan));
+
+  Expect.equals(true, test_branch(0.5, double.nan));
+  for (var i = 0; i < 20; i++) test_branch(0.5, double.nan);
+  Expect.equals(true, test_branch(0.5, double.nan));
+}
diff --git a/tests/language/double/to_string_as_exponential2_runtime_test.dart b/tests/language/double/to_string_as_exponential2_runtime_test.dart
new file mode 100644
index 0000000..1c0a498
--- /dev/null
+++ b/tests/language/double/to_string_as_exponential2_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  var v = 1.0;
+  Expect.throwsRangeError(() => v.toStringAsExponential(-1));
+  Expect.throwsRangeError(() => v.toStringAsExponential(21));
+
+
+
+}
diff --git a/tests/language/double/to_string_as_exponential2_test.dart b/tests/language/double/to_string_as_exponential2_test.dart
new file mode 100644
index 0000000..fbe03c4
--- /dev/null
+++ b/tests/language/double/to_string_as_exponential2_test.dart
@@ -0,0 +1,24 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  var v = 1.0;
+  Expect.throwsRangeError(() => v.toStringAsExponential(-1));
+  Expect.throwsRangeError(() => v.toStringAsExponential(21));
+  v.toStringAsExponential(1.5);
+  //                      ^^^
+  // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+  // [cfe] The argument type 'double' can't be assigned to the parameter type 'int?'.
+  v.toStringAsExponential("string");
+  //                      ^^^^^^^^
+  // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+  // [cfe] The argument type 'String' can't be assigned to the parameter type 'int?'.
+  v.toStringAsExponential("3");
+  //                      ^^^
+  // [analyzer] STATIC_WARNING.ARGUMENT_TYPE_NOT_ASSIGNABLE
+  // [cfe] The argument type 'String' can't be assigned to the parameter type 'int?'.
+}
diff --git a/tests/language/double/to_string_as_exponential3_test.dart b/tests/language/double/to_string_as_exponential3_test.dart
new file mode 100644
index 0000000..7300013
--- /dev/null
+++ b/tests/language/double/to_string_as_exponential3_test.dart
@@ -0,0 +1,12 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  Expect.equals("1.00000000000000000000e+0", (1.0).toStringAsExponential(20));
+  Expect.equals("1.00000000000000005551e-1", (0.1).toStringAsExponential(20));
+  Expect.equals(1.00000000000000005551e-1, 0.1);
+}
diff --git a/tests/language/double/to_string_as_exponential_test.dart b/tests/language/double/to_string_as_exponential_test.dart
new file mode 100644
index 0000000..e201913
--- /dev/null
+++ b/tests/language/double/to_string_as_exponential_test.dart
@@ -0,0 +1,100 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  Expect.equals("1e+0", (1.0).toStringAsExponential());
+  Expect.equals("1.1e+1", (11.0).toStringAsExponential());
+  Expect.equals("1.12e+2", (112.0).toStringAsExponential());
+  Expect.equals("1e+0", (1.0).toStringAsExponential(null));
+  Expect.equals("1.1e+1", (11.0).toStringAsExponential(null));
+  Expect.equals("1.12e+2", (112.0).toStringAsExponential(null));
+  Expect.equals("1e+0", (1.0).toStringAsExponential(0));
+  Expect.equals("1e+1", (11.0).toStringAsExponential(0));
+  Expect.equals("1e+2", (112.0).toStringAsExponential(0));
+  Expect.equals("1.0e+0", (1.0).toStringAsExponential(1));
+  Expect.equals("1.1e+1", (11.0).toStringAsExponential(1));
+  Expect.equals("1.1e+2", (112.0).toStringAsExponential(1));
+  Expect.equals("1.00e+0", (1.0).toStringAsExponential(2));
+  Expect.equals("1.10e+1", (11.0).toStringAsExponential(2));
+  Expect.equals("1.12e+2", (112.0).toStringAsExponential(2));
+  Expect.equals("1.000e+0", (1.0).toStringAsExponential(3));
+  Expect.equals("1.100e+1", (11.0).toStringAsExponential(3));
+  Expect.equals("1.120e+2", (112.0).toStringAsExponential(3));
+  Expect.equals("1e-1", (0.1).toStringAsExponential());
+  Expect.equals("1.1e-1", (0.11).toStringAsExponential());
+  Expect.equals("1.12e-1", (0.112).toStringAsExponential());
+  Expect.equals("1e-1", (0.1).toStringAsExponential(null));
+  Expect.equals("1.1e-1", (0.11).toStringAsExponential(null));
+  Expect.equals("1.12e-1", (0.112).toStringAsExponential(null));
+  Expect.equals("1e-1", (0.1).toStringAsExponential(0));
+  Expect.equals("1e-1", (0.11).toStringAsExponential(0));
+  Expect.equals("1e-1", (0.112).toStringAsExponential(0));
+  Expect.equals("1.0e-1", (0.1).toStringAsExponential(1));
+  Expect.equals("1.1e-1", (0.11).toStringAsExponential(1));
+  Expect.equals("1.1e-1", (0.112).toStringAsExponential(1));
+  Expect.equals("1.00e-1", (0.1).toStringAsExponential(2));
+  Expect.equals("1.10e-1", (0.11).toStringAsExponential(2));
+  Expect.equals("1.12e-1", (0.112).toStringAsExponential(2));
+  Expect.equals("1.000e-1", (0.1).toStringAsExponential(3));
+  Expect.equals("1.100e-1", (0.11).toStringAsExponential(3));
+  Expect.equals("1.120e-1", (0.112).toStringAsExponential(3));
+
+  Expect.equals("-0e+0", (-0.0).toStringAsExponential());
+  Expect.equals("-1e+0", (-1.0).toStringAsExponential());
+  Expect.equals("-1.1e+1", (-11.0).toStringAsExponential());
+  Expect.equals("-1.12e+2", (-112.0).toStringAsExponential());
+  Expect.equals("-0e+0", (-0.0).toStringAsExponential(null));
+  Expect.equals("-1e+0", (-1.0).toStringAsExponential(null));
+  Expect.equals("-1.1e+1", (-11.0).toStringAsExponential(null));
+  Expect.equals("-1.12e+2", (-112.0).toStringAsExponential(null));
+  Expect.equals("-1e+0", (-1.0).toStringAsExponential(0));
+  Expect.equals("-1e+1", (-11.0).toStringAsExponential(0));
+  Expect.equals("-1e+2", (-112.0).toStringAsExponential(0));
+  Expect.equals("-1.0e+0", (-1.0).toStringAsExponential(1));
+  Expect.equals("-1.1e+1", (-11.0).toStringAsExponential(1));
+  Expect.equals("-1.1e+2", (-112.0).toStringAsExponential(1));
+  Expect.equals("-1.00e+0", (-1.0).toStringAsExponential(2));
+  Expect.equals("-1.10e+1", (-11.0).toStringAsExponential(2));
+  Expect.equals("-1.12e+2", (-112.0).toStringAsExponential(2));
+  Expect.equals("-1.000e+0", (-1.0).toStringAsExponential(3));
+  Expect.equals("-1.100e+1", (-11.0).toStringAsExponential(3));
+  Expect.equals("-1.120e+2", (-112.0).toStringAsExponential(3));
+  Expect.equals("-1e-1", (-0.1).toStringAsExponential());
+  Expect.equals("-1.1e-1", (-0.11).toStringAsExponential());
+  Expect.equals("-1.12e-1", (-0.112).toStringAsExponential());
+  Expect.equals("-1e-1", (-0.1).toStringAsExponential(null));
+  Expect.equals("-1.1e-1", (-0.11).toStringAsExponential(null));
+  Expect.equals("-1.12e-1", (-0.112).toStringAsExponential(null));
+  Expect.equals("-1e-1", (-0.1).toStringAsExponential(0));
+  Expect.equals("-1e-1", (-0.11).toStringAsExponential(0));
+  Expect.equals("-1e-1", (-0.112).toStringAsExponential(0));
+  Expect.equals("-1.0e-1", (-0.1).toStringAsExponential(1));
+  Expect.equals("-1.1e-1", (-0.11).toStringAsExponential(1));
+  Expect.equals("-1.1e-1", (-0.112).toStringAsExponential(1));
+  Expect.equals("-1.00e-1", (-0.1).toStringAsExponential(2));
+  Expect.equals("-1.10e-1", (-0.11).toStringAsExponential(2));
+  Expect.equals("-1.12e-1", (-0.112).toStringAsExponential(2));
+  Expect.equals("-1.000e-1", (-0.1).toStringAsExponential(3));
+  Expect.equals("-1.100e-1", (-0.11).toStringAsExponential(3));
+  Expect.equals("-1.120e-1", (-0.112).toStringAsExponential(3));
+
+  Expect.equals("NaN", (double.nan).toStringAsExponential(2));
+  Expect.equals("Infinity", (double.infinity).toStringAsExponential(2));
+  Expect.equals("-Infinity", (-double.infinity).toStringAsExponential(2));
+  Expect.equals("1e+0", (1.0).toStringAsExponential(0));
+  Expect.equals("0e+0", (0.0).toStringAsExponential());
+  Expect.equals("0e+0", (0.0).toStringAsExponential(null));
+  Expect.equals("0.00e+0", (0.0).toStringAsExponential(2));
+  Expect.equals("1e+1", (11.2356).toStringAsExponential(0));
+  Expect.equals("1.1236e+1", (11.2356).toStringAsExponential(4));
+  Expect.equals("1.1236e-4", (0.000112356).toStringAsExponential(4));
+  Expect.equals("-1.1236e-4", (-0.000112356).toStringAsExponential(4));
+  Expect.equals("1.12356e-4", (0.000112356).toStringAsExponential());
+  Expect.equals("-1.12356e-4", (-0.000112356).toStringAsExponential());
+  Expect.equals("1.12356e-4", (0.000112356).toStringAsExponential(null));
+  Expect.equals("-1.12356e-4", (-0.000112356).toStringAsExponential(null));
+}
diff --git a/tests/language/double/to_string_as_fixed2_runtime_test.dart b/tests/language/double/to_string_as_fixed2_runtime_test.dart
new file mode 100644
index 0000000..821394f
--- /dev/null
+++ b/tests/language/double/to_string_as_fixed2_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  var v = 0.0;
+  Expect.throwsRangeError(() => v.toStringAsFixed(-1));
+  Expect.throwsRangeError(() => v.toStringAsFixed(21));
+
+
+
+}
diff --git a/tests/language/double/to_string_as_fixed_test.dart b/tests/language/double/to_string_as_fixed_test.dart
new file mode 100644
index 0000000..6e0aed2
--- /dev/null
+++ b/tests/language/double/to_string_as_fixed_test.dart
@@ -0,0 +1,104 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+class ToStringAsFixedTest {
+  static void testMain() {
+    Expect.equals("2.000", 2.0.toStringAsFixed(3));
+    Expect.equals("2.100", 2.1.toStringAsFixed(3));
+    Expect.equals("2.120", 2.12.toStringAsFixed(3));
+    Expect.equals("2.123", 2.123.toStringAsFixed(3));
+    Expect.equals("2.124", 2.1239.toStringAsFixed(3));
+    Expect.equals("NaN", (0.0 / 0.0).toStringAsFixed(3));
+    Expect.equals("Infinity", (1.0 / 0.0).toStringAsFixed(3));
+    Expect.equals("-Infinity", (-1.0 / 0.0).toStringAsFixed(3));
+    Expect.equals(
+        "1.1111111111111111e+21", 1111111111111111111111.0.toStringAsFixed(8));
+    Expect.equals("0.1", 0.1.toStringAsFixed(1));
+    Expect.equals("0.10", 0.1.toStringAsFixed(2));
+    Expect.equals("0.100", 0.1.toStringAsFixed(3));
+    Expect.equals("0.01", 0.01.toStringAsFixed(2));
+    Expect.equals("0.010", 0.01.toStringAsFixed(3));
+    Expect.equals("0.0100", 0.01.toStringAsFixed(4));
+    Expect.equals("0.00", 0.001.toStringAsFixed(2));
+    Expect.equals("0.001", 0.001.toStringAsFixed(3));
+    Expect.equals("0.0010", 0.001.toStringAsFixed(4));
+    Expect.equals("1.0000", 1.0.toStringAsFixed(4));
+    Expect.equals("1.0", 1.0.toStringAsFixed(1));
+    Expect.equals("1", 1.0.toStringAsFixed(0));
+    Expect.equals("12", 12.0.toStringAsFixed(0));
+    Expect.equals("1", 1.1.toStringAsFixed(0));
+    Expect.equals("12", 12.1.toStringAsFixed(0));
+    Expect.equals("1", 1.12.toStringAsFixed(0));
+    Expect.equals("12", 12.12.toStringAsFixed(0));
+    Expect.equals("0.0000006", 0.0000006.toStringAsFixed(7));
+    Expect.equals("0.00000006", 0.00000006.toStringAsFixed(8));
+    Expect.equals("0.000000060", 0.00000006.toStringAsFixed(9));
+    Expect.equals("0.0000000600", 0.00000006.toStringAsFixed(10));
+    Expect.equals("0", 0.0.toStringAsFixed(0));
+    Expect.equals("0.0", 0.0.toStringAsFixed(1));
+    Expect.equals("0.00", 0.0.toStringAsFixed(2));
+
+    Expect.equals("-0.1", (-0.1).toStringAsFixed(1));
+    Expect.equals("-0.10", (-0.1).toStringAsFixed(2));
+    Expect.equals("-0.100", (-0.1).toStringAsFixed(3));
+    Expect.equals("-0.01", (-0.01).toStringAsFixed(2));
+    Expect.equals("-0.010", (-0.01).toStringAsFixed(3));
+    Expect.equals("-0.0100", (-0.01).toStringAsFixed(4));
+    Expect.equals("-0.00", (-0.001).toStringAsFixed(2));
+    Expect.equals("-0.001", (-0.001).toStringAsFixed(3));
+    Expect.equals("-0.0010", (-0.001).toStringAsFixed(4));
+    Expect.equals("-1.0000", (-1.0).toStringAsFixed(4));
+    Expect.equals("-1.0", (-1.0).toStringAsFixed(1));
+    Expect.equals("-1", (-1.0).toStringAsFixed(0));
+    Expect.equals("-1", (-1.1).toStringAsFixed(0));
+    Expect.equals("-12", (-12.1).toStringAsFixed(0));
+    Expect.equals("-1", (-1.12).toStringAsFixed(0));
+    Expect.equals("-12", (-12.12).toStringAsFixed(0));
+    Expect.equals("-0.0000006", (-0.0000006).toStringAsFixed(7));
+    Expect.equals("-0.00000006", (-0.00000006).toStringAsFixed(8));
+    Expect.equals("-0.000000060", (-0.00000006).toStringAsFixed(9));
+    Expect.equals("-0.0000000600", (-0.00000006).toStringAsFixed(10));
+    Expect.equals("-0", (-0.0).toStringAsFixed(0));
+    Expect.equals("-0.0", (-0.0).toStringAsFixed(1));
+    Expect.equals("-0.00", (-0.0).toStringAsFixed(2));
+
+    Expect.equals("1000", 1000.0.toStringAsFixed(0));
+    Expect.equals("0", 0.00001.toStringAsFixed(0));
+    Expect.equals("0.00001", 0.00001.toStringAsFixed(5));
+    Expect.equals(
+        "0.00000000000000000010", 0.0000000000000000001.toStringAsFixed(20));
+    Expect.equals("0.00001000000000000", 0.00001.toStringAsFixed(17));
+    Expect.equals("1.00000000000000000", 1.0.toStringAsFixed(17));
+    Expect.equals(
+        "1000000000000000128", 1000000000000000128.0.toStringAsFixed(0));
+    Expect.equals(
+        "100000000000000128.0", 100000000000000128.0.toStringAsFixed(1));
+    Expect.equals(
+        "10000000000000128.00", 10000000000000128.0.toStringAsFixed(2));
+    Expect.equals("10000000000000128.00000000000000000000",
+        10000000000000128.0.toStringAsFixed(20));
+    Expect.equals("0", 0.0.toStringAsFixed(0));
+    Expect.equals("-42.000", (-42.0).toStringAsFixed(3));
+    Expect.equals(
+        "-1000000000000000128", (-1000000000000000128.0).toStringAsFixed(0));
+    Expect.equals("-0.00000000000000000010",
+        (-0.0000000000000000001).toStringAsFixed(20));
+    Expect.equals(
+        "0.12312312312312299889", 0.123123123123123.toStringAsFixed(20));
+    // Test that we round up even when the last digit generated is even.
+    // dtoa does not do this in its original form.
+    Expect.equals("1", 0.5.toStringAsFixed(0));
+    Expect.equals("-1", (-0.5).toStringAsFixed(0));
+    Expect.equals("1.3", 1.25.toStringAsFixed(1));
+    Expect.equals("234.2040", 234.20405.toStringAsFixed(4));
+    Expect.equals("234.2041", 234.2040506.toStringAsFixed(4));
+  }
+}
+
+main() {
+  ToStringAsFixedTest.testMain();
+}
diff --git a/tests/language/double/to_string_as_precision2_runtime_test.dart b/tests/language/double/to_string_as_precision2_runtime_test.dart
new file mode 100644
index 0000000..8831dca
--- /dev/null
+++ b/tests/language/double/to_string_as_precision2_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  var v = 0.0;
+  Expect.throwsRangeError(() => v.toStringAsPrecision(0));
+  Expect.throwsRangeError(() => v.toStringAsPrecision(22));
+
+
+
+}
diff --git a/tests/language/double/to_string_as_precision3_test.dart b/tests/language/double/to_string_as_precision3_test.dart
new file mode 100644
index 0000000..19f390ca
--- /dev/null
+++ b/tests/language/double/to_string_as_precision3_test.dart
@@ -0,0 +1,18 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  Expect.equals(
+      "0.000555000000000000046248", (0.000555).toStringAsPrecision(21));
+  Expect.equals(0.000555000000000000046248, 0.000555);
+  Expect.equals(
+      "5.54999999999999980179e-7", (0.000000555).toStringAsPrecision(21));
+  Expect.equals(5.54999999999999980179e-7, 0.000000555);
+  Expect.equals(
+      "-5.54999999999999980179e-7", (-0.000000555).toStringAsPrecision(21));
+  Expect.equals(-5.54999999999999980179e-7, -0.000000555);
+}
diff --git a/tests/language/double/to_string_as_precision_test.dart b/tests/language/double/to_string_as_precision_test.dart
new file mode 100644
index 0000000..6c048fe
--- /dev/null
+++ b/tests/language/double/to_string_as_precision_test.dart
@@ -0,0 +1,42 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  Expect.equals("NaN", (double.nan).toStringAsPrecision(1));
+  Expect.equals("Infinity", (double.infinity).toStringAsPrecision(2));
+  Expect.equals("-Infinity", (-double.infinity).toStringAsPrecision(2));
+  Expect.equals("0.000555000000000000", (0.000555).toStringAsPrecision(15));
+  Expect.equals("5.55000000000000e-7", (0.000000555).toStringAsPrecision(15));
+  Expect.equals("-5.55000000000000e-7", (-0.000000555).toStringAsPrecision(15));
+  Expect.equals("1e+8", (123456789.0).toStringAsPrecision(1));
+  Expect.equals("123456789", (123456789.0).toStringAsPrecision(9));
+  Expect.equals("1.2345679e+8", (123456789.0).toStringAsPrecision(8));
+  Expect.equals("1.234568e+8", (123456789.0).toStringAsPrecision(7));
+  Expect.equals("-1.234568e+8", (-123456789.0).toStringAsPrecision(7));
+  Expect.equals("-1.2e-9", (-.0000000012345).toStringAsPrecision(2));
+  Expect.equals("-1.2e-8", (-.000000012345).toStringAsPrecision(2));
+  Expect.equals("-1.2e-7", (-.00000012345).toStringAsPrecision(2));
+  Expect.equals("-0.0000012", (-.0000012345).toStringAsPrecision(2));
+  Expect.equals("-0.000012", (-.000012345).toStringAsPrecision(2));
+  Expect.equals("-0.00012", (-.00012345).toStringAsPrecision(2));
+  Expect.equals("-0.0012", (-.0012345).toStringAsPrecision(2));
+  Expect.equals("-0.012", (-.012345).toStringAsPrecision(2));
+  Expect.equals("-0.12", (-.12345).toStringAsPrecision(2));
+  Expect.equals("-1.2", (-1.2345).toStringAsPrecision(2));
+  Expect.equals("-12", (-12.345).toStringAsPrecision(2));
+  Expect.equals("-1.2e+2", (-123.45).toStringAsPrecision(2));
+  Expect.equals("-1.2e+3", (-1234.5).toStringAsPrecision(2));
+  Expect.equals("-1.2e+4", (-12345.0).toStringAsPrecision(2));
+  Expect.equals("-1.235e+4", (-12345.67).toStringAsPrecision(4));
+  Expect.equals("-1.234e+4", (-12344.67).toStringAsPrecision(4));
+  Expect.equals("-0.0", (-0.0).toStringAsPrecision(2));
+  Expect.equals("-0", (-0.0).toStringAsPrecision(1));
+  // Test that we round up even when the last digit generated is even.
+  // dtoa does not do this in its original form.
+  Expect.equals("1.3", 1.25.toStringAsPrecision(2));
+  Expect.equals("1.4", 1.35.toStringAsPrecision(2));
+}
diff --git a/tests/language/double/to_string_test.dart b/tests/language/double/to_string_test.dart
new file mode 100644
index 0000000..fcdafb9
--- /dev/null
+++ b/tests/language/double/to_string_test.dart
@@ -0,0 +1,56 @@
+// 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.
+// Test basic integer operations.
+
+import "package:expect/expect.dart";
+
+main() {
+  Expect.equals("NaN", (double.nan).toString());
+  Expect.equals("Infinity", (1 / 0).toString());
+  Expect.equals("-Infinity", (-1 / 0).toString());
+  Expect.equals("90.12", (90.12).toString());
+  Expect.equals("0.1", (0.1).toString());
+  Expect.equals("0.01", (0.01).toString());
+  Expect.equals("0.0123", (0.0123).toString());
+  Expect.equals(
+      "1.1111111111111111e+21", (1111111111111111111111.0).toString());
+  Expect.equals(
+      "1.1111111111111111e+22", (11111111111111111111111.0).toString());
+  Expect.equals("0.00001", (0.00001).toString());
+  Expect.equals("0.000001", (0.000001).toString());
+  Expect.equals("1e-7", (0.0000001).toString());
+  Expect.equals("1.2e-7", (0.00000012).toString());
+  Expect.equals("1.23e-7", (0.000000123).toString());
+  Expect.equals("1e-8", (0.00000001).toString());
+  Expect.equals("1.2e-8", (0.000000012).toString());
+  Expect.equals("1.23e-8", (0.0000000123).toString());
+
+  Expect.equals("-0.0", (-0.0).toString());
+  Expect.equals("-90.12", (-90.12).toString());
+  Expect.equals("-0.1", (-0.1).toString());
+  Expect.equals("-0.01", (-0.01).toString());
+  Expect.equals("-0.0123", (-0.0123).toString());
+  Expect.equals(
+      "-1.1111111111111111e+21", (-1111111111111111111111.0).toString());
+  Expect.equals(
+      "-1.1111111111111111e+22", (-11111111111111111111111.0).toString());
+  Expect.equals("-0.00001", (-0.00001).toString());
+  Expect.equals("-0.000001", (-0.000001).toString());
+  Expect.equals("-1e-7", (-0.0000001).toString());
+  Expect.equals("-1.2e-7", (-0.00000012).toString());
+  Expect.equals("-1.23e-7", (-0.000000123).toString());
+  Expect.equals("-1e-8", (-0.00000001).toString());
+  Expect.equals("-1.2e-8", (-0.000000012).toString());
+  Expect.equals("-1.23e-8", (-0.0000000123).toString());
+
+  Expect.equals("0.00001", (0.00001).toString());
+  Expect.equals("1e+21", (1000000000000000012800.0).toString());
+  Expect.equals("-1e+21", (-1000000000000000012800.0).toString());
+  Expect.equals("1e-7", (0.0000001).toString());
+  Expect.equals("-1e-7", (-0.0000001).toString());
+  Expect.equals(
+      "1.0000000000000001e+21", (1000000000000000128000.0).toString());
+  Expect.equals("0.000001", (0.000001).toString());
+  Expect.equals("1e-7", (0.0000001).toString());
+}
diff --git a/tests/language_2/double/to_string_as_fixed2_test.dart b/tests/language_2/double/to_string_as_fixed2_test.dart
index bc76e63..3040a30 100644
--- a/tests/language_2/double/to_string_as_fixed2_test.dart
+++ b/tests/language_2/double/to_string_as_fixed2_test.dart
@@ -3,6 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 // Test basic integer operations.
 
+// [NNBD non-migrated]: This test has no language/ counterpart. The static
+// errors are just redundant tests of the static type system, and the runtime
+// errors are redundant with to_string_as_fixed2_runtime_test.dart.
+
 import "package:expect/expect.dart";
 
 main() {
diff --git a/tests/language_2/double/to_string_as_precision2_test.dart b/tests/language_2/double/to_string_as_precision2_test.dart
index e69d0c9..4ce0c34 100644
--- a/tests/language_2/double/to_string_as_precision2_test.dart
+++ b/tests/language_2/double/to_string_as_precision2_test.dart
@@ -3,6 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 // Test basic integer operations.
 
+// [NNBD non-migrated]: This test has no language/ counterpart. The static
+// errors are just redundant tests of the static type system, and the runtime
+// errors are redundant with to_string_as_precision2_runtime_test.dart.
+
 import "package:expect/expect.dart";
 
 main() {