testBigIntTypedArray.js 957 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2015 André Bargull. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. description: |
  5. Collection of functions used to assert the correctness of BigInt TypedArray objects.
  6. ---*/
  7. /**
  8. * The %TypedArray% intrinsic constructor function.
  9. */
  10. var TypedArray = Object.getPrototypeOf(Int8Array);
  11. /**
  12. * Calls the provided function for every typed array constructor.
  13. *
  14. * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
  15. */
  16. function testWithBigIntTypedArrayConstructors(f) {
  17. /**
  18. * Array containing every BigInt typed array constructor.
  19. */
  20. var constructors = [
  21. BigInt64Array,
  22. BigUint64Array
  23. ];
  24. for (var i = 0; i < constructors.length; ++i) {
  25. var constructor = constructors[i];
  26. try {
  27. f(constructor);
  28. } catch (e) {
  29. e.message += " (Testing with " + constructor.name + ".)";
  30. throw e;
  31. }
  32. }
  33. }