1 // GENERATED, DO NOT EDIT
2 // file: byteConversionValues.js
3 // Copyright (C) 2016 the V8 project authors. All rights reserved.
4 // This code is governed by the BSD license found in the LICENSE file.
7 Provide a list for original and expected values for different byte
9 This helper is mostly used on tests for TypedArray and DataView, and each
10 array from the expected values must match the original values array on every
11 index containing its original value.
12 defines: [byteConversionValues]
14 var byteConversionValues = {
20 2147483647, // 2 ** 31 - 1
21 2147483648, // 2 ** 31
26 4294967295, // 2 ** 32 - 1
27 4294967296, // 2 ** 32
28 9007199254740991, // 2 ** 53 - 1
29 9007199254740992, // 2 ** 53
42 -127, // - ( 2 ** 7 - 1 )
44 -32767, // - ( 2 ** 15 - 1 )
45 -32768, // - ( 2 ** 15 )
46 -2147483647, // - ( 2 ** 31 - 1 )
47 -2147483648, // - ( 2 ** 31 )
48 -255, // - ( 2 ** 8 - 1 )
50 -65535, // - ( 2 ** 16 - 1 )
51 -65536, // - ( 2 ** 16 )
52 -4294967295, // - ( 2 ** 32 - 1 )
53 -4294967296, // - ( 2 ** 32 )
57 2049, // an integer which rounds down under ties-to-even when cast to float16
58 2051, // an integer which rounds up under ties-to-even when cast to float16
59 0.00006103515625, // smallest normal float16
60 0.00006097555160522461, // largest subnormal float16
61 5.960464477539063e-8, // smallest float16
62 2.9802322387695312e-8, // largest double which rounds to 0 when cast to float16
63 2.980232238769532e-8, // smallest double which does not round to 0 when cast to float16
64 8.940696716308594e-8, // a double which rounds up to a subnormal under ties-to-even when cast to float16
65 1.4901161193847656e-7, // a double which rounds down to a subnormal under ties-to-even when cast to float16
66 1.490116119384766e-7, // the next double above the one on the previous line one
67 65504, // max finite float16
68 65520, // smallest double which rounds to infinity when cast to float16
69 65519.99999999999, // largest double which does not round to infinity when cast to float16
70 0.000061005353927612305, // smallest double which rounds to a non-subnormal when cast to float16
71 0.0000610053539276123 // largest double which rounds to a subnormal when cast to float16
88 -1, // 9007199254740991
89 0, // 9007199254740992
119 0, // 0.00006103515625
120 0, // 0.00006097555160522461
121 0, // 5.960464477539063e-8
122 0, // 2.9802322387695312e-8
123 0, // 2.980232238769532e-8
124 0, // 8.940696716308594e-8
125 0, // 1.4901161193847656e-7
126 0, // 1.490116119384766e-7
129 -17, // 65519.99999999999
130 0, // 0.000061005353927612305
131 0 // 0.0000610053539276123
146 255, // 9007199254740991
147 0, // 9007199254740992
177 0, // 0.00006103515625
178 0, // 0.00006097555160522461
179 0, // 5.960464477539063e-8
180 0, // 2.9802322387695312e-8
181 0, // 2.980232238769532e-8
182 0, // 8.940696716308594e-8
183 0, // 1.4901161193847656e-7
184 0, // 1.490116119384766e-7
187 239, // 65519.99999999999
188 0, // 0.000061005353927612305
189 0 // 0.0000610053539276123
204 255, // 9007199254740991
205 255, // 9007199254740992
235 0, // 0.00006103515625
236 0, // 0.00006097555160522461
237 0, // 5.960464477539063e-8
238 0, // 2.9802322387695312e-8
239 0, // 2.980232238769532e-8
240 0, // 8.940696716308594e-8
241 0, // 1.4901161193847656e-7
242 0, // 1.490116119384766e-7
245 255, // 65519.99999999999
246 0, // 0.000061005353927612305
247 0 // 0.0000610053539276123
262 -1, // 9007199254740991
263 0, // 9007199254740992
293 0, // 0.00006103515625
294 0, // 0.00006097555160522461
295 0, // 5.960464477539063e-8
296 0, // 2.9802322387695312e-8
297 0, // 2.980232238769532e-8
298 0, // 8.940696716308594e-8
299 0, // 1.4901161193847656e-7
300 0, // 1.490116119384766e-7
303 -17, // 65519.99999999999
304 0, // 0.000061005353927612305
305 0 // 0.0000610053539276123
320 65535, // 9007199254740991
321 0, // 9007199254740992
351 0, // 0.00006103515625
352 0, // 0.00006097555160522461
353 0, // 5.960464477539063e-8
354 0, // 2.9802322387695312e-8
355 0, // 2.980232238769532e-8
356 0, // 8.940696716308594e-8
357 0, // 1.4901161193847656e-7
358 0, // 1.490116119384766e-7
361 65519, // 65519.99999999999
362 0, // 0.000061005353927612305
363 0 // 0.0000610053539276123
370 2147483647, // 2147483647
371 -2147483648, // 2147483648
378 -1, // 9007199254740991
379 0, // 9007199254740992
396 -2147483647, // -2147483647
397 -2147483648, // -2147483648
409 0, // 0.00006103515625
410 0, // 0.00006097555160522461
411 0, // 5.960464477539063e-8
412 0, // 2.9802322387695312e-8
413 0, // 2.980232238769532e-8
414 0, // 8.940696716308594e-8
415 0, // 1.4901161193847656e-7
416 0, // 1.490116119384766e-7
419 65519, // 65519.99999999999
420 0, // 0.000061005353927612305
421 0 // 0.0000610053539276123
428 2147483647, // 2147483647
429 2147483648, // 2147483648
434 4294967295, // 4294967295
436 4294967295, // 9007199254740991
437 0, // 9007199254740992
452 4294934529, // -32767
453 4294934528, // -32768
454 2147483649, // -2147483647
455 2147483648, // -2147483648
458 4294901761, // -65535
459 4294901760, // -65536
467 0, // 0.00006103515625
468 0, // 0.00006097555160522461
469 0, // 5.960464477539063e-8
470 0, // 2.9802322387695312e-8
471 0, // 2.980232238769532e-8
472 0, // 8.940696716308594e-8
473 0, // 1.4901161193847656e-7
474 0, // 1.490116119384766e-7
477 65519, // 65519.99999999999
478 0, // 0.000061005353927612305
479 0 // 0.0000610053539276123
486 Infinity, // 2147483647
487 Infinity, // 2147483648
492 Infinity, // 4294967295
493 Infinity, // 4294967296
494 Infinity, // 9007199254740991
495 Infinity, // 9007199254740992
497 0.0999755859375, // 0.1
500 0.60009765625, // 0.6
505 -0.0999755859375, // -0.1
506 -1.099609375, // -1.1
512 -Infinity, // -2147483647
513 -Infinity, // -2147483648
518 -Infinity, // -4294967295
519 -Infinity, // -4294967296
520 Infinity, // Infinity
521 -Infinity, // -Infinity
525 0.00006103515625, // 0.00006103515625
526 0.00006097555160522461, // 0.00006097555160522461
527 5.960464477539063e-8, // 5.960464477539063e-8
528 0, // 2.9802322387695312e-8
529 5.960464477539063e-8, // 2.980232238769532e-8
530 1.1920928955078125e-7, // 8.940696716308594e-8
531 1.1920928955078125e-7, // 1.4901161193847656e-7
532 1.7881393432617188e-7, // 1.490116119384766e-7
535 65504, // 65519.99999999999
536 0.00006103515625, // 0.000061005353927612305
537 0.00006097555160522461 // 0.0000610053539276123
544 2147483648, // 2147483647
545 2147483648, // 2147483648
550 4294967296, // 4294967295
551 4294967296, // 4294967296
552 9007199254740992, // 9007199254740991
553 9007199254740992, // 9007199254740992
554 1.100000023841858, // 1.1
555 0.10000000149011612, // 0.1
558 0.6000000238418579, // 0.6
559 0.699999988079071, // 0.7
563 -0.10000000149011612, // -0.1
564 -1.100000023841858, // -1.1
570 -2147483648, // -2147483647
571 -2147483648, // -2147483648
576 -4294967296, // -4294967295
577 -4294967296, // -4294967296
578 Infinity, // Infinity
579 -Infinity, // -Infinity
583 0.00006103515625, // 0.00006103515625
584 0.00006097555160522461, // 0.00006097555160522461
585 5.960464477539063e-8, // 5.960464477539063e-8
586 2.9802322387695312e-8, // 2.9802322387695312e-8
587 2.9802322387695312e-8, // 2.980232238769532e-8
588 8.940696716308594e-8, // 8.940696716308594e-8
589 1.4901161193847656e-7, // 1.4901161193847656e-7
590 1.4901161193847656e-7, // 1.490116119384766e-7
593 65520, // 65519.99999999999
594 0.000061005353927612305, // 0.000061005353927612305
595 0.000061005353927612305 // 0.0000610053539276123
602 2147483647, // 2147483647
603 2147483648, // 2147483648
608 4294967295, // 4294967295
609 4294967296, // 4294967296
610 9007199254740991, // 9007199254740991
611 9007199254740992, // 9007199254740992
615 0.50000001, // 0.50000001,
628 -2147483647, // -2147483647
629 -2147483648, // -2147483648
634 -4294967295, // -4294967295
635 -4294967296, // -4294967296
636 Infinity, // Infinity
637 -Infinity, // -Infinity
641 0.00006103515625, // 0.00006103515625
642 0.00006097555160522461, // 0.00006097555160522461
643 5.960464477539063e-8, // 5.960464477539063e-8
644 2.9802322387695312e-8, // 2.9802322387695312e-8
645 2.980232238769532e-8, // 2.980232238769532e-8
646 8.940696716308594e-8, // 8.940696716308594e-8
647 1.4901161193847656e-7, // 1.4901161193847656e-7
648 1.490116119384766e-7, // 1.490116119384766e-7
651 65519.99999999999, // 65519.99999999999
652 0.000061005353927612305, // 0.000061005353927612305
653 0.0000610053539276123 // 0.0000610053539276123
658 // file: detachArrayBuffer.js
659 // Copyright (C) 2016 the V8 project authors. All rights reserved.
660 // This code is governed by the BSD license found in the LICENSE file.
663 A function used in the process of asserting correctness of TypedArray objects.
665 $262.detachArrayBuffer is defined by a host.
666 defines: [$DETACHBUFFER]
669 function $DETACHBUFFER(buffer) {
670 if (!$262 || typeof $262.detachArrayBuffer !== "function") {
671 throw new Test262Error("No method available to detach an ArrayBuffer");
673 $262.detachArrayBuffer(buffer);
677 // Copyright (C) 2016 the V8 project authors. All rights reserved.
678 // This code is governed by the BSD license found in the LICENSE file.
681 A collection of NaN values produced from expressions that have been observed
682 to create distinct bit representations on various platforms. These provide a
683 weak basis for assertions regarding the consistent canonicalization of NaN
684 values in Array buffers.
697 Number("Not-a-Number"),
700 // file: testTypedArray.js
701 // Copyright (C) 2015 André Bargull. All rights reserved.
702 // This code is governed by the BSD license found in the LICENSE file.
705 Collection of functions used to assert the correctness of TypedArray objects.
707 - floatArrayConstructors
708 - nonClampedIntArrayConstructors
709 - intArrayConstructors
710 - typedArrayConstructors
712 - testWithTypedArrayConstructors
713 - nonAtomicsFriendlyTypedArrayConstructors
714 - testWithAtomicsFriendlyTypedArrayConstructors
715 - testWithNonAtomicsFriendlyTypedArrayConstructors
716 - testTypedArrayConversions
719 var floatArrayConstructors = [
724 var nonClampedIntArrayConstructors = [
733 var intArrayConstructors = nonClampedIntArrayConstructors.concat([Uint8ClampedArray]);
735 // Float16Array is a newer feature
736 // adding it to this list unconditionally would cause implementations lacking it to fail every test which uses it
737 if (typeof Float16Array !== 'undefined') {
738 floatArrayConstructors.push(Float16Array);
742 * Array containing every non-bigint typed array constructor.
745 var typedArrayConstructors = floatArrayConstructors.concat(intArrayConstructors);
748 * The %TypedArray% intrinsic constructor function.
750 var TypedArray = Object.getPrototypeOf(Int8Array);
753 * Callback for testing a typed array constructor.
755 * @callback typedArrayConstructorCallback
756 * @param {Function} Constructor the constructor object to test with.
760 * Calls the provided function for every typed array constructor.
762 * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
763 * @param {Array} selected - An optional Array with filtered typed arrays
765 function testWithTypedArrayConstructors(f, selected) {
766 var constructors = selected || typedArrayConstructors;
767 for (var i = 0; i < constructors.length; ++i) {
768 var constructor = constructors[i];
772 e.message += " (Testing with " + constructor.name + ".)";
778 var nonAtomicsFriendlyTypedArrayConstructors = floatArrayConstructors.concat([Uint8ClampedArray]);
780 * Calls the provided function for every non-"Atomics Friendly" typed array constructor.
782 * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
783 * @param {Array} selected - An optional Array with filtered typed arrays
785 function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
786 testWithTypedArrayConstructors(f, nonAtomicsFriendlyTypedArrayConstructors);
790 * Calls the provided function for every "Atomics Friendly" typed array constructor.
792 * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
793 * @param {Array} selected - An optional Array with filtered typed arrays
795 function testWithAtomicsFriendlyTypedArrayConstructors(f) {
796 testWithTypedArrayConstructors(f, [
807 * Helper for conversion operations on TypedArrays, the expected values
808 * properties are indexed in order to match the respective value for each
809 * TypedArray constructor
810 * @param {Function} fn - the function to call for each constructor and value.
811 * will be called with the constructor, value, expected
812 * value, and a initial value that can be used to avoid
813 * a false positive with an equivalent expected value.
815 function testTypedArrayConversions(byteConversionValues, fn) {
816 var values = byteConversionValues.values;
817 var expected = byteConversionValues.expected;
819 testWithTypedArrayConstructors(function(TA) {
820 var name = TA.name.slice(0, -5);
822 return values.forEach(function(value, index) {
823 var exp = expected[name][index];
828 fn(TA, value, exp, initial);
834 * Checks if the given argument is one of the float-based TypedArray constructors.
836 * @param {constructor} ctor - the value to check
839 function isFloatTypedArrayConstructor(arg) {
840 return floatArrayConstructors.indexOf(arg) !== -1;
844 * Determines the precision of the given float-based TypedArray constructor.
846 * @param {constructor} ctor - the value to check
847 * @returns {string} "half", "single", or "double" for Float16Array, Float32Array, and Float64Array respectively.
849 function floatTypedArrayConstructorPrecision(FA) {
850 if (typeof Float16Array !== "undefined" && FA === Float16Array) {
852 } else if (FA === Float32Array) {
854 } else if (FA === Float64Array) {
857 throw new Error("Malformed test - floatTypedArrayConstructorPrecision called with non-float TypedArray");