summaryrefslogtreecommitdiff
path: root/harness
diff options
context:
space:
mode:
authorJosh Wolfe <jwolfe@igalia.com>2017-08-29 17:28:55 -0700
committerRick Waldron <waldron.rick@gmail.com>2017-09-08 10:15:19 -0400
commit0d9ef34510cc7851b0ac67a7cf7200eb2a97a7a8 (patch)
treee172bdba007b59df1f97698ba35a0ad3eb68bed7 /harness
parent0f3f22f6abbe9718a37a9abb5a54eb0bf6913229 (diff)
downloadqtdeclarative-testsuites-0d9ef34510cc7851b0ac67a7cf7200eb2a97a7a8.tar.gz
more separation of ToInteger from ToNumber
Diffstat (limited to 'harness')
-rw-r--r--harness/typeCoercion.js58
1 files changed, 32 insertions, 26 deletions
diff --git a/harness/typeCoercion.js b/harness/typeCoercion.js
index 504c56c3e..7c32a2c8d 100644
--- a/harness/typeCoercion.js
+++ b/harness/typeCoercion.js
@@ -7,59 +7,65 @@ description: |
---*/
function testCoercibleToIntegerZero(test) {
+ testCoercibleToNumberZero(test);
+
+ testCoercibleToIntegerFromInteger(0, test);
+
+ // NaN -> +0
+ testCoercibleToNumberNan(test);
+
+ // When toString() returns a string that parses to NaN:
+ test({});
+ test([]);
+}
+
+function testCoercibleToIntegerOne(test) {
+ testCoercibleToNumberOne(test);
+
+ testCoercibleToIntegerFromInteger(1, test);
+
+ // When toString() returns "1"
+ test([1]);
+ test(["1"]);
+}
+
+function testCoercibleToNumberZero(test) {
function testPrimitiveValue(value) {
test(value);
// ToPrimitive
testPrimitiveWrappers(value, "number", test);
}
- // ToNumber
testPrimitiveValue(null);
testPrimitiveValue(false);
testPrimitiveValue(0);
testPrimitiveValue("0");
+}
+
+function testCoercibleToNumberNan(test) {
+ function testPrimitiveValue(value) {
+ test(value);
+ // ToPrimitive
+ testPrimitiveWrappers(value, "number", test);
+ }
- // ToInteger: NaN -> +0
testPrimitiveValue(undefined);
testPrimitiveValue(NaN);
testPrimitiveValue("");
testPrimitiveValue("foo");
testPrimitiveValue("true");
-
- // ToInteger: floor(abs(number))
- testPrimitiveValue(0.9);
- testPrimitiveValue(-0);
- testPrimitiveValue(-0.9);
- testPrimitiveValue("0.9");
- testPrimitiveValue("-0");
- testPrimitiveValue("-0.9");
-
- // Non-primitive values that coerce to 0:
- // toString() returns a string that parses to NaN.
- test({});
- test([]);
}
-function testCoercibleToIntegerOne(test) {
+function testCoercibleToNumberOne(test) {
function testPrimitiveValue(value) {
test(value);
// ToPrimitive
testPrimitiveWrappers(value, "number", test);
}
- // ToNumber
testPrimitiveValue(true);
testPrimitiveValue(1);
testPrimitiveValue("1");
-
- // ToInteger: floor(abs(number))
- testPrimitiveValue(1.9);
- testPrimitiveValue("1.9");
-
- // Non-primitive values that coerce to 1:
- // toString() returns a string that parses to 1.
- test([1]);
- test(["1"]);
}
function testCoercibleToIntegerFromInteger(nominalInteger, test) {