summaryrefslogtreecommitdiff
path: root/harness
diff options
context:
space:
mode:
authorRobin Templeton <robin@igalia.com>2017-10-24 11:50:47 -0400
committerLeo Balter <leonardo.balter@gmail.com>2018-02-15 16:45:05 -0500
commit9232d65b303620da18e2fe57945275cd3b29cb22 (patch)
treed78451fe9cb6f64ded76786c09b701181f51e983 /harness
parentb59d956b3c268abd0875aeb87d6688f4c7aafc9b (diff)
downloadqtdeclarative-testsuites-9232d65b303620da18e2fe57945275cd3b29cb22.tar.gz
BigInt TypedArray tests
- add @jakobkummerow's changes - remove EOL whitespace - use 'Array.isArray' instead of 'instanceof Array' - check for BigInt type in toLocaleString tests - specify TypedArray constructor list for non-BigInt tests - update TypedArray harness test for BigInt - add a missing type coercion - disable more tests for Big(U)Int64Array - check for BigInt before using BigInt TypedArray constructors
Diffstat (limited to 'harness')
-rw-r--r--harness/testTypedArray.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js
index 2699214ca..7f777b56c 100644
--- a/harness/testTypedArray.js
+++ b/harness/testTypedArray.js
@@ -20,11 +20,22 @@ var typedArrayConstructors = [
Uint8ClampedArray
];
+var numericTypedArrayConstructors = typedArrayConstructors.slice();
+
+if (typeof BigInt !== "undefined") {
+ typedArrayConstructors.push(BigInt64Array);
+ typedArrayConstructors.push(BigUint64Array);
+}
+
/**
* The %TypedArray% intrinsic constructor function.
*/
var TypedArray = Object.getPrototypeOf(Int8Array);
+function convertToBigInt(x) {
+ return (Array.isArray(x)) ? x.map(convertToBigInt) : BigInt(x);
+}
+
/**
* Callback for testing a typed array constructor.
*
@@ -41,9 +52,14 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
function testWithTypedArrayConstructors(f, selected) {
var constructors = selected || typedArrayConstructors;
for (var i = 0; i < constructors.length; ++i) {
+ var N = function(x) { return x; };
var constructor = constructors[i];
+ if (constructor.name == "BigInt64Array" ||
+ constructor.name == "BigUint64Array") {
+ N = convertToBigInt;
+ }
try {
- f(constructor);
+ f(constructor, N);
} catch (e) {
e.message += " (Testing with " + constructor.name + ".)";
throw e;
@@ -75,5 +91,5 @@ function testTypedArrayConversions(byteConversionValues, fn) {
}
fn(TA, value, exp, initial);
});
- });
+ }, numericTypedArrayConstructors);
}