mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[tests] update to use variations.dart#jsNumbers
Replaces uses of `webNumbers` with `jsNumbers`. CoreLibraryReviewExempt: no semantic changes - only updates to use new pkg/expect variations properties Change-Id: I8072b0b1f92d37e756c211b5d0de106a59d0960b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346911 Reviewed-by: Mayank Patke <fishythefish@google.com>
This commit is contained in:
parent
ff4c387079
commit
cd83e0ccc0
|
@ -4,6 +4,7 @@
|
|||
// Dart test for testing Math.min and Math.max.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
negate(x) => -x;
|
||||
|
||||
|
@ -36,9 +37,9 @@ main() {
|
|||
var matrix = [
|
||||
-inf,
|
||||
-maxFiniteAsDouble,
|
||||
[minInt64, if (!webNumbers) minInt64AsDouble],
|
||||
if (!webNumbers) [-maxInt64, -maxFiniteAsInt],
|
||||
if (!webNumbers) -two53p1,
|
||||
[minInt64, if (!v.jsNumbers) minInt64AsDouble],
|
||||
if (!v.jsNumbers) [-maxInt64, -maxFiniteAsInt],
|
||||
if (!v.jsNumbers) -two53p1,
|
||||
[-two53, -maxExactIntAsInt, -maxExactIntAsDouble],
|
||||
-maxNonInt,
|
||||
[-maxNonIntFloorAsDouble, -maxNonIntFloorAsInt],
|
||||
|
@ -61,9 +62,9 @@ main() {
|
|||
[maxNonIntFloorAsDouble, maxNonIntFloorAsInt],
|
||||
maxNonInt,
|
||||
[two53, maxExactIntAsInt, maxExactIntAsDouble],
|
||||
if (!webNumbers) two53p1,
|
||||
[maxInt64, if (!webNumbers) maxFiniteAsInt],
|
||||
if (!webNumbers) maxInt64AsDouble,
|
||||
if (!v.jsNumbers) two53p1,
|
||||
[maxInt64, if (!v.jsNumbers) maxFiniteAsInt],
|
||||
if (!v.jsNumbers) maxInt64AsDouble,
|
||||
maxFiniteAsDouble,
|
||||
inf,
|
||||
[nan, mnan],
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
Expect.equals(0, 0.0.ceil());
|
||||
|
@ -24,7 +25,7 @@ main() {
|
|||
|
||||
Expect.equals(9007199254740991, 9007199254740991.0.ceil());
|
||||
Expect.equals(9007199254740992, 9007199254740992.0.ceil());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(1.7976931348623157e+308, double.maxFinite.ceil());
|
||||
} else {
|
||||
// Split 0x7fffffffffffffff into sum of two web numbers to avoid compilation
|
||||
|
@ -46,7 +47,7 @@ main() {
|
|||
Expect.equals(-4503599627370499, (-4503599627370499.0).ceil());
|
||||
Expect.equals(-9007199254740991, (-9007199254740991.0).ceil());
|
||||
Expect.equals(-9007199254740992, (-9007199254740992.0).ceil());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(-1.7976931348623157e+308, (-double.maxFinite).ceil());
|
||||
} else {
|
||||
Expect.equals(-9223372036854775808, (-double.maxFinite).ceil());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
Expect.equals(0, 0.0.floor());
|
||||
|
@ -24,7 +25,7 @@ main() {
|
|||
|
||||
Expect.equals(9007199254740991, 9007199254740991.0.floor());
|
||||
Expect.equals(9007199254740992, 9007199254740992.0.floor());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(1.7976931348623157e+308, double.maxFinite.floor());
|
||||
} else {
|
||||
// Split 0x7fffffffffffffff into sum of two web numbers to avoid compilation
|
||||
|
@ -46,7 +47,7 @@ main() {
|
|||
Expect.equals(-4503599627370499, (-4503599627370499.0).floor());
|
||||
Expect.equals(-9007199254740991, (-9007199254740991.0).floor());
|
||||
Expect.equals(-9007199254740992, (-9007199254740992.0).floor());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(-1.7976931348623157e+308, (-double.maxFinite).floor());
|
||||
} else {
|
||||
Expect.equals(-9223372036854775808, (-double.maxFinite).floor());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
Expect.equals(0, 0.0.round());
|
||||
|
@ -14,7 +15,7 @@ main() {
|
|||
Expect.equals(1, 0.9999999999999999.round());
|
||||
Expect.equals(1, 1.0.round());
|
||||
Expect.equals(1, 1.000000000000001.round());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(1.7976931348623157e+308, double.maxFinite.round());
|
||||
} else {
|
||||
// Split 0x7fffffffffffffff into sum of two web numbers to avoid compilation
|
||||
|
@ -29,7 +30,7 @@ main() {
|
|||
Expect.equals(-1, (-0.9999999999999999).round());
|
||||
Expect.equals(-1, (-1.0).round());
|
||||
Expect.equals(-1, (-1.000000000000001).round());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(-1.7976931348623157e+308, (-double.maxFinite).round());
|
||||
} else {
|
||||
Expect.equals(-9223372036854775808, (-double.maxFinite).round());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
Expect.equals(0, 0.0.truncate());
|
||||
|
@ -24,7 +25,7 @@ main() {
|
|||
|
||||
Expect.equals(9007199254740991, 9007199254740991.0.truncate());
|
||||
Expect.equals(9007199254740992, 9007199254740992.0.truncate());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(1.7976931348623157e+308, double.maxFinite.truncate());
|
||||
} else {
|
||||
// Split 0x7fffffffffffffff into sum of two web numbers to avoid compilation
|
||||
|
@ -46,7 +47,7 @@ main() {
|
|||
Expect.equals(-4503599627370499, (-4503599627370499.0).truncate());
|
||||
Expect.equals(-9007199254740991, (-9007199254740991.0).truncate());
|
||||
Expect.equals(-9007199254740992, (-9007199254740992.0).truncate());
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
Expect.equals(-1.7976931348623157e+308, (-double.maxFinite).truncate());
|
||||
} else {
|
||||
Expect.equals(-9223372036854775808, (-double.maxFinite).truncate());
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
library hash_map2_test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
import 'dart:collection';
|
||||
import 'dart:math' as math;
|
||||
|
||||
|
@ -315,7 +316,7 @@ void testIdentitySet(Set create()) {
|
|||
testIdentitySet
|
||||
];
|
||||
set.addAll(constants);
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
// 0.0 and -0.0 are identical in JS.
|
||||
Expect.equals(constants.length - 1, set.length);
|
||||
Expect.isTrue(
|
||||
|
@ -327,7 +328,7 @@ void testIdentitySet(Set create()) {
|
|||
}
|
||||
for (var c in constants) {
|
||||
// identical(double.nan, double.nan) == false in JS.
|
||||
if (webNumbers && c is double && c.isNaN) continue;
|
||||
if (v.jsNumbers && c is double && c.isNaN) continue;
|
||||
Expect.isTrue(set.contains(c), "constant: $c");
|
||||
}
|
||||
set.clear();
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
import "dart:math" show pow, log;
|
||||
|
||||
void main() {
|
||||
final String oneByteWhiteSpace = webNumbers
|
||||
final String oneByteWhiteSpace = v.jsNumbers
|
||||
? "\x09\x0a\x0b\x0c\x0d\x20\xa0"
|
||||
: "\x09\x0a\x0b\x0c\x0d\x20\x85\xa0";
|
||||
final String whiteSpace = "$oneByteWhiteSpace\u1680"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
/// Test that converting [value] to a string gives [expect].
|
||||
|
@ -52,7 +53,7 @@ main() {
|
|||
test(0x1fffffffffffff, "9007199254740991");
|
||||
test(0x20000000000000, "9007199254740992");
|
||||
// Split literals into sum of two web numbers to avoid compilation errors.
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
// The String for large integral web numbers (doubles) could be any sequence
|
||||
// of digits that parse back to the same value. The algorithm chooses 'nice'
|
||||
// rounded numbers rather than the equivalent digits for some multiple of a
|
||||
|
@ -88,7 +89,7 @@ main() {
|
|||
// Numbers 99..99, 100...00, and 100..01 up to 18 digits.
|
||||
for (int i = 1; i < 19; i++) {
|
||||
// Works in dart2js up to 10^15.
|
||||
if (webNumbers && i > 15) break;
|
||||
if (v.jsNumbers && i > 15) break;
|
||||
test(number - 1, "9" * i);
|
||||
test(number, "1" + "0" * i);
|
||||
test(number + 1, "1" + "0" * (i - 1) + "1");
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
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));
|
||||
if (!webNumbers) {
|
||||
if (!v.jsNumbers) {
|
||||
Expect.isFalse(identical(0.0, -0.0));
|
||||
Expect.isTrue(identical(double.nan, double.nan));
|
||||
} else {
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
// Test basic integer operations.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
if (!webNumbers) {
|
||||
if (!v.jsNumbers) {
|
||||
Expect.equals("0.0", (0.0).toString());
|
||||
Expect.equals("9.0", (9.0).toString());
|
||||
Expect.equals("90.0", (90.0).toString());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
var myIdentical = identical;
|
||||
|
||||
|
@ -10,7 +11,7 @@ main() {
|
|||
// Mint (2^63).
|
||||
Expect.isTrue(myIdentical(0x8000000000000000, 0x8000000000000000));
|
||||
|
||||
if (!webNumbers) {
|
||||
if (!v.jsNumbers) {
|
||||
Expect.isFalse(myIdentical(0x8000000000000000, 0x8000000000000000 + 1));
|
||||
|
||||
// Different types.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
double uint64toDouble(int i) {
|
||||
var buffer = new Uint8List(8).buffer;
|
||||
|
@ -20,7 +21,7 @@ double createOtherNAN() {
|
|||
}
|
||||
|
||||
main() {
|
||||
if (webNumbers) {
|
||||
if (v.jsNumbers) {
|
||||
// (1) The web compilers elect to generate smaller, faster code for
|
||||
// `identical` using `===`, with the result that `identical(NaN, NaN)` is
|
||||
// false.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
library NumbersTest.dart;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
class NumbersTest {
|
||||
static double testMain() {
|
||||
|
@ -13,18 +14,18 @@ class NumbersTest {
|
|||
Expect.equals(true, one is Object);
|
||||
Expect.equals(true, one is num);
|
||||
Expect.equals(true, one is int);
|
||||
Expect.equals(webNumbers, one is double);
|
||||
Expect.equals(v.jsNumbers, one is double);
|
||||
|
||||
var two = 2.0;
|
||||
Expect.equals(true, two is Object);
|
||||
Expect.equals(true, two is num);
|
||||
Expect.equals(webNumbers, two is int);
|
||||
Expect.equals(v.jsNumbers, two is int);
|
||||
Expect.equals(true, two is double);
|
||||
|
||||
var result = one + two;
|
||||
Expect.equals(true, result is Object);
|
||||
Expect.equals(true, result is num);
|
||||
Expect.equals(webNumbers, result is int);
|
||||
Expect.equals(v.jsNumbers, result is int);
|
||||
Expect.equals(true, result is double);
|
||||
|
||||
Expect.equals(3.0, result);
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
for (int i = 0; i < 80; i++) {
|
||||
var a = -1 << i;
|
||||
// web shifts produce a 32-bit unsigned result. Make it signed.
|
||||
if (webNumbers) a = a.toSigned(32);
|
||||
if (v.jsNumbers) a = a.toSigned(32);
|
||||
var b = -1;
|
||||
Expect.equals(1 << i, a ~/ b);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// VMOptions=--optimization-counter-threshold=10 --no-use-osr --no-background-compilation
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
main() {
|
||||
// Prime IC cache.
|
||||
|
@ -14,7 +15,7 @@ main() {
|
|||
Expect.equals(i % 256, foo(i));
|
||||
Expect.equals(i % -256, boo(i));
|
||||
|
||||
if (!webNumbers) {
|
||||
if (!v.jsNumbers) {
|
||||
Expect.throws(() => hoo(i), (e) => e is UnsupportedError);
|
||||
} else {
|
||||
// web numbers can't distinguish doubles from ints, so `i % 0`, which
|
||||
|
@ -42,7 +43,7 @@ main() {
|
|||
Expect.equals(i ~/ i + i % i, fooTwo2(i));
|
||||
}
|
||||
}
|
||||
if (!webNumbers) {
|
||||
if (!v.jsNumbers) {
|
||||
Expect.throws(() => foo2(0), (e) => e is UnsupportedError);
|
||||
} else {
|
||||
// web numbers can't distinguish doubles from ints, so `0 % 0`, which should
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
// VMOptions=--optimization-counter-threshold=10 --no-use-osr
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'package:expect/variations.dart' as v;
|
||||
|
||||
import "truncdiv_test.dart" as truncdiv_test show foo, foo2;
|
||||
|
||||
main() {
|
||||
if (!webNumbers) {
|
||||
if (!v.jsNumbers) {
|
||||
Expect.throws<UnsupportedError>(() => truncdiv_test.foo(12, 0));
|
||||
} else {
|
||||
// Web numbers consider infinities to be large-magnitide 'int' values.
|
||||
|
|
Loading…
Reference in a new issue