2018-02-09 19:39:06 +01:00
|
|
|
// Copyright (C) 2015 André Bargull. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
|
|
description: |
|
|
|
|
Collection of functions used to assert the correctness of BigInt TypedArray objects.
|
2020-05-06 21:26:38 +02:00
|
|
|
defines:
|
|
|
|
- TypedArray
|
|
|
|
- testWithBigIntTypedArrayConstructors
|
2018-02-09 19:39:06 +01:00
|
|
|
---*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The %TypedArray% intrinsic constructor function.
|
|
|
|
*/
|
2018-03-22 21:36:57 +01:00
|
|
|
var TypedArray = Object.getPrototypeOf(Int8Array);
|
2018-02-15 18:52:26 +01:00
|
|
|
|
2018-02-09 19:39:06 +01:00
|
|
|
/**
|
|
|
|
* Calls the provided function for every typed array constructor.
|
|
|
|
*
|
|
|
|
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
|
2020-05-06 21:26:38 +02:00
|
|
|
* @param {Array} selected - An optional Array with filtered typed arrays
|
2018-02-09 19:39:06 +01:00
|
|
|
*/
|
2020-05-06 21:26:38 +02:00
|
|
|
function testWithBigIntTypedArrayConstructors(f, selected) {
|
2018-02-27 20:58:56 +01:00
|
|
|
/**
|
|
|
|
* Array containing every BigInt typed array constructor.
|
|
|
|
*/
|
2020-05-06 21:26:38 +02:00
|
|
|
var constructors = selected || [
|
2018-02-27 20:58:56 +01:00
|
|
|
BigInt64Array,
|
|
|
|
BigUint64Array
|
|
|
|
];
|
|
|
|
|
2018-02-09 19:39:06 +01:00
|
|
|
for (var i = 0; i < constructors.length; ++i) {
|
|
|
|
var constructor = constructors[i];
|
|
|
|
try {
|
|
|
|
f(constructor);
|
|
|
|
} catch (e) {
|
|
|
|
e.message += " (Testing with " + constructor.name + ".)";
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|