summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArray
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArray')
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/Symbol.species/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js20
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/Symbol.species/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/length.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js19
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/invoked.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/length.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/name.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/length.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js19
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype.js20
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js22
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js22
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/at/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js94
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js94
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js97
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js113
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js95
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js75
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js94
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js102
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js97
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js113
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js95
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js75
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/iter-prototype.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-itor.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js106
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js85
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-this.js22
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js106
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js103
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js89
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js22
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js80
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-strict-strict.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js80
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict-strict.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict-strict.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict-strict.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/returns-undefined.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js74
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js80
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js80
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js137
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/iter-prototype.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/return-length.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-this.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js79
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js73
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js78
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js69
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js78
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/returns-original-object.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/reverts.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js97
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js74
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js65
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js90
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js89
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js74
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js95
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js107
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js107
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js97
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js74
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js65
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js23
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/shell.js66
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js77
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js95
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js110
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js110
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/arraylength-internal.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js51
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/infinity.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/minus-zero.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-different-length.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-same-length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js65
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-end.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-start.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js65
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js68
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-this.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js71
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js76
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js61
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/arraylength-internal.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js25
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/infinity.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/minus-zero.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-end.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js37
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js39
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js40
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js27
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js64
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js63
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js67
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js41
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js50
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js56
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-result.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js55
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js45
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js57
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js58
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js48
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js59
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js60
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js49
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js52
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js30
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js47
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/toString/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/iter-prototype.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-itor.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js26
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js29
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js62
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js54
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js46
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/shell.js42
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js34
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js44
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js22
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js32
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js43
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js53
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js33
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js31
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js28
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js36
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js38
-rw-r--r--js/src/tests/test262/built-ins/TypedArray/shell.js614
1452 files changed, 61022 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/browser.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js
new file mode 100644
index 0000000000..8efd820740
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 22.2.2.4
+description: >
+ get %TypedArray% [ @@species ].length is 0.
+info: |
+ get %TypedArray% [ @@species ]
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [Symbol.species]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray, Symbol.species);
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js
new file mode 100644
index 0000000000..8747ac6130
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 22.2.2.4
+description: >
+ get %TypedArray% [ @@species ].name is "get [Symbol.species]".
+info: |
+ get %TypedArray% [ @@species ]
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [Symbol.species]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray, Symbol.species);
+
+assert.sameValue(desc.get.name, "get [Symbol.species]");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js
new file mode 100644
index 0000000000..5a97e8f5e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 22.2.2.4
+description: >
+ @@species property of TypedArray
+info: |
+ 22.2.2.4 get %TypedArray% [ @@species ]
+
+ %TypedArray%[@@species] is an accessor property whose set accessor function
+ is undefined.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray, Symbol.species);
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, 'function');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js
new file mode 100644
index 0000000000..3b79165925
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/result.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 22.2.2.4
+description: >
+ @@species property returns the `this` value
+info: |
+ 22.2.2.4 get %TypedArray% [ @@species ]
+
+ 1. Return the this value.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+var value = {};
+var getter = Object.getOwnPropertyDescriptor(TypedArray, Symbol.species).get;
+
+assert.sameValue(getter.call(value), value);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/Symbol.species/shell.js b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/Symbol.species/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/browser.js b/js/src/tests/test262/built-ins/TypedArray/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js b/js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js
new file mode 100644
index 0000000000..705df14bf9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/arylk-get-length-error.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: Returns error produced by accessing array-like's length
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ ...
+ 7. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var arrayLike = {};
+
+Object.defineProperty(arrayLike, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ TypedArray.from(arrayLike);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js b/js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js
new file mode 100644
index 0000000000..e4ab814d5f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/arylk-to-length-error.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: Returns error produced by interpreting length property as a length
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ ...
+ 7. Let len be ? ToLength(? Get(arrayLike, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var arrayLike = { length: {} };
+
+arrayLike.length = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ TypedArray.from(arrayLike);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/browser.js b/js/src/tests/test262/built-ins/TypedArray/from/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js
new file mode 100644
index 0000000000..97ce6b2ff9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-func.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: >
+ "from" cannot be invoked as a function
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ 1. Let C be the this value.
+ 2. If IsConstructor(C) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var from = TypedArray.from;
+
+assert.throws(TypeError, function() {
+ from([]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js
new file mode 100644
index 0000000000..d2414e0923
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/invoked-as-method.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: >
+ "from" cannot be invoked as a method of %TypedArray%
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ ...
+ 8. Let targetObj be ? TypedArrayCreate(C, «len»).
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.throws(TypeError, function() {
+ TypedArray.from([]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js
new file mode 100644
index 0000000000..b37537d19e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-access-error.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: Returns error produced by accessing @@iterator
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ ...
+ 6. Let arrayLike be ? IterableToArrayLike(source).
+ ...
+
+ 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items )
+
+ 1. Let usingIterator be ? GetMethod(items, @@iterator).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var iter = {};
+Object.defineProperty(iter, Symbol.iterator, {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ TypedArray.from(iter);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js
new file mode 100644
index 0000000000..de395eb2dc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-invoke-error.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: Returns error produced by invoking @@iterator
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ ...
+ 6. Let arrayLike be ? IterableToArrayLike(source).
+ ...
+
+ 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items )
+
+ 1. Let usingIterator be ? GetMethod(items, @@iterator).
+ 2. If usingIterator is not undefined, then
+ a. Let iterator be ? GetIterator(items, usingIterator).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var iter = {};
+iter[Symbol.iterator] = function() {
+ throw new Test262Error();
+};
+
+assert.throws(Test262Error, function() {
+ TypedArray.from(iter);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js
new file mode 100644
index 0000000000..7cbea13246
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-error.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: Returns error produced by advancing the iterator
+info: |
+ 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items )
+
+ 2. If usingIterator is not undefined, then
+ ...
+ d. Repeat, while next is not false
+ i. Let next be ? IteratorStep(iterator).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next: function() {
+ throw new Test262Error();
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ TypedArray.from(iter);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js
new file mode 100644
index 0000000000..a1674c417b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/iter-next-value-error.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: Returns error produced by accessing iterated value
+info: |
+ 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items )
+
+ 2. If usingIterator is not undefined, then
+ ...
+ d. Repeat, while next is not false
+ ...
+ ii. If next is not false, then
+ 1. Let nextValue be ? IteratorValue(next).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var iter = {};
+iter[Symbol.iterator] = function() {
+ return {
+ next: function() {
+ var result = {};
+ Object.defineProperty(result, 'value', {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ return result;
+ }
+ };
+};
+
+assert.throws(Test262Error, function() {
+ TypedArray.from(iter);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/length.js b/js/src/tests/test262/built-ins/TypedArray/from/length.js
new file mode 100644
index 0000000000..6ec675f750
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/length.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.from
+description: >
+ %TypedArray%.from.length is 1.
+info: |
+ %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+
+ Every built-in Function object, including constructors, has a length property
+ whose value is an integer. Unless otherwise specified, this value is equal to
+ the largest number of named arguments shown in the subclause headings for the
+ function description. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are shown using the form «...name») are not
+ included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function object
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.from.length, 1);
+
+verifyNotEnumerable(TypedArray.from, "length");
+verifyNotWritable(TypedArray.from, "length");
+verifyConfigurable(TypedArray.from, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js
new file mode 100644
index 0000000000..ece0766bee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/mapfn-is-not-callable.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: Throw a TypeError exception is mapfn is not callable
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ ...
+ 3. If mapfn was supplied and mapfn is not undefined, then
+ a. If IsCallable(mapfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, Symbol.iterator, TypedArray]
+---*/
+
+var getIterator = 0;
+var arrayLike = {};
+Object.defineProperty(arrayLike, Symbol.iterator, {
+ get: function() {
+ getIterator++;
+ }
+});
+
+assert.throws(TypeError, function() {
+ TypedArray.from(arrayLike, null);
+}, "mapfn is null");
+
+assert.throws(TypeError, function() {
+ TypedArray.from(arrayLike, 42);
+}, "mapfn is a number");
+
+assert.throws(TypeError, function() {
+ TypedArray.from(arrayLike, "");
+}, "mapfn is a string");
+
+assert.throws(TypeError, function() {
+ TypedArray.from(arrayLike, {});
+}, "mapfn is an ordinary object");
+
+assert.throws(TypeError, function() {
+ TypedArray.from(arrayLike, []);
+}, "mapfn is an array");
+
+assert.throws(TypeError, function() {
+ TypedArray.from(arrayLike, true);
+}, "mapfn is a boolean");
+
+var s = Symbol("1");
+assert.throws(TypeError, function() {
+ TypedArray.from(arrayLike, s);
+}, "mapfn is a symbol");
+
+assert.sameValue(
+ getIterator, 0,
+ "IsCallable(mapfn) check occurs before getting source[@@iterator]"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/name.js b/js/src/tests/test262/built-ins/TypedArray/from/name.js
new file mode 100644
index 0000000000..9fa98be4e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 22.2.2.1
+description: >
+ %TypedArray%.from.name is "from".
+info: |
+ %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.from.name, "from");
+
+verifyNotEnumerable(TypedArray.from, "name");
+verifyNotWritable(TypedArray.from, "name");
+verifyConfigurable(TypedArray.from, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js
new file mode 100644
index 0000000000..41a794dfca
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.from does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, TypedArray, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(TypedArray.from), false, 'isConstructor(TypedArray.from) must return false');
+
+assert.throws(TypeError, () => {
+ new TypedArray.from([]);
+}, '`new TypedArray.from([])` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js
new file mode 100644
index 0000000000..7dd61adf7d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/prop-desc.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 22.2.2.1
+description: >
+ "from" property of TypedArray
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+verifyNotEnumerable(TypedArray, 'from');
+verifyWritable(TypedArray, 'from');
+verifyConfigurable(TypedArray, 'from');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/shell.js b/js/src/tests/test262/built-ins/TypedArray/from/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js
new file mode 100644
index 0000000000..7838753ba5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/from/this-is-not-constructor.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.from
+description: >
+ Throws a TypeError exception if this is not a constructor
+info: |
+ 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ 1. Let C be the this value.
+ 2. If IsConstructor(C) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var from = TypedArray.from;
+var m = { m() {} }.m;
+
+assert.throws(TypeError, function() {
+ from.call(m, []);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/invoked.js b/js/src/tests/test262/built-ins/TypedArray/invoked.js
new file mode 100644
index 0000000000..3dca11ff4c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/invoked.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%
+description: Throw a TypeError exception if directly invoked.
+info: |
+ 22.2.1.1 %TypedArray% ( )
+
+ 1. Throw a TypeError Exception
+ ...
+
+ Note: ES2016 replaces all the references for the %TypedArray% constructor to a
+ single chapter covering all arguments cases.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.throws(TypeError, function() {
+ TypedArray();
+});
+
+assert.throws(TypeError, function() {
+ new TypedArray();
+});
+
+assert.throws(TypeError, function() {
+ TypedArray(1);
+});
+
+assert.throws(TypeError, function() {
+ new TypedArray(1);
+});
+
+assert.throws(TypeError, function() {
+ TypedArray(1.1);
+});
+
+assert.throws(TypeError, function() {
+ new TypedArray(1.1);
+});
+
+assert.throws(TypeError, function() {
+ TypedArray({});
+});
+
+assert.throws(TypeError, function() {
+ new TypedArray({});
+});
+
+var typedArray = new Int8Array(4);
+assert.throws(TypeError, function() {
+ TypedArray(typedArray);
+});
+
+assert.throws(TypeError, function() {
+ new TypedArray(typedArray);
+});
+
+var buffer = new ArrayBuffer(4);
+assert.throws(TypeError, function() {
+ TypedArray(buffer);
+});
+
+assert.throws(TypeError, function() {
+ new TypedArray(buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/length.js b/js/src/tests/test262/built-ins/TypedArray/length.js
new file mode 100644
index 0000000000..2f4e13aeff
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/length.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%
+description: >
+ TypedArray has a "length" property whose value is 0.
+info: |
+ %TypedArray% ( )
+
+ The length property of the %TypedArray% constructor function is 0.
+
+ 17 ECMAScript Standard Built-in Objects
+
+ ...
+
+ Unless otherwise specified, the length property of a built-in function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+verifyProperty(TypedArray, "length", {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/name.js b/js/src/tests/test262/built-ins/TypedArray/name.js
new file mode 100644
index 0000000000..ef6ccf58c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/name.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%
+description: >
+ TypedArray has a 'name' property whose value is "TypedArray".
+info: |
+ 22.2.2 Properties of the %TypedArray% Intrinsic Object
+
+ Besides a length property whose value is 3 and a name property whose value is
+ "TypedArray", %TypedArray% has the following properties:
+ ...
+
+ ES6 section 17: Unless otherwise specified, the name property of a built-in
+ Function object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.name, 'TypedArray');
+
+verifyNotEnumerable(TypedArray, 'name');
+verifyNotWritable(TypedArray, 'name');
+verifyConfigurable(TypedArray, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/browser.js b/js/src/tests/test262/built-ins/TypedArray/of/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js
new file mode 100644
index 0000000000..1f40a9659b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-func.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 22.2.2.2
+description: >
+ "of" cannot be invoked as a function
+info: |
+ 22.2.2.2 %TypedArray%.of ( ...items )
+
+ ...
+ 3. Let C be the this value.
+ 4. If IsConstructor(C) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var of = TypedArray.of;
+
+assert.throws(TypeError, function() {
+ of();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js
new file mode 100644
index 0000000000..0b671ca852
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/invoked-as-method.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.of
+description: >
+ "of" cannot be invoked as a method of %TypedArray%
+info: |
+ 22.2.2.2 %TypedArray%.of ( ...items )
+
+ ...
+ 5. Let newObj be ? TypedArrayCreate(C, «len»).
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.throws(TypeError, function() {
+ TypedArray.of();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/length.js b/js/src/tests/test262/built-ins/TypedArray/of/length.js
new file mode 100644
index 0000000000..9739cd5045
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/length.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%-of
+description: >
+ %TypedArray%.of.length is 0.
+info: |
+ %TypedArray%.of ( ...items )
+
+ 17 ECMAScript Standard Built-in Objects:
+
+ Every built-in Function object, including constructors, has a length property
+ whose value is an integer. Unless otherwise specified, this value is equal to
+ the largest number of named arguments shown in the subclause headings for the
+ function description. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are shown using the form «...name») are not
+ included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function object
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.of.length, 0);
+
+verifyNotEnumerable(TypedArray.of, "length");
+verifyNotWritable(TypedArray.of, "length");
+verifyConfigurable(TypedArray.of, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/name.js b/js/src/tests/test262/built-ins/TypedArray/of/name.js
new file mode 100644
index 0000000000..c18c95cafe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 22.2.2.2
+description: >
+ %TypedArray%.of.name is "of".
+info: |
+ %TypedArray%.of ( ...items )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.of.name, "of");
+
+verifyNotEnumerable(TypedArray.of, "name");
+verifyNotWritable(TypedArray.of, "name");
+verifyConfigurable(TypedArray.of, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js
new file mode 100644
index 0000000000..575bb492fb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.of does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, TypedArray, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(TypedArray.of), false, 'isConstructor(TypedArray.of) must return false');
+
+assert.throws(TypeError, () => {
+ new TypedArray.of(1, 2, 3, 4);
+}, '`new TypedArray.of(1, 2, 3, 4)` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js
new file mode 100644
index 0000000000..86bad8552c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/prop-desc.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 22.2.2.2
+description: >
+ "of" property of TypedArray
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+verifyNotEnumerable(TypedArray, 'of');
+verifyWritable(TypedArray, 'of');
+verifyConfigurable(TypedArray, 'of');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/shell.js b/js/src/tests/test262/built-ins/TypedArray/of/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js b/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js
new file mode 100644
index 0000000000..606fba3255
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/of/this-is-not-constructor.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.of
+description: >
+ Throws a TypeError exception if this is not a constructor
+info: |
+ 22.2.2.2 %TypedArray%.of ( ...items )
+
+ ...
+ 3. Let C be the this value.
+ 4. If IsConstructor(C) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var m = { m() {} }.m;
+
+assert.throws(TypeError, function() {
+ TypedArray.of.call(m, []);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype.js
new file mode 100644
index 0000000000..95287ce179
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%
+description: >
+ "prototype" property of TypedArray
+info: |
+ 22.2.2.3 %TypedArray%.prototype
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]:
+ false, [[Configurable]]: false }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+verifyNotEnumerable(TypedArray, 'prototype');
+verifyNotWritable(TypedArray, 'prototype');
+verifyNotConfigurable(TypedArray, 'prototype');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js
new file mode 100644
index 0000000000..1e125255c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype-@@iterator
+description: >
+ Initial state of the Symbol.iterator property
+info: |
+ The initial value of the @@iterator property is the same function object
+ as the initial value of the %TypedArray%.prototype.values property.
+
+ Per ES6 section 17, the method should exist on the %TypedArray% prototype, and it
+ should be writable and configurable, but not enumerable.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [Symbol.iterator]
+---*/
+
+assert.sameValue(TypedArray.prototype[Symbol.iterator], TypedArray.prototype.values);
+
+verifyNotEnumerable(TypedArray.prototype, Symbol.iterator);
+verifyWritable(TypedArray.prototype, Symbol.iterator);
+verifyConfigurable(TypedArray.prototype, Symbol.iterator);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js
new file mode 100644
index 0000000000..2a894cabda
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype[Symbol.iterator] does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, Symbol, Symbol.iterator, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype[Symbol.iterator]),
+ false,
+ 'isConstructor(TypedArray.prototype[Symbol.iterator]) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8[Symbol.iterator]();
+}, '`let u8 = new Uint8Array(1); new u8[Symbol.iterator]()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.iterator/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..df8573d85d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: The getter method does not throw with a detached buffer
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ ...
+ 4. Let name be the value of O's [[TypedArrayName]] internal slot.
+ 5. Assert: name is a String value.
+ 6. Return name.
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, Symbol.toStringTag, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample[Symbol.toStringTag], TA.name);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js
new file mode 100644
index 0000000000..d22df1a051
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ Return undefined if this value does not have a [[TypedArrayName]] internal slot
+info: |
+ 22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ ...
+ 3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.toStringTag, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(TypedArrayPrototype[Symbol.toStringTag], undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js
new file mode 100644
index 0000000000..fa28fde06b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: If this value is not Object, return undefined.
+info: |
+ 22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, return undefined.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.toStringTag, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+).get;
+
+assert.sameValue(getter(), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js
new file mode 100644
index 0000000000..246f30b499
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ get %TypedArray%.prototype [ @@toStringTag ].length is 0.
+info: |
+ get %TypedArray%.prototype [ @@toStringTag ]
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testBigIntTypedArray.js]
+features: [BigInt, Symbol.toStringTag]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag);
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js
new file mode 100644
index 0000000000..3b77f82c2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ get %TypedArray%.prototype [ @@toStringTag ].name is "get [Symbol.toStringTag]".
+info: |
+ get %TypedArray%.prototype [ @@toStringTag ]
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testBigIntTypedArray.js]
+features: [BigInt, Symbol.toStringTag]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag);
+
+assert.sameValue(desc.get.name, "get [Symbol.toStringTag]");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js
new file mode 100644
index 0000000000..070228754a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ "@@toStringTag" property of TypedArrayPrototype
+info: |
+ 22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
+
+ %TypedArray%.prototype[@@toStringTag] is an accessor property whose set
+ accessor function is undefined.
+ ...
+
+ This property has the attributes { [[Enumerable]]: false, [[Configurable]]:
+ true }.
+includes: [propertyHelper.js, testBigIntTypedArray.js]
+features: [BigInt, Symbol.toStringTag]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+);
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, 'function');
+verifyNotEnumerable(TypedArrayPrototype, Symbol.toStringTag);
+verifyConfigurable(TypedArrayPrototype, Symbol.toStringTag);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js
new file mode 100644
index 0000000000..34b025e7bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ Return value from the [[TypedArrayName]] internal slot
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ ...
+ 4. Let name be the value of O's [[TypedArrayName]] internal slot.
+ 5. Assert: name is a String value.
+ 6. Return name.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.toStringTag, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta = new TA();
+ assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js
new file mode 100644
index 0000000000..59ed5bc04d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ Return undefined when `this` does not have a [[TypedArrayName]] internal slot
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ ...
+ 3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.toStringTag, DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+).get;
+
+assert.sameValue(getter.call({}), undefined);
+assert.sameValue(getter.call([]), undefined);
+assert.sameValue(getter.call(new ArrayBuffer(8)), undefined);
+
+var ab = new ArrayBuffer(8);
+var dv = new DataView(ab, 0, 1);
+assert.sameValue(getter.call(dv), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js
new file mode 100644
index 0000000000..9a040f049f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: Return undefined when `this` is not Object
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, return undefined.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, Symbol.toStringTag, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+).get;
+
+assert.sameValue(getter.call(undefined), undefined, "this is undefined");
+assert.sameValue(getter.call(42), undefined, "this is 42");
+assert.sameValue(getter.call("foo"), undefined, "this is a string");
+assert.sameValue(getter.call(true), undefined, "this is true");
+assert.sameValue(getter.call(false), undefined, "this is false");
+assert.sameValue(getter.call(Symbol("s")), undefined, "this is a Symbol");
+assert.sameValue(getter.call(null), undefined, "this is null");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js
new file mode 100644
index 0000000000..2644bfebd4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: The getter method does not throw with a detached buffer
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ ...
+ 4. Let name be the value of O's [[TypedArrayName]] internal slot.
+ 5. Assert: name is a String value.
+ 6. Return name.
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [Symbol.toStringTag, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample[Symbol.toStringTag], TA.name);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js
new file mode 100644
index 0000000000..227ff392a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ Return undefined if this value does not have a [[TypedArrayName]] internal slot
+info: |
+ 22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ ...
+ 3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.toStringTag, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(TypedArrayPrototype[Symbol.toStringTag], undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js
new file mode 100644
index 0000000000..f05d7656d6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: If this value is not Object, return undefined.
+info: |
+ 22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, return undefined.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.toStringTag, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+).get;
+
+assert.sameValue(getter(), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js
new file mode 100644
index 0000000000..d47c20684b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ get %TypedArray%.prototype [ @@toStringTag ].length is 0.
+info: |
+ get %TypedArray%.prototype [ @@toStringTag ]
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [Symbol.toStringTag]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag);
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js
new file mode 100644
index 0000000000..6de76bd40f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ get %TypedArray%.prototype [ @@toStringTag ].name is "get [Symbol.toStringTag]".
+info: |
+ get %TypedArray%.prototype [ @@toStringTag ]
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [Symbol.toStringTag]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, Symbol.toStringTag);
+
+assert.sameValue(desc.get.name, "get [Symbol.toStringTag]");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js
new file mode 100644
index 0000000000..7fda276f58
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ "@@toStringTag" property of TypedArrayPrototype
+info: |
+ 22.2.3.31 get %TypedArray%.prototype [ @@toStringTag ]
+
+ %TypedArray%.prototype[@@toStringTag] is an accessor property whose set
+ accessor function is undefined.
+ ...
+
+ This property has the attributes { [[Enumerable]]: false, [[Configurable]]:
+ true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [Symbol.toStringTag]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+);
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, 'function');
+verifyNotEnumerable(TypedArrayPrototype, Symbol.toStringTag);
+verifyConfigurable(TypedArrayPrototype, Symbol.toStringTag);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js
new file mode 100644
index 0000000000..4cc973019c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ Return value from the [[TypedArrayName]] internal slot
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ ...
+ 4. Let name be the value of O's [[TypedArrayName]] internal slot.
+ 5. Assert: name is a String value.
+ 6. Return name.
+includes: [testTypedArray.js]
+features: [Symbol.toStringTag, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = new TA();
+ assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js
new file mode 100644
index 0000000000..06450f6030
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: >
+ Return undefined when `this` does not have a [[TypedArrayName]] internal slot
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ ...
+ 3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.toStringTag, DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+).get;
+
+assert.sameValue(getter.call({}), undefined);
+assert.sameValue(getter.call([]), undefined);
+assert.sameValue(getter.call(new ArrayBuffer(8)), undefined);
+
+var ab = new ArrayBuffer(8);
+var dv = new DataView(ab, 0, 1);
+assert.sameValue(getter.call(dv), undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js
new file mode 100644
index 0000000000..460564f162
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype-@@tostringtag
+description: Return undefined when `this` is not Object
+info: |
+ 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ]
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, return undefined.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, Symbol.toStringTag, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, Symbol.toStringTag
+).get;
+
+assert.sameValue(getter.call(undefined), undefined, "this is undefined");
+assert.sameValue(getter.call(42), undefined, "this is 42");
+assert.sameValue(getter.call("foo"), undefined, "this is a string");
+assert.sameValue(getter.call(true), undefined, "this is true");
+assert.sameValue(getter.call(false), undefined, "this is false");
+assert.sameValue(getter.call(Symbol("s")), undefined, "this is a Symbol");
+assert.sameValue(getter.call(null), undefined, "this is null");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..33f5aeb6d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, TypedArray.prototype.at, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'implements TypedArray.prototype.at'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.at(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.at(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the at operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.at(0);
+ throw new Test262Error('at completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js
new file mode 100644
index 0000000000..0177ff8308
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-argument-tointeger.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Property type and descriptor.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ Let relativeIndex be ? ToInteger(index).
+
+includes: [testTypedArray.js]
+features: [TypedArray, TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+testWithTypedArrayConstructors(TA => {
+ assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
+ let valueOfCallCount = 0;
+ let index = {
+ valueOf() {
+ valueOfCallCount++;
+ return 1;
+ }
+ };
+
+ let a = new TA([0,1,2,3]);
+
+ assert.sameValue(a.at(index), 1, 'a.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1');
+ assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js
new file mode 100644
index 0000000000..e3f65c143d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Property type and descriptor.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ Let relativeIndex be ? ToInteger(index).
+
+includes: [testTypedArray.js]
+features: [TypedArray, TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+testWithTypedArrayConstructors(TA => {
+ assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
+ let a = new TA([0,1,2,3]);
+
+ assert.throws(TypeError, () => {
+ a.at(Symbol());
+ }, '`a.at(Symbol())` throws TypeError');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js
new file mode 100644
index 0000000000..4d604500bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Property type and descriptor.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ Let relativeIndex be ? ToInteger(index).
+
+includes: [testTypedArray.js]
+features: [TypedArray, TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+testWithTypedArrayConstructors(TA => {
+ assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
+
+ let a = new TA([0,1,2,3]);
+
+ assert.sameValue(a.at(false), 0, 'a.at(false) must return 0');
+ assert.sameValue(a.at(null), 0, 'a.at(null) must return 0');
+ assert.sameValue(a.at(undefined), 0, 'a.at(undefined) must return 0');
+ assert.sameValue(a.at(""), 0, 'a.at("") must return 0');
+ assert.sameValue(a.at(function() {}), 0, 'a.at(function() {}) must return 0');
+ assert.sameValue(a.at([]), 0, 'a.at([]) must return 0');
+
+ assert.sameValue(a.at(true), 1, 'a.at(true) must return 1');
+ assert.sameValue(a.at("1"), 1, 'a.at("1") must return 1');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js
new file mode 100644
index 0000000000..acd90fd31c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/length.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ TypedArray.prototype.at.length value and descriptor.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+assert.sameValue(
+ TypedArray.prototype.at.length, 1,
+ 'The value of TypedArray.prototype.at.length is 1'
+);
+
+verifyNotEnumerable(TypedArray.prototype.at, 'length');
+verifyNotWritable(TypedArray.prototype.at, 'length');
+verifyConfigurable(TypedArray.prototype.at, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js
new file mode 100644
index 0000000000..fd4fcf2324
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/name.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ %TypedArray%.prototype.at.name value and descriptor.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+assert.sameValue(
+ TypedArray.prototype.at.name, 'at',
+ 'The value of TypedArray.prototype.at.name is "at"'
+);
+
+verifyProperty(TypedArray.prototype.at, 'name', {
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js
new file mode 100644
index 0000000000..946b185db0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/prop-desc.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Property type and descriptor.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ 17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+verifyProperty(TypedArray.prototype, 'at', {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..57eecff89f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, TypedArray.prototype.at, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'implements TypedArray.prototype.at'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.at(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.at(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the at operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.at(0);
+ throw new Test262Error('at completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js
new file mode 100644
index 0000000000..aaf89b12ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Return abrupt from ToObject(this value).
+info: |
+ %TypedArray%.prototype.at( index )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+
+includes: [testTypedArray.js]
+features: [TypedArray,TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+assert.throws(TypeError, () => {
+ TypedArray.prototype.at.call(undefined);
+}, '`TypedArray.prototype.at.call(undefined)` throws TypeError');
+
+assert.throws(TypeError, () => {
+ TypedArray.prototype.at.call(null);
+}, '`TypedArray.prototype.at.call(null)` throws TypeError');
+
+testWithTypedArrayConstructors(TA => {
+ assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
+
+ assert.throws(TypeError, () => {
+ TA.prototype.at.call(undefined);
+ }, '`TA.prototype.at.call(undefined)` throws TypeError');
+
+ assert.throws(TypeError, () => {
+ TA.prototype.at.call(null);
+ }, '`TA.prototype.at.call(null)` throws TypeError');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js
new file mode 100644
index 0000000000..ff4d81fc04
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item-relative-index.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Returns the item value at the specified relative index
+info: |
+ %TypedArray%.prototype.at( index )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ Let relativeIndex be ? ToInteger(index).
+ If relativeIndex ≥ 0, then
+ Let k be relativeIndex.
+ Else,
+ Let k be len + relativeIndex.
+ If k < 0 or k ≥ len, then return undefined.
+ Return ? Get(O, ! ToString(k)).
+
+includes: [testTypedArray.js]
+features: [TypedArray,TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+testWithTypedArrayConstructors(TA => {
+ let a = new TA([1, 2, 3, 4, 5]);
+ assert.sameValue(a.at(0), 1, 'a.at(0) must return 1');
+ assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5');
+ assert.sameValue(a.at(-2), 4, 'a.at(-2) must return 4');
+ assert.sameValue(a.at(-3), 3, 'a.at(-3) must return 3');
+ assert.sameValue(a.at(-4), 2, 'a.at(-4) must return 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js
new file mode 100644
index 0000000000..77ac1a0317
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-item.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Returns the item value at the specified index
+info: |
+ %TypedArray%.prototype.at( index )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ Let relativeIndex be ? ToInteger(index).
+ If relativeIndex ≥ 0, then
+ Let k be relativeIndex.
+ Else,
+ Let k be len + relativeIndex.
+ If k < 0 or k ≥ len, then return undefined.
+ Return ? Get(O, ! ToString(k)).
+
+includes: [testTypedArray.js]
+features: [TypedArray,TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+testWithTypedArrayConstructors(TA => {
+ assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
+ let a = new TA([1, 2, 3, 4]);
+
+ assert.sameValue(a.at(0), 1, 'a.at(0) must return 1');
+ assert.sameValue(a.at(1), 2, 'a.at(1) must return 2');
+ assert.sameValue(a.at(2), 3, 'a.at(2) must return 3');
+ assert.sameValue(a.at(3), 4, 'a.at(3) must return 4');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js
new file mode 100644
index 0000000000..c4eafb1e10
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Returns the item value at the specified index, holes are filled in sparse arrays.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ Let relativeIndex be ? ToInteger(index).
+ If relativeIndex ≥ 0, then
+ Let k be relativeIndex.
+ Else,
+ Let k be len + relativeIndex.
+ If k < 0 or k ≥ len, then return undefined.
+ Return ? Get(O, ! ToString(k)).
+
+includes: [testTypedArray.js]
+features: [TypedArray, TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+testWithTypedArrayConstructors(TA => {
+ let a = new TA([0, 1, , 3, 4, , 6]);
+ let filler = 0;
+ if (TA.name.startsWith('Float')) {
+ filler = NaN;
+ }
+ assert.sameValue(a.at(0), 0, 'a.at(0) must return 0');
+ assert.sameValue(a.at(1), 1, 'a.at(1) must return 1');
+ assert.sameValue(a.at(2), filler, 'a.at(2) must return the value of filler');
+ assert.sameValue(a.at(3), 3, 'a.at(3) must return 3');
+ assert.sameValue(a.at(4), 4, 'a.at(4) must return 4');
+ assert.sameValue(a.at(5), filler, 'a.at(5) must return the value of filler');
+ assert.sameValue(a.at(6), 6, 'a.at(6) must return 6');
+ assert.sameValue(a.at(-0), 0, 'a.at(-0) must return 0');
+ assert.sameValue(a.at(-1), 6, 'a.at(-1) must return 6');
+ assert.sameValue(a.at(-2), filler, 'a.at(-2) must return the value of filler');
+ assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4');
+ assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3');
+ assert.sameValue(a.at(-5), filler, 'a.at(-5) must return the value of filler');
+ assert.sameValue(a.at(-6), 1, 'a.at(-6) must return 1');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js
new file mode 100644
index 0000000000..8a954e3971
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.at
+description: >
+ Returns undefined if the specified index less than or greater than the available index range.
+info: |
+ %TypedArray%.prototype.at( index )
+
+ If k < 0 or k ≥ len, then return undefined.
+
+includes: [testTypedArray.js]
+features: [TypedArray,TypedArray.prototype.at]
+---*/
+assert.sameValue(
+ typeof TypedArray.prototype.at,
+ 'function',
+ 'The value of `typeof TypedArray.prototype.at` is "function"'
+);
+
+testWithTypedArrayConstructors(TA => {
+ assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
+ let a = new TA([]);
+
+ assert.sameValue(a.at(-2), undefined, 'a.at(-2) must return undefined'); // wrap around the end
+ assert.sameValue(a.at(0), undefined, 'a.at(0) must return undefined');
+ assert.sameValue(a.at(1), undefined, 'a.at(1) must return undefined');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/at/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/at/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/at/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..c255fe3436
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: The getter method does not throw with a detached buffer
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(8);
+ var sample = new TA(buffer, 0, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js
new file mode 100644
index 0000000000..a9055b85a6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/return-buffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ Return buffer from [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT);
+ var ta = new TA(buffer);
+
+ assert.sameValue(ta.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js
new file mode 100644
index 0000000000..37d07fc49b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: The getter method does not throw with a detached buffer
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(8);
+ var sample = new TA(buffer, 0, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js
new file mode 100644
index 0000000000..d1ce4b348a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-accessor.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ Requires this value to have a [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.buffer;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js
new file mode 100644
index 0000000000..4b47043775
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/invoked-as-func.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, 'buffer'
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js
new file mode 100644
index 0000000000..5d0450e8f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ get %TypedArray%.prototype.buffer.length is 0.
+info: |
+ get %TypedArray%.prototype.buffer
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js
new file mode 100644
index 0000000000..f0464af9dc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ get %TypedArray%.prototype.buffer.name is "get buffer".
+info: |
+ get %TypedArray%.prototype.buffer
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "buffer");
+
+assert.sameValue(desc.get.name, "get buffer");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js
new file mode 100644
index 0000000000..70f7c8973f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/prop-desc.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ "buffer" property of TypedArrayPrototype
+info: |
+ %TypedArray%.prototype.buffer is an accessor property whose set accessor
+ function is undefined.
+
+ Section 17: Every accessor property described in clauses 18 through 26 and in
+ Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "buffer");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(TypedArrayPrototype, "buffer");
+verifyConfigurable(TypedArrayPrototype, "buffer");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js
new file mode 100644
index 0000000000..aa17d649bf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/return-buffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ Return buffer from [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. Return buffer.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT);
+ var ta = new TA(buffer);
+
+ assert.sameValue(ta.buffer, buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js
new file mode 100644
index 0000000000..69844e2da1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "buffer"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+});
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+});
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+});
+
+var dv = new DataView(new ArrayBuffer(8), 0);
+assert.throws(TypeError, function() {
+ getter.call(dv);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js
new file mode 100644
index 0000000000..27d44fee16
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-inherits-typedarray.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot, even if its prototype does
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "buffer"
+).get;
+
+testWithTypedArrayConstructors(TA => {
+ var typedArray = new TA(5);
+ var o = {};
+ Object.setPrototypeOf(o, typedArray);
+ assert.throws(TypeError, function() {
+ getter.call(o);
+ },
+ "Internal slot should not be inherited");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js
new file mode 100644
index 0000000000..6f23eb7253
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/buffer/this-is-not-object.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.buffer
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.1 get %TypedArray%.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "buffer"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ getter.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ getter.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ getter.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ getter.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ getter.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ getter.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..e31373224f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: Returns 0 if the instance has a detached buffer
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. If IsDetachedBuffer(buffer) is true, return 0.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.byteLength, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js
new file mode 100644
index 0000000000..e3051b920a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js
@@ -0,0 +1,56 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the dynamically-sized TypedArray instance
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE);
+ var expected = BPE * 3;
+
+ assert.sameValue(array.byteLength, expected);
+
+ try {
+ ab.resize(BPE * 5);
+ expected = BPE * 4;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ expected = BPE * 2;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following shrink (within bounds)");
+
+ try {
+ ab.resize(BPE);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following shrink (on boundary)");
+
+ try {
+ ab.resize(0);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js
new file mode 100644
index 0000000000..366e9c00fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js
@@ -0,0 +1,49 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the fixed-sized TypedArray instance
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ assert.sameValue(array.byteLength, BPE * 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, BPE * 2, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, BPE * 2, "following shrink (within bounds)");
+
+ var expected;
+ try {
+ ab.resize(BPE * 2);
+ expected = 0;
+ } catch (_) {
+ expected = BPE * 2;
+ }
+
+ assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js
new file mode 100644
index 0000000000..36e9352f98
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: >
+ Return value from [[ByteLength]] internal slot
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ ...
+ 6. Let size be the value of O's [[ByteLength]] internal slot.
+ 7. Return size.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var bytesPerElement = TA.BYTES_PER_ELEMENT;
+ var ta1 = new TA();
+ assert.sameValue(ta1.byteLength, 0);
+
+ var ta2 = new TA(42);
+ assert.sameValue(ta2.byteLength, 42 * bytesPerElement);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js
new file mode 100644
index 0000000000..205495e17c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: Returns 0 if the instance has a detached buffer
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. If IsDetachedBuffer(buffer) is true, return 0.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.byteLength, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js
new file mode 100644
index 0000000000..6f61359335
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-accessor.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: >
+ Requires this value to have a [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.byteLength;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js
new file mode 100644
index 0000000000..2564aef2f1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/invoked-as-func.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, 'byteLength'
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js
new file mode 100644
index 0000000000..c8d44217b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: >
+ get %TypedArray%.prototype.byteLength.length is 0.
+info: |
+ get %TypedArray%.prototype.byteLength
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js
new file mode 100644
index 0000000000..b6da9f6c41
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: >
+ get %TypedArray%.prototype.byteLength.name is "get byteLength".
+info: |
+ get %TypedArray%.prototype.byteLength
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteLength");
+
+assert.sameValue(desc.get.name, "get byteLength");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js
new file mode 100644
index 0000000000..cb1a455857
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/prop-desc.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: >
+ "byteLength" property of TypedArrayPrototype
+info: |
+ %TypedArray%.prototype.byteLength is an accessor property whose set accessor
+ function is undefined.
+
+ Section 17: Every accessor property described in clauses 18 through 26 and in
+ Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "byteLength");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(TypedArrayPrototype, "byteLength");
+verifyConfigurable(TypedArrayPrototype, "byteLength");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js
new file mode 100644
index 0000000000..16c93b6cac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js
@@ -0,0 +1,56 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the dynamically-sized TypedArray instance
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE);
+ var expected = BPE * 3;
+
+ assert.sameValue(array.byteLength, expected);
+
+ try {
+ ab.resize(BPE * 5);
+ expected = BPE * 4;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ expected = BPE * 2;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following shrink (within bounds)");
+
+ try {
+ ab.resize(BPE);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following shrink (on boundary)");
+
+ try {
+ ab.resize(0);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js
new file mode 100644
index 0000000000..7067776ec0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js
@@ -0,0 +1,49 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the fixed-sized TypedArray instance
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ assert.sameValue(array.byteLength, BPE * 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, BPE * 2, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.byteLength, BPE * 2, "following shrink (within bounds)");
+
+ var expected;
+ try {
+ ab.resize(BPE * 2);
+ expected = 0;
+ } catch (_) {
+ expected = BPE * 2;
+ }
+
+ assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js
new file mode 100644
index 0000000000..a344aa1d4f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/return-bytelength.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: >
+ Return value from [[ByteLength]] internal slot
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ ...
+ 6. Let size be the value of O's [[ByteLength]] internal slot.
+ 7. Return size.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var bytesPerElement = TA.BYTES_PER_ELEMENT;
+ var ta1 = new TA();
+ assert.sameValue(ta1.byteLength, 0);
+
+ var ta2 = new TA(42);
+ assert.sameValue(ta2.byteLength, 42 * bytesPerElement);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js
new file mode 100644
index 0000000000..212bd2b016
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+});
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+});
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+});
+
+var dv = new DataView(new ArrayBuffer(8), 0);
+assert.throws(TypeError, function() {
+ getter.call(dv);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js
new file mode 100644
index 0000000000..84a1e60675
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.bytelength
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.2 get %TypedArray%.prototype.byteLength
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ getter.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ getter.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ getter.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ getter.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ getter.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ getter.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..0a10adbbc2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: Returns 0 if the instance has a detached buffer
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. If IsDetachedBuffer(buffer) is true, return 0.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(128);
+ var sample = new TA(buffer, 8, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.byteOffset, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js
new file mode 100644
index 0000000000..82604a178c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js
@@ -0,0 +1,53 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the dynamically-sized TypedArray instance
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE);
+
+ assert.sameValue(array.byteOffset, BPE);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)");
+
+ try {
+ ab.resize(BPE);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following shrink (on boundary)");
+
+ var expected = BPE;
+ try {
+ ab.resize(0);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js
new file mode 100644
index 0000000000..f047af9c48
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js
@@ -0,0 +1,49 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the fixed-sized TypedArray instance
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ assert.sameValue(array.byteOffset, BPE);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)");
+
+ var expected;
+ try {
+ ab.resize(BPE * 2);
+ expected = 0;
+ } catch (_) {
+ expected = BPE;
+ }
+
+ assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js
new file mode 100644
index 0000000000..3849eab69b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: >
+ Return value from [[ByteOffset]] internal slot
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ ...
+ 6. Let offset be the value of O's [[ByteOffset]] internal slot.
+ 7. Return size.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.byteOffset, 0, "Regular typedArray");
+
+ var offset = 4 * TA.BYTES_PER_ELEMENT;
+
+ var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT);
+ var ta2 = new TA(buffer1, offset);
+ assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)");
+
+ var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT);
+ var sample = new TA(buffer2, offset);
+ var ta3 = new TA(sample);
+ assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js
new file mode 100644
index 0000000000..e831fd0232
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/detached-buffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: Returns 0 if the instance has a detached buffer
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ ...
+ 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 5. If IsDetachedBuffer(buffer) is true, return 0.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new ArrayBuffer(128);
+ var sample = new TA(buffer, 8, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.byteOffset, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js
new file mode 100644
index 0000000000..7ebe5f7ff2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-accessor.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: >
+ Requires this value to have a [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.byteOffset;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js
new file mode 100644
index 0000000000..e7ff71bfef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/invoked-as-func.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, 'byteOffset'
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js
new file mode 100644
index 0000000000..f8e16555cb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: >
+ get %TypedArray%.prototype.byteOffset.length is 0.
+info: |
+ get %TypedArray%.prototype.byteOffset
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js
new file mode 100644
index 0000000000..4a2e7d3ea3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: >
+ get %TypedArray%.prototype.byteOffset.name is "get byteOffset".
+info: |
+ get %TypedArray%.prototype.byteOffset
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "byteOffset");
+
+assert.sameValue(desc.get.name, "get byteOffset");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js
new file mode 100644
index 0000000000..8d6f554f4a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/prop-desc.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: >
+ "byteOffset" property of TypedArrayPrototype
+info: |
+ %TypedArray%.prototype.byteOffset is an accessor property whose set accessor
+ function is undefined.
+
+ Section 17: Every accessor property described in clauses 18 through 26 and in
+ Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "byteOffset");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(TypedArrayPrototype, "byteOffset");
+verifyConfigurable(TypedArrayPrototype, "byteOffset");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js
new file mode 100644
index 0000000000..3f90222055
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js
@@ -0,0 +1,53 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the dynamically-sized TypedArray instance
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE);
+
+ assert.sameValue(array.byteOffset, BPE);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)");
+
+ try {
+ ab.resize(BPE);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following shrink (on boundary)");
+
+ var expected = BPE;
+ try {
+ ab.resize(0);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js
new file mode 100644
index 0000000000..66555faa47
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js
@@ -0,0 +1,49 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the fixed-sized TypedArray instance
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ assert.sameValue(array.byteOffset, BPE);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)");
+
+ var expected;
+ try {
+ ab.resize(BPE * 2);
+ expected = 0;
+ } catch (_) {
+ expected = BPE;
+ }
+
+ assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js
new file mode 100644
index 0000000000..889aef45b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: >
+ Return value from [[ByteOffset]] internal slot
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ ...
+ 6. Let offset be the value of O's [[ByteOffset]] internal slot.
+ 7. Return size.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.byteOffset, 0, "Regular typedArray");
+
+ var offset = 4 * TA.BYTES_PER_ELEMENT;
+
+ var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT);
+ var ta2 = new TA(buffer1, offset);
+ assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)");
+
+ var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT);
+ var sample = new TA(buffer2, offset);
+ var ta3 = new TA(sample);
+ assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js
new file mode 100644
index 0000000000..4388d3d760
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "byteOffset"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+});
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+});
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+});
+
+var dv = new DataView(new ArrayBuffer(8), 0);
+assert.throws(TypeError, function() {
+ getter.call(dv);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js
new file mode 100644
index 0000000000..da5c78ed28
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.byteoffset
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.3 get %TypedArray%.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "byteOffset"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ getter.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ getter.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ getter.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ getter.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ getter.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ getter.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js
new file mode 100644
index 0000000000..d41ffbfa41
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/constructor.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.constructor
+description: >
+ Initial state of the constructor property
+info: |
+ The initial value of %TypedArray%.prototype.constructor is the %TypedArray% intrinsic object.
+
+ Per ES6 section 17, the method should exist on the %TypedArray% prototype, and it
+ should be writable and configurable, but not enumerable.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.constructor, TypedArray);
+
+verifyNotEnumerable(TypedArray.prototype, "constructor");
+verifyWritable(TypedArray.prototype, "constructor");
+verifyConfigurable(TypedArray.prototype, "constructor");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js
new file mode 100644
index 0000000000..81c4a3a943
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ end argument is coerced to an integer values.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null),
+ [0n, 1n, 2n, 3n]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN),
+ [0n, 1n, 2n, 3n]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false),
+ [0n, 1n, 2n, 3n]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true),
+ [0n, 0n, 2n, 3n]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, '-2'),
+ [0n, 0n, 1n, 3n]
+ ),
+ 'string "-2" value coerced to integer -2'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5),
+ [0n, 0n, 1n, 3n]
+ ),
+ 'float -2.5 value coerced to integer -2'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js
new file mode 100644
index 0000000000..278e95b791
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js
@@ -0,0 +1,94 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ start argument is coerced to an integer value.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, false),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, null),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, true),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, '1'),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5),
+ [0n, 0n, 1n, 2n]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5),
+ [1n, 2n, 3n, 3n]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js
new file mode 100644
index 0000000000..a5556c519a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js
@@ -0,0 +1,94 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ target argument is coerced to an integer value.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin('1', 0),
+ [0n, 0n, 1n, 2n]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0),
+ [0n, 0n, 1n, 2n]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..f017576090
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.copyWithin(obj, obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..f9e3b903d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA();
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.sameValue(sample.copyWithin(0, 0), sample);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js
new file mode 100644
index 0000000000..f1fde574bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-end.js
@@ -0,0 +1,97 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative end argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1),
+ [1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1),
+ [0n, 1n, 0n, 1n, 2n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2),
+ [0n, 2n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1),
+ [2n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1),
+ [0n, 1n, 3n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1),
+ [0n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1),
+ [0n, 1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1),
+ [3n, 1n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js
new file mode 100644
index 0000000000..55710a2447
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js
@@ -0,0 +1,113 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative out of bounds end argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js
new file mode 100644
index 0000000000..997436c7bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js
@@ -0,0 +1,95 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with out of bounds negative start argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
+ from be min(relativeStart, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10),
+ [0n, 1n, 0n, 1n, 2n]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity),
+ [1n, 2n, 1n, 2n, 3n]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10),
+ [0n, 1n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js
new file mode 100644
index 0000000000..925be0ce7c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with out of bounds negative target argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
+ to be min(relativeTarget, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2),
+ [2n, 3n, 4n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2),
+ [3n, 4n, 5n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js
new file mode 100644
index 0000000000..d7ac9c82b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-start.js
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative start argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
+ from be min(relativeStart, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1),
+ [3n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2),
+ [0n, 1n, 3n, 4n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2),
+ [0n, 3n, 4n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2),
+ [0n, 1n, 2n, 2n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3),
+ [0n, 1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2),
+ [3n, 4n, 2n, 3n, 4n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js
new file mode 100644
index 0000000000..286910f628
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/negative-target.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative target argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
+ to be min(relativeTarget, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0),
+ [0n, 1n, 2n, 0n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2),
+ [0n, 1n, 2n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2),
+ [0n, 1n, 2n, 2n]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js
new file mode 100644
index 0000000000..45440750fb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Max value of end position is the this.length.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6),
+ [1n, 2n, 3n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity),
+ [2n, 3n, 4n, 5n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6),
+ [0n, 3n, 4n, 5n, 4n, 5n]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity),
+ [1n, 4n, 5n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js
new file mode 100644
index 0000000000..51f22654a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js
@@ -0,0 +1,76 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Max values of target and start positions are this.length.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10),
+ [0n, 1n, 2n, 3n, 4n, 5n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity),
+ [1n, 2n, 3n, 4n, 5n]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js
new file mode 100644
index 0000000000..137f9190cf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Copy values with non-negative target and start positions.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0),
+ [1n, 2n, 3n, 4n, 5n, 6n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2),
+ [3n, 4n, 5n, 6n, 5n, 6n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0),
+ [1n, 2n, 3n, 1n, 2n, 3n]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4),
+ [0n, 4n, 5n, 3n, 4n, 5n]
+ )
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js
new file mode 100644
index 0000000000..17ddf9d1c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js
@@ -0,0 +1,75 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Copy values with non-negative target, start and end positions.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2),
+ [0n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2),
+ [1n, 1n, 2n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
+ );
+
+ /*
+ * 10. If from<to and to<from+count, then
+ * a. Let direction be - 1.
+ * b. Let from be from + count - 1.
+ * c. Let to be to + count - 1.
+ *
+ * 0 < 1, 1 < 0 + 2
+ * direction = -1
+ * from = 0 + 2 - 1
+ * to = 1 + 2 - 1
+ */
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, 2),
+ [0n, 0n, 1n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5),
+ [0n, 3n, 4n, 3n, 4n, 5n]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js
new file mode 100644
index 0000000000..1aa2fb1f99
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if end is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, 0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js
new file mode 100644
index 0000000000..a2cc76eb35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(end).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ };
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, 0, o1);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js
new file mode 100644
index 0000000000..2a49db8598
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if start is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js
new file mode 100644
index 0000000000..b7a03a0ea1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(start).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var err = {
+ valueOf: function() {
+ throw new Error("ToInteger(start) runs before ToInteger(end)");
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, o, err);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js
new file mode 100644
index 0000000000..51851b1bfc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if target is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(s, 0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js
new file mode 100644
index 0000000000..d80ca93e1c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(target).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(o);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..fcf1f9323a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.copyWithin,
+ 'function',
+ 'implements TypedArray.prototype.copyWithin'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.copyWithin(0, 0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.copyWithin(0, 0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the copyWithin operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.copyWithin(0, 0);
+ throw new Test262Error('copyWithin completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js
new file mode 100644
index 0000000000..b67372010b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/return-this.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Returns `this`.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ 13. Return O.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA();
+ var result1 = sample1.copyWithin(0, 0);
+
+ assert.sameValue(result1, sample1);
+
+ var sample2 = new TA([1n, 2n, 3n]);
+ var result2 = sample2.copyWithin(1, 0);
+
+ assert.sameValue(result2, sample2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js
new file mode 100644
index 0000000000..ea081c6ef3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ If `end` is undefined, set final position to `this.length`.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined),
+ [1n, 2n, 3n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1),
+ [1n, 2n, 3n, 3n]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js
new file mode 100644
index 0000000000..f563d813ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/bit-precision.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Preservation of bit-level encoding
+info: |
+ Array.prototype.copyWithin (target, start [ , end ] )
+
+ 12. Repeat, while count > 0
+ [...]
+ d. If fromPresent is true, then
+ i. Let fromVal be ? Get(O, fromKey).
+ ii. Perform ? Set(O, toKey, fromVal, true).
+includes: [nans.js, compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+function body(FloatArray) {
+ var subject = new FloatArray(NaNs.length * 2);
+
+ NaNs.forEach(function(v, i) {
+ subject[i] = v;
+ });
+
+ var originalBytes, copiedBytes;
+ var length = NaNs.length * FloatArray.BYTES_PER_ELEMENT;
+
+ originalBytes = new Uint8Array(
+ subject.buffer,
+ 0,
+ length
+ );
+
+ subject.copyWithin(NaNs.length, 0);
+ copiedBytes = new Uint8Array(
+ subject.buffer,
+ length
+ );
+
+ assert(compareArray(originalBytes, copiedBytes));
+}
+
+testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js
new file mode 100644
index 0000000000..ec9f014d04
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/byteoffset.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2021 Chengzhong Wu. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ copyWithin should respect typedarray's byteOffset
+info: |
+ 22.2.3.5%TypedArray%.prototype.copyWithin ( target, start [ , end ] )
+ ...
+ 17. If count > 0, then
+ e. Let elementSize be the Element Size value specified in Table 72 for typedArrayName.
+ f. Let byteOffset be O.[[ByteOffset]].
+ g. Let toByteIndex be to × elementSize + byteOffset.
+ h. Let fromByteIndex be from × elementSize + byteOffset.
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = new TA([0, 1, 2, 3]);
+ assert.compareArray(
+ new TA(ta.buffer, TA.BYTES_PER_ELEMENT).copyWithin(2, 0),
+ [1, 2, 1],
+ 'copyWithin should respect typedarray\'s byteOffset'
+ );
+
+ assert.compareArray(
+ ta,
+ [0, 1, 2, 1],
+ 'underlying arraybuffer should have been updated'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js
new file mode 100644
index 0000000000..2b687ed165
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2019 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ SECURITY: end argument is coerced to an integer values
+ causing array detachment, but the value is still defined
+ by a prototype
+info: |
+ 22.2.3.5%TypedArray%.prototype.copyWithin ( target, start [ , end ] )
+ ...
+ 8. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
+ ...
+ 10. Let count be min(final - from, len - to).
+ 11. If count > 0, then
+ a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
+ b. Let buffer be O.[[ViewedArrayBuffer]].
+ c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta;
+ var array = [];
+
+ function detachAndReturnIndex(){
+ $DETACHBUFFER(ta.buffer);
+ Object.setPrototypeOf(ta, array);
+ return 101;
+ }
+
+ array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed
+ array.fill(7, 0);
+ ta = new TA(array);
+ assert.throws(TypeError, function(){
+ ta.copyWithin(0, 100, {valueOf : detachAndReturnIndex});
+ }, "should throw TypeError as array is detached");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js
new file mode 100644
index 0000000000..484f388021
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2019 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ SECURITY: end argument is coerced to an integer values
+ causing array detachment
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )
+
+ ...
+ 8. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
+ ...
+ 10. Let count be min(final - from, len - to).
+ 11. If count > 0, then
+ a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
+ b. Let buffer be O.[[ViewedArrayBuffer]].
+ c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta;
+ function detachAndReturnIndex(){
+ $DETACHBUFFER(ta.buffer);
+ return 900;
+ }
+
+ var array = [];
+ array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed
+ array.fill(7, 0);
+ ta = new TA(array);
+ assert.throws(TypeError, function(){
+ ta.copyWithin(0, 100, {valueOf : detachAndReturnIndex});
+ }, "should throw TypeError as array is detached");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js
new file mode 100644
index 0000000000..01a44699d5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-end.js
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ end argument is coerced to an integer values.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, null),
+ [0, 1, 2, 3]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN),
+ [0, 1, 2, 3]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, false),
+ [0, 1, 2, 3]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, true),
+ [0, 0, 2, 3]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, '-2'),
+ [0, 0, 1, 3]
+ ),
+ 'string "-2" value coerced to integer -2'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5),
+ [0, 0, 1, 3]
+ ),
+ 'float -2.5 value coerced to integer -2'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js
new file mode 100644
index 0000000000..559d3a18df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2019 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ SECURITY: start argument is coerced to an integer value, which detached
+ the array
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )
+
+ ...
+ 6. Let relativeStart be ? ToInteger(start).
+ ...
+ 10. Let count be min(final - from, len - to).
+ 11. If count > 0, then
+ a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data.
+ b. Let buffer be O.[[ViewedArrayBuffer]].
+ c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta;
+ function detachAndReturnIndex(){
+ $DETACHBUFFER(ta.buffer);
+ return 100;
+ }
+
+ var array = [];
+ array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed
+ array.fill(7, 0);
+ ta = new TA(array);
+ assert.throws(TypeError, function(){
+ ta.copyWithin(0, {valueOf : detachAndReturnIndex}, 1000);
+ }, "should throw TypeError as array is detached");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js
new file mode 100644
index 0000000000..9eb1399586
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-start.js
@@ -0,0 +1,94 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ start argument is coerced to an integer value.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, undefined),
+ [0, 0, 1, 2]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, false),
+ [0, 0, 1, 2]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, NaN),
+ [0, 0, 1, 2]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, null),
+ [0, 0, 1, 2]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, true),
+ [1, 2, 3, 3]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, '1'),
+ [1, 2, 3, 3]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0.5),
+ [0, 0, 1, 2]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1.5),
+ [1, 2, 3, 3]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js
new file mode 100644
index 0000000000..cfe5773f8f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/coerced-values-target.js
@@ -0,0 +1,102 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ target argument is coerced to an integer value.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(undefined, 1),
+ [1, 2, 3, 3]
+ ),
+ 'undefined value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(false, 1),
+ [1, 2, 3, 3]
+ ),
+ 'false value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(NaN, 1),
+ [1, 2, 3, 3]
+ ),
+ 'NaN value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(null, 1),
+ [1, 2, 3, 3]
+ ),
+ 'null value coerced to 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(true, 0),
+ [0, 0, 1, 2]
+ ),
+ 'true value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin('1', 0),
+ [0, 0, 1, 2]
+ ),
+ 'string "1" value coerced to 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0.5, 1),
+ [1, 2, 3, 3]
+ ),
+ '0.5 float value coerced to integer 0'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1.5, 0),
+ [0, 0, 1, 2]
+ ),
+ '1.5 float value coerced to integer 1'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin({}, 1),
+ [1, 2, 3, 3]
+ ),
+ 'object value coerced to integer 0'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js
new file mode 100644
index 0000000000..78e7bbda66
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/detached-buffer.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.copyWithin(obj, obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..d5cc8f993d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA();
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.sameValue(sample.copyWithin(0, 0), sample);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js
new file mode 100644
index 0000000000..61da74b61a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var copyWithin = TypedArray.prototype.copyWithin;
+
+assert.sameValue(typeof copyWithin, 'function');
+
+assert.throws(TypeError, function() {
+ copyWithin();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js
new file mode 100644
index 0000000000..1c7783022f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [, end ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.copyWithin, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.copyWithin();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js
new file mode 100644
index 0000000000..f7652c91da
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ %TypedArray%.prototype.copyWithin.length is 2.
+info: |
+ %TypedArray%.prototype.copyWithin (target, start [, end ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.copyWithin.length, 2);
+
+verifyNotEnumerable(TypedArray.prototype.copyWithin, "length");
+verifyNotWritable(TypedArray.prototype.copyWithin, "length");
+verifyConfigurable(TypedArray.prototype.copyWithin, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js
new file mode 100644
index 0000000000..7a888ea988
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ %TypedArray%.prototype.copyWithin.name is "copyWithin".
+info: |
+ %TypedArray%.prototype.copyWithin (target, start [, end ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.copyWithin.name, "copyWithin");
+
+verifyNotEnumerable(TypedArray.prototype.copyWithin, "name");
+verifyNotWritable(TypedArray.prototype.copyWithin, "name");
+verifyConfigurable(TypedArray.prototype.copyWithin, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js
new file mode 100644
index 0000000000..51fdfe1ab0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-end.js
@@ -0,0 +1,97 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative end argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, -1),
+ [1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1),
+ [0, 1, 0, 1, 2]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2),
+ [0, 2, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -2, -1),
+ [2, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1),
+ [0, 1, 3, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1),
+ [0, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1),
+ [0, 1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1),
+ [3, 1, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js
new file mode 100644
index 0000000000..97ae46c850
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js
@@ -0,0 +1,113 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative out of bounds end argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -2, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -9, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js
new file mode 100644
index 0000000000..31cfc40993
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js
@@ -0,0 +1,95 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with out of bounds negative start argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
+ from be min(relativeStart, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, -10),
+ [0, 1, 0, 1, 2]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity),
+ [1, 2, 1, 2, 3]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(10, -10),
+ [0, 1, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-9, -10),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js
new file mode 100644
index 0000000000..ac9c07bf31
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with out of bounds negative target argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
+ to be min(relativeTarget, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-10, 0),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2),
+ [2, 3, 4, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2),
+ [3, 4, 5, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js
new file mode 100644
index 0000000000..21c18b503e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-start.js
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative start argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let
+ from be min(relativeStart, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, -1),
+ [3, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(2, -2),
+ [0, 1, 3, 4, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(1, -2),
+ [0, 3, 4, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-1, -2),
+ [0, 1, 2, 2]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3),
+ [0, 1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2),
+ [3, 4, 2, 3, 4]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js
new file mode 100644
index 0000000000..b8fc48835a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/negative-target.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Set values with negative target argument.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let
+ to be min(relativeTarget, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-1, 0),
+ [0, 1, 2, 0]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2),
+ [0, 1, 2, 2, 3]
+ ),
+ '[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(-1, 2),
+ [0, 1, 2, 2]
+ ),
+ '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js
new file mode 100644
index 0000000000..569b7d95b4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Max value of end position is the this.length.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, 6),
+ [1, 2, 3, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity),
+ [2, 3, 4, 5, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6),
+ [0, 3, 4, 5, 4, 5]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity),
+ [1, 4, 5, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js
new file mode 100644
index 0000000000..d2b7e87fbc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js
@@ -0,0 +1,76 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Max values of target and start positions are this.length.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10),
+ [0, 1, 2, 3, 4, 5]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity),
+ [1, 2, 3, 4, 5]
+ ),
+ '[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js
new file mode 100644
index 0000000000..d0d152e3d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Copy values with non-negative target and start positions.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0),
+ [1, 2, 3, 4, 5, 6]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2),
+ [3, 4, 5, 6, 5, 6]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0),
+ [1, 2, 3, 1, 2, 3]
+ )
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4),
+ [0, 4, 5, 3, 4, 5]
+ )
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js
new file mode 100644
index 0000000000..62a6bfcd4a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js
@@ -0,0 +1,75 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Copy values with non-negative target, start and end positions.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 0, 0),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 0, 2),
+ [0, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, 2),
+ [1, 1, 2, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]'
+ );
+
+ /*
+ * 10. If from<to and to<from+count, then
+ * a. Let direction be - 1.
+ * b. Let from be from + count - 1.
+ * c. Let to be to + count - 1.
+ *
+ * 0 < 1, 1 < 0 + 2
+ * direction = -1
+ * from = 0 + 2 - 1
+ * to = 1 + 2 - 1
+ */
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(1, 0, 2),
+ [0, 0, 1, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(1, 0, 2) -> [0, 0, 1, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 5),
+ [0, 3, 4, 3, 4, 5]
+ ),
+ '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js
new file mode 100644
index 0000000000..34042bfc79
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.copyWithin does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.copyWithin),
+ false,
+ 'isConstructor(TypedArray.prototype.copyWithin) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.copyWithin();
+}, '`let u8 = new Uint8Array(1); new u8.copyWithin()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js
new file mode 100644
index 0000000000..96da143cac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ "copyWithin" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'copyWithin');
+verifyWritable(TypedArrayPrototype, 'copyWithin');
+verifyConfigurable(TypedArrayPrototype, 'copyWithin');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js
new file mode 100644
index 0000000000..09d60ac7d1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if end is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, 0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js
new file mode 100644
index 0000000000..5d7ef05e4e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(end).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ };
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, 0, o1);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js
new file mode 100644
index 0000000000..4a5455bf26
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if start is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js
new file mode 100644
index 0000000000..6a0843ae3f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(start).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 5. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var err = {
+ valueOf: function() {
+ throw new Error("ToInteger(start) runs before ToInteger(end)");
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(0, o, err);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js
new file mode 100644
index 0000000000..a1148053a7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt if target is a Symbol.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.copyWithin(s, 0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js
new file mode 100644
index 0000000000..0e9c56d1a2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Return abrupt from ToInteger(target).
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 3. Let relativeTarget be ? ToInteger(target).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var o = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.copyWithin(o);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..a9c562a62a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.copyWithin,
+ 'function',
+ 'implements TypedArray.prototype.copyWithin'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.copyWithin(0, 0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.copyWithin(0, 0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the copyWithin operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.copyWithin(0, 0);
+ throw new Test262Error('copyWithin completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js
new file mode 100644
index 0000000000..2ff0381574
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/return-this.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Returns `this`.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ 13. Return O.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA();
+ var result1 = sample1.copyWithin(0, 0);
+
+ assert.sameValue(result1, sample1);
+
+ var sample2 = new TA([1, 2, 3]);
+ var result2 = sample2.copyWithin(1, 0);
+
+ assert.sameValue(result2, sample2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js
new file mode 100644
index 0000000000..7f19b0b3ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var copyWithin = TypedArray.prototype.copyWithin;
+
+assert.throws(TypeError, function() {
+ copyWithin.call(undefined, 0, 0);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ copyWithin.call(null, 0, 0);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ copyWithin.call(42, 0, 0);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ copyWithin.call("1", 0, 0);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ copyWithin.call(true, 0, 0);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ copyWithin.call(false, 0, 0);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ copyWithin.call(s, 0, 0);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..9bd0b0458d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var copyWithin = TypedArray.prototype.copyWithin;
+
+assert.throws(TypeError, function() {
+ copyWithin.call({}, 0, 0);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ copyWithin.call([], 0, 0);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ copyWithin.call(ab, 0, 0);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ copyWithin.call(dv, 0, 0);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js
new file mode 100644
index 0000000000..e4e7072486
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/copyWithin/undefined-end.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.copywithin
+description: >
+ If `end` is undefined, set final position to `this.length`.
+info: |
+ 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] )
+
+ %TypedArray%.prototype.copyWithin is a distinct function that implements the
+ same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length" and the actual copying of values in step 12
+ must be performed in a manner that preserves the bit-level encoding of the
+ source data.
+
+ ...
+
+ 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] )
+
+ ...
+ 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined),
+ [1, 2, 3, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]'
+ );
+
+ assert(
+ compareArray(
+ new TA([0, 1, 2, 3]).copyWithin(0, 1),
+ [1, 2, 3, 3]
+ ),
+ '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..4412a8b2ad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/detached-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.entries();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/iter-prototype.js
new file mode 100644
index 0000000000..28b7e853de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/iter-prototype.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: >
+ The prototype of the returned iterator is ArrayIteratorPrototype
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key+value").
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.iterator, TypedArray]
+---*/
+
+var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]());
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n, 42n, 64n]);
+ var iter = sample.entries();
+
+ assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..8aed92e439
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.entries,
+ 'function',
+ 'implements TypedArray.prototype.entries'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.entries();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.entries();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the entries operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.entries();
+ throw new Test262Error('entries completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-itor.js
new file mode 100644
index 0000000000..a0a0b1519b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/return-itor.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Return an iterator for the entries.
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key+value").
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA([0n, 42n, 64n]);
+ var itor = typedArray.entries();
+
+ var next = itor.next();
+ assert(compareArray(next.value, [0, 0n]));
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert(compareArray(next.value, [1, 42n]));
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert(compareArray(next.value, [2, 64n]));
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, undefined);
+ assert.sameValue(next.done, true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js
new file mode 100644
index 0000000000..4a644f910c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/detached-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.entries();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js
new file mode 100644
index 0000000000..1e5894ad29
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-func.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var entries = TypedArray.prototype.entries;
+
+assert.sameValue(typeof entries, 'function');
+
+assert.throws(TypeError, function() {
+ entries();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js
new file mode 100644
index 0000000000..17ce58a45c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/invoked-as-method.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.entries, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.entries();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js
new file mode 100644
index 0000000000..7637d66454
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/iter-prototype.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: >
+ The prototype of the returned iterator is ArrayIteratorPrototype
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key+value").
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]());
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([0, 42, 64]);
+ var iter = sample.entries();
+
+ assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js
new file mode 100644
index 0000000000..f7c54bd2a0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: >
+ %TypedArray%.prototype.entries.length is 0.
+info: |
+ %TypedArray%.prototype.entries ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.entries.length, 0);
+
+verifyNotEnumerable(TypedArray.prototype.entries, "length");
+verifyNotWritable(TypedArray.prototype.entries, "length");
+verifyConfigurable(TypedArray.prototype.entries, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js
new file mode 100644
index 0000000000..4947bc59fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: >
+ %TypedArray%.prototype.entries.name is "entries".
+info: |
+ %TypedArray%.prototype.entries ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.entries.name, "entries");
+
+verifyNotEnumerable(TypedArray.prototype.entries, "name");
+verifyNotWritable(TypedArray.prototype.entries, "name");
+verifyConfigurable(TypedArray.prototype.entries, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js
new file mode 100644
index 0000000000..8b28d47a0f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.entries does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.entries),
+ false,
+ 'isConstructor(TypedArray.prototype.entries) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.entries();
+}, '`let u8 = new Uint8Array(1); new u8.entries()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js
new file mode 100644
index 0000000000..ce4a744117
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: >
+ "entries" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'entries');
+verifyWritable(TypedArrayPrototype, 'entries');
+verifyConfigurable(TypedArrayPrototype, 'entries');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..c1cf23c0b1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.entries,
+ 'function',
+ 'implements TypedArray.prototype.entries'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.entries();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.entries();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the entries operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.entries();
+ throw new Test262Error('entries completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js
new file mode 100644
index 0000000000..16923a967c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/return-itor.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Return an iterator for the entries.
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key+value").
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var sample = [0, 42, 64];
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(sample);
+ var itor = typedArray.entries();
+
+ var next = itor.next();
+ assert(compareArray(next.value, [0, 0]));
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert(compareArray(next.value, [1, 42]));
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert(compareArray(next.value, [2, 64]));
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, undefined);
+ assert.sameValue(next.done, true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js
new file mode 100644
index 0000000000..58afdee779
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-object.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var entries = TypedArray.prototype.entries;
+
+assert.throws(TypeError, function() {
+ entries.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ entries.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ entries.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ entries.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ entries.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ entries.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ entries.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..f0574cd6b2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.entries
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.6 %TypedArray%.prototype.entries ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var entries = TypedArray.prototype.entries;
+
+assert.throws(TypeError, function() {
+ entries.call({});
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ entries.call([]);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ entries.call(ab);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ entries.call(dv);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..feb32a4e4b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..7539c73698
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..dcd3209e2a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.every(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..44ad01e601
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - key");
+ assert.sameValue(results[1][1], 1, "results[1][1] - key");
+
+ assert.sameValue(results[0][0], 7n, "results[0][0] - value");
+ assert.sameValue(results[1][0], 8n, "results[1][0] - value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..d0146e81d3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Throws a TypeError if callbackfn is not callable
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.every();
+ }, "no args");
+
+ assert.throws(TypeError, function() {
+ sample.every(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.every(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.every("abc");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.every(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.every(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.every(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.every(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.every({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.every(sample);
+ }, "same typedArray instance");
+
+ assert.throws(TypeError, function() {
+ sample.every(Symbol("1"));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..b933d0618e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().every(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..4de9055dca
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+
+ sample.every(function() {
+ return 43;
+ });
+
+ assert.sameValue(sample[0], 40n, "[0] == 40");
+ assert.sameValue(sample[1], 41n, "[1] == 41");
+ assert.sameValue(sample[2], 42n, "[2] == 42");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..13abf3af2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Returns abrupt from callbackfn
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.every(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..9681d5e39e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.every(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7n),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+
+ return true;
+ });
+
+ assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..b0a04b738e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/callbackfn-this.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.every(function() {
+ results1.push(this);
+ return true;
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.every(function() {
+ results2.push(this);
+ return true;
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..d90c073acb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.every(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..fabfb42348
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.every(function() {
+ calls++;
+ return true;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..7d9bf0d85f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.every,
+ 'function',
+ 'implements TypedArray.prototype.every'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.every(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.every(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the every operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.every(() => {});
+ throw new Test262Error('every completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js
new file mode 100644
index 0000000000..20d55bc611
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Returns false if any callbackfn call returns a coerced false.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.every(function() {
+ called++;
+ if (called === 1) {
+ return true;
+ }
+ return val;
+ });
+ assert.sameValue(called, 2, "callbackfn called until it returned " + val);
+ assert.sameValue(result, false, "result is false when it returned " + val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js
new file mode 100644
index 0000000000..ecd8112108
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Returns true if every callbackfn returns a coerced true.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+ var values = [
+ true,
+ 1,
+ "test262",
+ Symbol("1"),
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ];
+ var sample = new TA(values.length);
+ var result = sample.every(function() {
+ called++;
+ return values.unshift();
+ });
+
+ assert.sameValue(called, sample.length, "callbackfn called for each index");
+ assert.sameValue(result, true, "return is true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..bd074ea54e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/BigInt/values-are-not-cached.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.every(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ return true;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..643e3d9ab1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..3db2e4efb3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..c31447279d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-detachbuffer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 5. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.every(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..b9f512de47
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.every(function() {
+ results.push(arguments);
+ return true;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - key");
+ assert.sameValue(results[1][1], 1, "results[1][1] - key");
+
+ assert.sameValue(results[0][0], 7, "results[0][0] - value");
+ assert.sameValue(results[1][0], 8, "results[1][0] - value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..a3a9538f6a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-callable-throws.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Throws a TypeError if callbackfn is not callable
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.every();
+ }, "no args");
+
+ assert.throws(TypeError, function() {
+ sample.every(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.every(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.every("abc");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.every(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.every(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.every(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.every(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.every({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.every(sample);
+ }, "same typedArray instance");
+
+ assert.throws(TypeError, function() {
+ sample.every(Symbol("1"));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..5218382720
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().every(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js
new file mode 100644
index 0000000000..6dca2c649d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-resize.js
@@ -0,0 +1,76 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.every(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return true;
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, true, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.every(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return true;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, true, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..8f6678cf55
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+
+ sample.every(function() {
+ return 43;
+ });
+
+ assert.sameValue(sample[0], 40, "[0] == 40");
+ assert.sameValue(sample[1], 41, "[1] == 41");
+ assert.sameValue(sample[2], 42, "[2] == 42");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..4b7474124c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-returns-abrupt.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Returns abrupt from callbackfn
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.every(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..b9d28709b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.every(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+
+ return true;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js
new file mode 100644
index 0000000000..0619270eaf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/callbackfn-this.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.every(function() {
+ results1.push(this);
+ return true;
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.every(function() {
+ results2.push(this);
+ return true;
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js
new file mode 100644
index 0000000000..22e87b85f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.every(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..ec9c9ae8ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.every(function() {
+ calls++;
+ return true;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js
new file mode 100644
index 0000000000..c62503b63e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var every = TypedArray.prototype.every;
+
+assert.sameValue(typeof every, 'function');
+
+assert.throws(TypeError, function() {
+ every();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js
new file mode 100644
index 0000000000..f7e77e539b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.every, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.every();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js
new file mode 100644
index 0000000000..af76735482
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ %TypedArray%.prototype.every.length is 1.
+info: |
+ %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.every.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.every, "length");
+verifyNotWritable(TypedArray.prototype.every, "length");
+verifyConfigurable(TypedArray.prototype.every, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js
new file mode 100644
index 0000000000..53cae5735e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ %TypedArray%.prototype.every.name is "every".
+info: |
+ %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.every.name, "every");
+
+verifyNotEnumerable(TypedArray.prototype.every, "name");
+verifyNotWritable(TypedArray.prototype.every, "name");
+verifyConfigurable(TypedArray.prototype.every, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js
new file mode 100644
index 0000000000..16bffa2af1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.every does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.every),
+ false,
+ 'isConstructor(TypedArray.prototype.every) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.every(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.every(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js
new file mode 100644
index 0000000000..f4d99d733a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ "every" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'every');
+verifyWritable(TypedArrayPrototype, 'every');
+verifyConfigurable(TypedArrayPrototype, 'every');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..2b68002982
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.every,
+ 'function',
+ 'implements TypedArray.prototype.every'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.every(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.every(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the every operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.every(() => {});
+ throw new Test262Error('every completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js
new file mode 100644
index 0000000000..437bfd2b3d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Returns false if any callbackfn call returns a coerced false.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.every(function() {
+ called++;
+ if (called === 1) {
+ return true;
+ }
+ return val;
+ });
+ assert.sameValue(called, 2, "callbackfn called until it returned " + val);
+ assert.sameValue(result, false, "result is false when it returned " + val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js
new file mode 100644
index 0000000000..b75a13bb27
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Returns true if every callbackfn returns a coerced true.
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+ var values = [
+ true,
+ 1,
+ "test262",
+ Symbol("1"),
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ];
+ var sample = new TA(values.length);
+ var result = sample.every(function() {
+ called++;
+ return values.unshift();
+ });
+
+ assert.sameValue(called, sample.length, "callbackfn called for each index");
+ assert.sameValue(result, true, "return is true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js
new file mode 100644
index 0000000000..9086272c65
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var every = TypedArray.prototype.every;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ every.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ every.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ every.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ every.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ every.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ every.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ every.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..5d73f3d3d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var every = TypedArray.prototype.every;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ every.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ every.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ every.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ every.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js
new file mode 100644
index 0000000000..6b64c3fb8d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/every/values-are-not-cached.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.every
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.every is a distinct function that implements the same
+ algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ sample.every(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ return true;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js
new file mode 100644
index 0000000000..f7ba55c725
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/coerced-indexes.js
@@ -0,0 +1,106 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills elements from coerced to Integer `start` and `end` values
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
+ min(relativeStart, len).
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, undefined), [1n, 1n]),
+ '`undefined` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 0, undefined), [1n, 1n]),
+ 'If end is undefined, let relativeEnd be len'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, null), [1n, 1n]),
+ '`null` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 0, null), [0n, 0n]),
+ '`null` end coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, true), [0n, 1n]),
+ '`true` start coerced to 1'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 0, true), [1n, 0n]),
+ '`true` end coerced to 1'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, false), [1n, 1n]),
+ '`false` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 0, false), [0n, 0n]),
+ '`false` end coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, NaN), [1n, 1n]),
+ '`NaN` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 0, NaN), [0n, 0n]),
+ '`NaN` end coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, '1'), [0n, 1n]),
+ 'string start coerced'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 0, '1'), [1n, 0n]),
+ 'string end coerced'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 1.5), [0n, 1n]),
+ 'start as a float number coerced'
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n]).fill(1n, 0, 1.5), [1n, 0n]),
+ 'end as a float number coerced'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..0da0298fd6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/detached-buffer.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.fill(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js
new file mode 100644
index 0000000000..5a7302c362
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with non numeric values values.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. If O.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ var n = 1n;
+ sample.fill({ valueOf() { return n++; } });
+
+ assert.sameValue(n, 2n, "additional unexpected ToBigInt() calls");
+ assert.sameValue(sample[0], 1n, "incorrect ToNumber result in index 0");
+ assert.sameValue(sample[1], 1n, "incorrect ToNumber result in index 1");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js
new file mode 100644
index 0000000000..012c31fc29
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements from a with a custom start and end indexes.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
+ min(relativeStart, len).
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(compareArray(new TA([0n, 0n, 0n]).fill(8n, 1, 2), [0n, 8n, 0n]));
+ assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -3, 4), [0n, 0n, 8n, 8n, 0n]));
+ assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -2, -1), [0n, 0n, 0n, 8n, 0n]));
+ assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -1, -3), [0n, 0n, 0n, 0n, 0n]));
+ assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, 1, 3), [0n, 8n, 8n, 0n, 0n]));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js
new file mode 100644
index 0000000000..a50c36f53f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with non numeric values values.
+info: |
+ %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ Otherwise, set value to ? ToNumber(value).
+ Let relativeStart be ? ToIntegerOrInfinity(start).
+ If relativeStart is -Infinity, let k be 0.
+ Else if relativeStart < 0, let k be max(len + relativeStart, 0).
+ Else, let k be min(relativeStart, len).
+ If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
+ If relativeEnd is -Infinity, let final be 0.
+ Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
+ Else, let final be min(relativeEnd, len).
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ Repeat, while k < final,
+ Let Pk be ! ToString(F(k)).
+ Perform ! Set(O, Pk, value, true).
+ Set k to k + 1.
+ Return O.
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n]);
+
+ assert.throws(TypeError, function() {
+ sample.fill(undefined);
+ }, "abrupt completion from undefined");
+
+ assert.throws(TypeError, function() {
+ sample.fill(null);
+ }, "abrupt completion from null");
+
+ assert.throws(SyntaxError, function() {
+ sample.fill("nonsense");
+ }, "abrupt completion from string");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js
new file mode 100644
index 0000000000..7033d70ba7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js
@@ -0,0 +1,85 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with non numeric values values.
+info: |
+ %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ Otherwise, set value to ? ToNumber(value).
+ Let relativeStart be ? ToIntegerOrInfinity(start).
+ If relativeStart is -Infinity, let k be 0.
+ Else if relativeStart < 0, let k be max(len + relativeStart, 0).
+ Else, let k be min(relativeStart, len).
+ If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
+ If relativeEnd is -Infinity, let final be 0.
+ Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
+ Else, let final be min(relativeEnd, len).
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ Repeat, while k < final,
+ Let Pk be ! ToString(F(k)).
+ Perform ! Set(O, Pk, value, true).
+ Set k to k + 1.
+ Return O.
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n]);
+ sample.fill(false);
+ assert.sameValue(sample[0], 0n, "false => 0");
+
+ sample = new TA([42n]);
+ sample.fill(true);
+ assert.sameValue(sample[0], 1n, "true => 1");
+
+ sample = new TA([42n]);
+ sample.fill("7");
+ assert.sameValue(sample[0], 7n, "string conversion");
+
+ sample = new TA([42n]);
+ sample.fill({
+ toString: function() {
+ return "1";
+ },
+ valueOf: function() {
+ return 7n;
+ }
+ });
+ assert.sameValue(sample[0], 7n, "object valueOf conversion before toString");
+
+ sample = new TA([42n]);
+ sample.fill({
+ toString: function() {
+ return "7";
+ }
+ });
+ assert.sameValue(sample[0], 7n, "object toString when valueOf is absent");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js
new file mode 100644
index 0000000000..00c0cee49f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements from a with a custom end index.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 1), [8n, 0n, 0n]),
+ "Fill elements from custom end position"
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -1), [8n, 8n, 0n]),
+ "negative end sets final position to max((length + relativeEnd), 0)"
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 5), [8n, 8n, 8n]),
+ "end position is never higher than of length"
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -4), [0n, 0n, 0n]),
+ "end position is 0 when (len + relativeEnd) < 0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js
new file mode 100644
index 0000000000..ec09940a0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements from a with a custom start index.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
+ min(relativeStart, len).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, 1), [0n, 8n, 8n]),
+ "Fill elements from custom start position"
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, 4), [0n, 0n, 0n]),
+ "start position is never higher than length"
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, -1), [0n, 0n, 8n]),
+ "start < 0 sets initial position to max((len + relativeStart), 0)"
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n, -5), [8n, 8n, 8n]),
+ "start position is 0 when (len + relativeStart) < 0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js
new file mode 100644
index 0000000000..257b5d7017
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Throws a TypeError if value is a Symbol
+info: |
+ %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ Otherwise, set value to ? ToNumber(value).
+ Let relativeStart be ? ToIntegerOrInfinity(start).
+ If relativeStart is -Infinity, let k be 0.
+ Else if relativeStart < 0, let k be max(len + relativeStart, 0).
+ Else, let k be min(relativeStart, len).
+ If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
+ If relativeEnd is -Infinity, let final be 0.
+ Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
+ Else, let final be min(relativeEnd, len).
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ Repeat, while k < final,
+ Let Pk be ! ToString(F(k)).
+ Perform ! Set(O, Pk, value, true).
+ Set k to k + 1.
+ Return O.
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol('1');
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.fill(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js
new file mode 100644
index 0000000000..96cde20493
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/fill-values.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with `value` from a default start and index.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 7. Repeat, while k < final
+ a. Let Pk be ! ToString(k).
+ b. Perform ? Set(O, Pk, value, true).
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA().fill(8n),
+ []
+ ),
+ "does not fill an empty instance"
+ );
+
+ assert(
+ compareArray(new TA([0n, 0n, 0n]).fill(8n), [8n, 8n, 8n]),
+ "Default start and end indexes are 0 and this.length"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..dec320a415
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA(1);
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.sameValue(sample.fill(1n, 0), sample);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js
new file mode 100644
index 0000000000..6dac568fb4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt if end is a Symbol.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var end = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.fill(1n, 0, end);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js
new file mode 100644
index 0000000000..b329771ae3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt from ToInteger(end).
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var end = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.fill(1n, 0, end);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js
new file mode 100644
index 0000000000..9f46b32318
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Returns abrupt from value set
+info: |
+ %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ Otherwise, set value to ? ToNumber(value).
+ Let relativeStart be ? ToIntegerOrInfinity(start).
+ If relativeStart is -Infinity, let k be 0.
+ Else if relativeStart < 0, let k be max(len + relativeStart, 0).
+ Else, let k be min(relativeStart, len).
+ If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
+ If relativeEnd is -Infinity, let final be 0.
+ Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
+ Else, let final be min(relativeEnd, len).
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ Repeat, while k < final,
+ Let Pk be ! ToString(F(k)).
+ Perform ! Set(O, Pk, value, true).
+ Set k to k + 1.
+ Return O.
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n]);
+ var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.fill(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js
new file mode 100644
index 0000000000..c1391a13dc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt from ToInteger(start) as a Symbol.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var start = Symbol(1);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.fill(1n, start);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js
new file mode 100644
index 0000000000..7e9f04c49e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt from ToInteger(start).
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var start = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.fill(1n, start);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..7d483c1ce0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.fill,
+ 'function',
+ 'implements TypedArray.prototype.fill'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.fill(0n);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.fill(0n);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the fill operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.fill(0n);
+ throw new Test262Error('fill completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-this.js
new file mode 100644
index 0000000000..c9ab8f15d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/return-this.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Returns `this`.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA();
+ var result1 = sample1.fill(1n);
+
+ assert.sameValue(result1, sample1);
+
+ var sample2 = new TA(42);
+ var result2 = sample2.fill(7n);
+ assert.sameValue(result2, sample2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js
new file mode 100644
index 0000000000..ccaa1ae6bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-end-detach.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2020 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Security Throws a TypeError if end coercion detaches the buffer
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ 9. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
+ 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(10);
+
+ function detachAndReturnIndex(){
+ $DETACHBUFFER(sample.buffer);
+ return 10;
+ }
+
+ assert.throws(TypeError, function() {
+ sample.fill(0x77, 0, {valueOf: detachAndReturnIndex});
+ }, "Detachment when coercing end should throw TypeError");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js
new file mode 100644
index 0000000000..f2f78c3d39
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-indexes.js
@@ -0,0 +1,106 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills elements from coerced to Integer `start` and `end` values
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
+ min(relativeStart, len).
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(new TA([0, 0]).fill(1, undefined), [1, 1]),
+ '`undefined` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 0, undefined), [1, 1]),
+ 'If end is undefined, let relativeEnd be len'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, null), [1, 1]),
+ '`null` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 0, null), [0, 0]),
+ '`null` end coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, true), [0, 1]),
+ '`true` start coerced to 1'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 0, true), [1, 0]),
+ '`true` end coerced to 1'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, false), [1, 1]),
+ '`false` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 0, false), [0, 0]),
+ '`false` end coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, NaN), [1, 1]),
+ '`NaN` start coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 0, NaN), [0, 0]),
+ '`NaN` end coerced to 0'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, '1'), [0, 1]),
+ 'string start coerced'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 0, '1'), [1, 0]),
+ 'string end coerced'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 1.5), [0, 1]),
+ 'start as a float number coerced'
+ );
+
+ assert(
+ compareArray(new TA([0, 0]).fill(1, 0, 1.5), [1, 0]),
+ 'end as a float number coerced'
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js
new file mode 100644
index 0000000000..63656210b1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-start-detach.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Security Throws a TypeError if start coercion detaches the buffer
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ 6. Let relativeStart be ? ToInteger(start).
+ ...
+ 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(10);
+
+ function detachAndReturnIndex(){
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+
+ assert.throws(TypeError, function() {
+ sample.fill(0x77, {valueOf: detachAndReturnIndex}, 10);
+ }, "Detachment when coercing start should throw TypeError");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js
new file mode 100644
index 0000000000..cdfa9efd88
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/coerced-value-detach.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Security Throws a TypeError if value coercion detaches the buffer
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ 5. Otherwise, set value to ? ToNumber(value).
+ ...
+ 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(10);
+
+ function detachAndReturnIndex(){
+ $DETACHBUFFER(sample.buffer);
+ return 0x77;
+ }
+
+ assert.throws(TypeError, function() {
+ sample.fill({valueOf: detachAndReturnIndex}, 0, 10);
+ }, "Detachment when coercing value should throw TypeError");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js
new file mode 100644
index 0000000000..e81231bc64
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/detached-buffer.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.fill(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js
new file mode 100644
index 0000000000..0abceac140
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-once.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with non numeric values values.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let _value_ be ? ToNumber(_value_).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ var n = 1;
+ sample.fill({ valueOf() { return n++; } });
+
+ assert.sameValue(n, 2, "additional unexpected ToNumber() calls");
+ assert.sameValue(sample[0], 1, "incorrect ToNumber result in index 0");
+ assert.sameValue(sample[1], 1, "incorrect ToNumber result in index 1");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js
new file mode 100644
index 0000000000..c8e2908fc0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js
@@ -0,0 +1,103 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ An implementation must always choose either the same encoding for each implementation distinguishable *NaN* value, or an implementation-defined canonical value.
+info: |
+ This test does not compare the actual byte values, instead it simply checks that
+ the value is some valid NaN encoding.
+
+ ---
+
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ #sec-array.prototype.fill
+ Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 7. Repeat, while k < final
+ a. Let Pk be ! ToString(k).
+ b. Perform ? Set(O, Pk, value, true).
+ ...
+
+ #sec-setvalueinbuffer
+ SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian).
+
+ #sec-numbertorawbytes
+ NumberToRawBytes( type, value, isLittleEndian )
+
+ 1. If type is "Float32", then
+ a. Set rawBytes to a List containing the 4 bytes that are the result
+ of converting value to IEEE 754-2008 binary32 format using “Round to
+ nearest, ties to even” rounding mode. If isLittleEndian is false, the
+ bytes are arranged in big endian order. Otherwise, the bytes are
+ arranged in little endian order. If value is NaN, rawValue may be set
+ to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
+ encoding. An implementation must always choose either the same encoding
+ for each implementation distinguishable *NaN* value, or an
+ implementation-defined canonical value.
+ 2. Else, if type is "Float64", then
+ a. Set _rawBytes_ to a List containing the 8 bytes that are the IEEE
+ 754-2008 binary64 format encoding of _value_. If _isLittleEndian_ is
+ *false*, the bytes are arranged in big endian order. Otherwise,
+ the bytes are arranged in little endian order. If _value_ is *NaN*,
+ _rawValue_ may be set to any implementation chosen IEEE 754-2008
+ binary64 format Not-a-Number encoding. An implementation must
+ always choose either the same encoding for each implementation
+ distinguishable *NaN* value, or an implementation-defined
+ canonical value.
+ ...
+
+ #sec-isnan-number
+
+ NOTE: A reliable way for ECMAScript code to test if a value X is a NaN is
+ an expression of the form X !== X. The result will be true if and only
+ if X is a NaN.
+includes: [nans.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(FA) {
+ var precision = FA === Float32Array ? "single" : "double";
+ var samples = new FA(3);
+ var controls, idx, aNaN;
+
+ for (idx = 0; idx < NaNs.length; ++idx) {
+ aNaN = NaNs[idx];
+ controls = new Float32Array([aNaN, aNaN, aNaN]);
+
+ samples.fill(aNaN);
+
+ for (var i = 0; i < samples.length; i++) {
+ var sample = samples[i];
+ var control = controls[i];
+
+ assert(
+ samples[i] !== samples[i],
+ `samples (index=${idx}) produces a valid NaN (${precision} precision)`
+ );
+
+ assert(
+ controls[i] !== controls[i],
+ `controls (index=${idx}) produces a valid NaN (${precision} precision)`
+ );
+ }
+ }
+}, [Float32Array, Float64Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js
new file mode 100644
index 0000000000..c23bfe9b2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with non numeric values values.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 7. Repeat, while k < final
+ a. Let Pk be ! ToString(k).
+ b. Perform ? Set(O, Pk, value, true).
+ ...
+
+ 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ ...
+ 8. If type is "Float32", then
+ ...
+ 9. Else, if type is "Float64", then
+ ...
+ 10. Else,
+ ...
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 50 for Element Type type.
+ c. Let intValue be convOp(value).
+ d. If intValue ≥ 0, then
+ ...
+ e. Else,
+ ...
+includes: [byteConversionValues.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
+ var sample = new TA([initial]);
+
+ sample.fill(value);
+
+ assert.sameValue(sample[0], expected, value + " converts to " + expected);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js
new file mode 100644
index 0000000000..7f8d6dd51f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements from a with a custom start and end indexes.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
+ min(relativeStart, len).
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(compareArray(new TA([0, 0, 0]).fill(8, 1, 2), [0, 8, 0]));
+ assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8, 0]));
+ assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0]));
+ assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0]));
+ assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, 1, 3), [0, 8, 8, 0, 0]));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js
new file mode 100644
index 0000000000..371f9bde5f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-non-numeric.js
@@ -0,0 +1,89 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with non numeric values values.
+info: |
+ %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ Otherwise, set value to ? ToNumber(value).
+ Let relativeStart be ? ToIntegerOrInfinity(start).
+ If relativeStart is -Infinity, let k be 0.
+ Else if relativeStart < 0, let k be max(len + relativeStart, 0).
+ Else, let k be min(relativeStart, len).
+ If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
+ If relativeEnd is -Infinity, let final be 0.
+ Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
+ Else, let final be min(relativeEnd, len).
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ Repeat, while k < final,
+ Let Pk be ! ToString(F(k)).
+ Perform ! Set(O, Pk, value, true).
+ Set k to k + 1.
+ Return O.
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42]);
+ sample.fill(null);
+ assert.sameValue(sample[0], 0, "null => 0");
+
+ sample = new TA([42]);
+ sample.fill(false);
+ assert.sameValue(sample[0], 0, "false => 0");
+
+ sample = new TA([42]);
+ sample.fill(true);
+ assert.sameValue(sample[0], 1, "true => 1");
+
+ sample = new TA([42]);
+ sample.fill("7");
+ assert.sameValue(sample[0], 7, "string conversion");
+
+ sample = new TA([42]);
+ sample.fill({
+ toString: function() {
+ return "1";
+ },
+ valueOf: function() {
+ return 7;
+ }
+ });
+ assert.sameValue(sample[0], 7, "object valueOf conversion before toString");
+
+ sample = new TA([42]);
+ sample.fill({
+ toString: function() {
+ return "7";
+ }
+ });
+ assert.sameValue(sample[0], 7, "object toString when valueOf is absent");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js
new file mode 100644
index 0000000000..086bf5d1b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-end.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements from a with a custom end index.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let
+ final be min(relativeEnd, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, 0, 1), [8, 0, 0]),
+ "Fill elements from custom end position"
+ );
+
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, 0, -1), [8, 8, 0]),
+ "negative end sets final position to max((length + relativeEnd), 0)"
+ );
+
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, 0, 5), [8, 8, 8]),
+ "end position is never higher than of length"
+ );
+
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, 0, -4), [0, 0, 0]),
+ "end position is 0 when (len + relativeEnd) < 0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js
new file mode 100644
index 0000000000..d418285a8e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-relative-start.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements from a with a custom start index.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be
+ min(relativeStart, len).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, 1), [0, 8, 8]),
+ "Fill elements from custom start position"
+ );
+
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, 4), [0, 0, 0]),
+ "start position is never higher than length"
+ );
+
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, -1), [0, 0, 8]),
+ "start < 0 sets initial position to max((len + relativeStart), 0)"
+ );
+
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8, -5), [8, 8, 8]),
+ "start position is 0 when (len + relativeStart) < 0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js
new file mode 100644
index 0000000000..48bbe9c94e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values-symbol-throws.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Throws a TypeError if value is a Symbol
+info: |
+ %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ Otherwise, set value to ? ToNumber(value).
+ Let relativeStart be ? ToIntegerOrInfinity(start).
+ If relativeStart is -Infinity, let k be 0.
+ Else if relativeStart < 0, let k be max(len + relativeStart, 0).
+ Else, let k be min(relativeStart, len).
+ If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
+ If relativeEnd is -Infinity, let final be 0.
+ Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
+ Else, let final be min(relativeEnd, len).
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ Repeat, while k < final,
+ Let Pk be ! ToString(F(k)).
+ Perform ! Set(O, Pk, value, true).
+ Set k to k + 1.
+ Return O.
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol('1');
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.fill(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js
new file mode 100644
index 0000000000..a3a4bad901
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/fill-values.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Fills all the elements with `value` from a default start and index.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 7. Repeat, while k < final
+ a. Let Pk be ! ToString(k).
+ b. Perform ? Set(O, Pk, value, true).
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ assert(
+ compareArray(
+ new TA().fill(8),
+ []
+ ),
+ "does not fill an empty instance"
+ );
+
+ assert(
+ compareArray(new TA([0, 0, 0]).fill(8), [8, 8, 8]),
+ "Default start and end indexes are 0 and this.length"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..bdd67a6212
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/get-length-ignores-length-prop.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA(1);
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.sameValue(sample.fill(1, 0), sample);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js
new file mode 100644
index 0000000000..10b81cbf80
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fill = TypedArray.prototype.fill;
+
+assert.sameValue(typeof fill, 'function');
+
+assert.throws(TypeError, function() {
+ fill();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js
new file mode 100644
index 0000000000..2293f0644a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.fill, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.fill();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js
new file mode 100644
index 0000000000..2106e754bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ %TypedArray%.prototype.fill.length is 1.
+info: |
+ %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.fill.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.fill, "length");
+verifyNotWritable(TypedArray.prototype.fill, "length");
+verifyConfigurable(TypedArray.prototype.fill, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js
new file mode 100644
index 0000000000..c1e6729cee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ %TypedArray%.prototype.fill.name is "fill".
+info: |
+ %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.fill.name, "fill");
+
+verifyNotEnumerable(TypedArray.prototype.fill, "name");
+verifyNotWritable(TypedArray.prototype.fill, "name");
+verifyConfigurable(TypedArray.prototype.fill, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js
new file mode 100644
index 0000000000..984f6435ce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.fill does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.fill),
+ false,
+ 'isConstructor(TypedArray.prototype.fill) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.fill();
+}, '`let u8 = new Uint8Array(1); new u8.fill()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js
new file mode 100644
index 0000000000..b9de7e83b7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ "fill" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'fill');
+verifyWritable(TypedArrayPrototype, 'fill');
+verifyConfigurable(TypedArrayPrototype, 'fill');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js
new file mode 100644
index 0000000000..0c77c38dcd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt if end is a Symbol.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var end = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.fill(1, 0, end);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js
new file mode 100644
index 0000000000..aa95620a25
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-end.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt from ToInteger(end).
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var end = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.fill(1, 0, end);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js
new file mode 100644
index 0000000000..90d3c469ac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-set-value.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Returns abrupt from value set
+info: |
+ %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ Otherwise, set value to ? ToNumber(value).
+ Let relativeStart be ? ToIntegerOrInfinity(start).
+ If relativeStart is -Infinity, let k be 0.
+ Else if relativeStart < 0, let k be max(len + relativeStart, 0).
+ Else, let k be min(relativeStart, len).
+ If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
+ If relativeEnd is -Infinity, let final be 0.
+ Else if relativeEnd < 0, let final be max(len + relativeEnd, 0).
+ Else, let final be min(relativeEnd, len).
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ Repeat, while k < final,
+ Let Pk be ! ToString(F(k)).
+ Perform ! Set(O, Pk, value, true).
+ Set k to k + 1.
+ Return O.
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42]);
+ var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.fill(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js
new file mode 100644
index 0000000000..2a94acc7e4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt from ToInteger(start) as a Symbol.
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var start = Symbol(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.fill(1, start);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js
new file mode 100644
index 0000000000..e7016c9159
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-start.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Return abrupt from ToInteger(start).
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ %TypedArray%.prototype.fill is a distinct function that implements the same
+ algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse. However, such optimization
+ must not introduce any observable changes in the specified behaviour of the
+ algorithm.
+
+ ...
+
+ 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] )
+
+ ...
+ 3. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var start = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(Test262Error, function() {
+ sample.fill(1, start);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f518d85921
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.fill,
+ 'function',
+ 'implements TypedArray.prototype.fill'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.fill(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.fill(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the fill operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.fill(0);
+ throw new Test262Error('fill completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js
new file mode 100644
index 0000000000..afba1718ac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/return-this.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Returns `this`.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA();
+ var result1 = sample1.fill(1);
+
+ assert.sameValue(result1, sample1);
+
+ var sample2 = new TA(42);
+ var result2 = sample2.fill(7);
+ assert.sameValue(result2, sample2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js
new file mode 100644
index 0000000000..17d8f004c5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var fill = TypedArray.prototype.fill;
+
+assert.throws(TypeError, function() {
+ fill.call(undefined, 0);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ fill.call(null, 0);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ fill.call(42, 0);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ fill.call("1", 0);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ fill.call(true, 0);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ fill.call(false, 0);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ fill.call(s, 0);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..4568ee60c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.fill
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fill = TypedArray.prototype.fill;
+
+assert.throws(TypeError, function() {
+ fill.call({}, 0);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ fill.call([], 0);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ fill.call(ab, 0);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ fill.call(dv, 0);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js
new file mode 100644
index 0000000000..5582bb10f1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/arraylength-internal.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Uses internal ArrayLength instead of length property
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. Let len be the value of O's [[ArrayLength]] internal slot.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 4, "interactions are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..7d827de7d3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.filter(function() {
+ results.push(arguments);
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..ed033a7010
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.filter(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js
new file mode 100644
index 0000000000..af35a1f777
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: callbackfn is called for each item before TypedArraySpeciesCreate
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var length = 42;
+ var sample = new TA(length);
+ var calls = 0;
+ var before = false;
+
+ sample.constructor = {};
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ before = calls === length;
+ }
+ });
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(calls, 42, "callbackfn called for each item");
+ assert.sameValue(before, true, "all callbackfn called before");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js
new file mode 100644
index 0000000000..3cf2636d01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: callbackfn is called for each item before TypedArraySpeciesCreate
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var length = 42;
+ var sample = new TA(length);
+ var calls = 0;
+ var before = false;
+
+ sample.constructor = {};
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ before = calls === length;
+ }
+ });
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(calls, 42, "callbackfn called for each item");
+ assert.sameValue(before, true, "all callbackfn called before");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..30e4e3c3eb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2021 Apple Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(O, Pk).
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.filter(function() {
+ var flag = true;
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ } else {
+ flag = false;
+ }
+ loops++;
+ return flag;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js
new file mode 100644
index 0000000000..754091ed37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.filter(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+
+ assert.sameValue(results[0][0], 7n, "results[0][0] - kValue");
+ assert.sameValue(results[1][0], 8n, "results[1][0] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..5b718c30ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+
+ assert.throws(TypeError, function() {
+ sample.filter();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.filter(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.filter(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.filter(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.filter(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.filter({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.filter([]);
+ }, "[]");
+
+ assert.throws(TypeError, function() {
+ sample.filter(1);
+ }, "Number");
+
+ assert.throws(TypeError, function() {
+ sample.filter(Symbol(""));
+ }, "symbol");
+
+ assert.throws(TypeError, function() {
+ sample.filter("");
+ }, "string");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..c8d6283ac7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().filter(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..c8e6941ccd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ The callbackfn return does not change the instance
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(3);
+
+ sample1[1] = 1n;
+
+ sample1.filter(function() {
+ return 42;
+ });
+
+ assert.sameValue(sample1[0], 0n, "[0] == 0");
+ assert.sameValue(sample1[1], 1n, "[1] == 1");
+ assert.sameValue(sample1[2], 0n, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..7c45962521
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js
new file mode 100644
index 0000000000..4d1e9cfe18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.filter(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7n),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during interaction"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7n, "changed values after interaction [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after interaction [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after interaction [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..5054983356
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-this.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.filter(function() {
+ results1.push(this);
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.filter(function() {
+ results2.push(this);
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..87fe78c8de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js
new file mode 100644
index 0000000000..84fce65efa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Return does not share buffer
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+ 13. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var result;
+
+ result = sample.filter(function() { return true; });
+ assert.notSameValue(result.buffer, sample.buffer);
+
+ result = sample.filter(function() { return false; });
+ assert.notSameValue(result.buffer, sample.buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js
new file mode 100644
index 0000000000..7787154e72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns empty if every callbackfn returns boolean false
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var result = sample.filter(function() {
+ return val;
+ });
+ assert.sameValue(result.length, 0, val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js
new file mode 100644
index 0000000000..82c7e57468
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns full length result if every callbackfn returns boolean false
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+
+ [
+ true,
+ 1,
+ "test262",
+ Symbol("1"),
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ].forEach(function(val) {
+ var result = sample.filter(function() { return val; });
+ assert(compareArray(result, sample), val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f16b6b0daf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.filter,
+ 'function',
+ 'implements TypedArray.prototype.filter'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.filter(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.filter(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the filter operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.filter(() => {});
+ throw new Test262Error('filter completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..2c15f6ec0c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() {
+ return true;
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..43dbbe8f05
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,66 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.filter(function() {
+ return true;
+ });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..aeddd45fb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var callbackfn = function() { return true; };
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..38dac21933
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.filter(function() { return true; });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..b86692f869
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() { return true; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..a4e39abc2e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 42n, 42n]);
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(count);
+ };
+
+ sample.filter(function(v) { return v === 42n; });
+
+ assert.sameValue(result.length, 1, "called with 1 argument");
+ assert.sameValue(result[0], 2, "[0] is the new captured length");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 0000000000..e92ed32146
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Throws a TypeError if new typedArray's length < captured
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA();
+ };
+
+ assert.throws(TypeError, function() {
+ sample.filter(function() { return true; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 0000000000..a26cef8c1c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Does not throw a TypeError if new typedArray's length >= captured
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var customCount, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA(customCount);
+ };
+
+ customCount = 2;
+ result = sample.filter(function() { return true; });
+ assert.sameValue(result.length, customCount, "length == count");
+
+ customCount = 5;
+ result = sample.filter(function() { return true; });
+ assert.sameValue(result.length, customCount, "length > count");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..1fb32b4b51
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Custom @@species constructor may return a different TypedArray
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n]);
+ var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ var other = new otherTA([1n, 0n, 1n]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.filter(function() {});
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..fd0d97649c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = Array;
+
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..afbf9e9472
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var calls = 0;
+ var other, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(captured) {
+ calls++;
+ other = new TA(captured);
+ return other;
+ };
+
+ result = sample.filter(function() { return true; });
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert.sameValue(result, other, "return is instance of custom constructor");
+ assert(compareArray(result, [40n, 41n, 42n]), "values are set on the new obj");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..e5830cea73
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..75819af3c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.filter(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.filter(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js
new file mode 100644
index 0000000000..71bc8f62df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.filter(function() {});
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..66429b4a61
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Integer indexed values are not cached before interaction
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.filter(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js
new file mode 100644
index 0000000000..57618c84c5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/BigInt/values-are-set.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returned instance with filtered values set on it
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([41n, 1n, 42n, 7n]);
+ var result;
+
+ result = sample.filter(function() { return true; });
+ assert(compareArray(result, [41n, 1n, 42n, 7n]), "values are set #1");
+
+ result = sample.filter(function(v) {
+ return v > 40n;
+ });
+ assert(compareArray(result, [41n, 42n]), "values are set #2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js
new file mode 100644
index 0000000000..33c21ff6f6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/arraylength-internal.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Uses internal ArrayLength instead of length property
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. Let len be the value of O's [[ArrayLength]] internal slot.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 4, "interactions are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..35859300b2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.filter(function() {
+ results.push(arguments);
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..4b64fc8fe4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.filter(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js
new file mode 100644
index 0000000000..1d4cdffd48
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: callbackfn is called for each item before TypedArraySpeciesCreate
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var length = 42;
+ var sample = new TA(length);
+ var calls = 0;
+ var before = false;
+
+ sample.constructor = {};
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ before = calls === length;
+ }
+ });
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(calls, 42, "callbackfn called for each item");
+ assert.sameValue(before, true, "all callbackfn called before");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js
new file mode 100644
index 0000000000..e4294991a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-called-before-species.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: callbackfn is called for each item before TypedArraySpeciesCreate
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var length = 42;
+ var sample = new TA(length);
+ var calls = 0;
+ var before = false;
+
+ sample.constructor = {};
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ before = calls === length;
+ }
+ });
+
+ sample.filter(function() {
+ calls++;
+ });
+
+ assert.sameValue(calls, 42, "callbackfn called for each item");
+ assert.sameValue(before, true, "all callbackfn called before");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..27ea1c0524
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-detachbuffer.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(O, Pk).
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.filter(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js
new file mode 100644
index 0000000000..0c88c6a18b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.filter(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+
+ assert.sameValue(results[0][0], 7, "results[0][0] - kValue");
+ assert.sameValue(results[1][0], 8, "results[1][0] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..e14ad06554
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+
+ assert.throws(TypeError, function() {
+ sample.filter();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.filter(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.filter(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.filter(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.filter(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.filter({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.filter([]);
+ }, "[]");
+
+ assert.throws(TypeError, function() {
+ sample.filter(1);
+ }, "Number");
+
+ assert.throws(TypeError, function() {
+ sample.filter(Symbol(""));
+ }, "symbol");
+
+ assert.throws(TypeError, function() {
+ sample.filter("");
+ }, "string");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..b9de4395ac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().filter(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js
new file mode 100644
index 0000000000..bbbdd4c1b0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-resize.js
@@ -0,0 +1,79 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var NaNvalue = (TA === Float32Array || TA === Float64Array) ? NaN : 0;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.filter(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ finalResult = NaNvalue;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ finalResult = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return true;
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.compareArray(result, [0, 0, finalResult], 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.filter(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return true;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.compareArray(result, expectedElements, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..6dfefa332e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ The callbackfn return does not change the instance
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(3);
+
+ sample1[1] = 1;
+
+ sample1.filter(function() {
+ return 42;
+ });
+
+ assert.sameValue(sample1[0], 0, "[0] == 0");
+ assert.sameValue(sample1[1], 1, "[1] == 1");
+ assert.sameValue(sample1[2], 0, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..8b40373c4a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js
new file mode 100644
index 0000000000..4f42d5a7f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.filter(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during interaction"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after interaction [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after interaction [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after interaction [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js
new file mode 100644
index 0000000000..500140145c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/callbackfn-this.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.filter(function() {
+ results1.push(this);
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.filter(function() {
+ results2.push(this);
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js
new file mode 100644
index 0000000000..56763ff852
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js
new file mode 100644
index 0000000000..6b2b117b87
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var filter = TypedArray.prototype.filter;
+
+assert.sameValue(typeof filter, 'function');
+
+assert.throws(TypeError, function() {
+ filter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js
new file mode 100644
index 0000000000..e05b086e7e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.filter, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.filter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js
new file mode 100644
index 0000000000..43eb0a71d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ %TypedArray%.prototype.filter.length is 1.
+info: |
+ %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.filter.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.filter, "length");
+verifyNotWritable(TypedArray.prototype.filter, "length");
+verifyConfigurable(TypedArray.prototype.filter, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js
new file mode 100644
index 0000000000..517b0a9b17
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ %TypedArray%.prototype.filter.name is "filter".
+info: |
+ %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.filter.name, "filter");
+
+verifyNotEnumerable(TypedArray.prototype.filter, "name");
+verifyNotWritable(TypedArray.prototype.filter, "name");
+verifyConfigurable(TypedArray.prototype.filter, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js
new file mode 100644
index 0000000000..403a52833e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.filter does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.filter),
+ false,
+ 'isConstructor(TypedArray.prototype.filter) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.filter(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.filter(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js
new file mode 100644
index 0000000000..4fd22727f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ "filter" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'filter');
+verifyWritable(TypedArrayPrototype, 'filter');
+verifyConfigurable(TypedArrayPrototype, 'filter');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js
new file mode 100644
index 0000000000..f9c95146bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-does-not-share-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Return does not share buffer
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+ 13. Return A.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+ var result;
+
+ result = sample.filter(function() { return true; });
+ assert.notSameValue(result.buffer, sample.buffer);
+
+ result = sample.filter(function() { return false; });
+ assert.notSameValue(result.buffer, sample.buffer);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js
new file mode 100644
index 0000000000..333865b7f9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns empty if every callbackfn returns boolean false
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var result = sample.filter(function() {
+ return val;
+ });
+ assert.sameValue(result.length, 0, val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js
new file mode 100644
index 0000000000..ebdc9cd740
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns full length result if every callbackfn returns boolean false
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+
+ [
+ true,
+ 1,
+ "test262",
+ Symbol("1"),
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ].forEach(function(val) {
+ var result = sample.filter(function() { return val; });
+ assert(compareArray(result, sample), val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..a5ad41d841
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.filter,
+ 'function',
+ 'implements TypedArray.prototype.filter'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.filter(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.filter(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the filter operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.filter(() => {});
+ throw new Test262Error('filter completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..d3ff3fa259
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() {
+ return true;
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..264a90ef1e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,66 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.filter(function() {
+ return true;
+ });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..bf3e736c60
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var callbackfn = function() { return true; };
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.filter(callbackfn);
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..df73eb95af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.filter(function() { return true; });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..2c3ca7cce1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.filter(function() { return true; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..233bab0335
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 42, 42]);
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(count);
+ };
+
+ sample.filter(function(v) { return v === 42; });
+
+ assert.sameValue(result.length, 1, "called with 1 argument");
+ assert.sameValue(result[0], 2, "[0] is the new captured length");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 0000000000..e95a16d1af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Throws a TypeError if new typedArray's length < captured
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA();
+ };
+
+ assert.throws(TypeError, function() {
+ sample.filter(function() { return true; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 0000000000..7b2ef2a03a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Does not throw a TypeError if new typedArray's length >= captured
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var customCount, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA(customCount);
+ };
+
+ customCount = 2;
+ result = sample.filter(function() { return true; });
+ assert.sameValue(result.length, customCount, "length == count");
+
+ customCount = 5;
+ result = sample.filter(function() { return true; });
+ assert.sameValue(result.length, customCount, "length > count");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..f0bb676bbd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Custom @@species constructor may return a different TypedArray
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40]);
+ var otherTA = TA === Int8Array ? Int16Array : Int8Array;
+ var other = new otherTA([1, 0, 1]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.filter(function() {});
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [1, 0, 1]), "the returned object is preserved");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..795267c2a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = Array;
+
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..2a8a77a84e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+ var calls = 0;
+ var other, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(captured) {
+ calls++;
+ other = new TA(captured);
+ return other;
+ };
+
+ result = sample.filter(function() { return true; });
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert.sameValue(result, other, "return is instance of custom constructor");
+ assert(compareArray(result, [40, 41, 42]), "values are set on the new obj");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..c7be1baf0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.filter(function() {});
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..eceb6c5440
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.filter(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.filter(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js
new file mode 100644
index 0000000000..e9139c9c20
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/speciesctor-get-species.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 10. Let A be ? TypedArraySpeciesCreate(O, « captured »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.filter(function() {});
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js
new file mode 100644
index 0000000000..53275207fd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-object.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var filter = TypedArray.prototype.filter;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ filter.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ filter.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ filter.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ filter.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ filter.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ filter.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ filter.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..e223f362dc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var filter = TypedArray.prototype.filter;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ filter.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ filter.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ filter.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ filter.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js
new file mode 100644
index 0000000000..e9f070db01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-not-cached.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Integer indexed values are not cached before interaction
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 9. Repeat, while k < len
+ ...
+ c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ sample.filter(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js
new file mode 100644
index 0000000000..f819a8fd83
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/filter/values-are-set.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.filter
+description: >
+ Returned instance with filtered values set on it
+info: |
+ 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] )
+
+ ...
+ 12. For each element e of kept
+ a. Perform ! Set(A, ! ToString(n), e, true).
+ b. Increment n by 1.
+ 13. Return A.
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([41, 1, 42, 7]);
+ var result;
+
+ result = sample.filter(function() { return true; });
+ assert(compareArray(result, [41, 1, 42, 7]), "values are set #1");
+
+ result = sample.filter(function(v) {
+ return v > 40;
+ });
+ assert(compareArray(result, [41, 42]), "values are set #2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..51b7d60af4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.find(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..05b01d3167
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42n]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.find(function() { return true; }),
+ 42n
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js
new file mode 100644
index 0000000000..64667d84a6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js
@@ -0,0 +1,80 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Change values during predicate call
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var arr = [1n, 2n, 3n];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.find(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0n, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.find(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, 7n, "value found");
+
+ sample = new TA(arr);
+ result = sample.find(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7n;
+ }
+ return val === 3n;
+ });
+ assert.sameValue(result, undefined, "value not found");
+
+ sample = new TA(arr);
+ result = sample.find(function(val, i) {
+ if ( i > 0 ) {
+ sample[0] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, undefined, "value not found - changed after call");
+
+ sample = new TA(arr);
+ result = sample.find(function() {
+ sample[0] = 7n;
+ return true;
+ });
+ assert.sameValue(result, 1n, "find() returns previous found value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js
new file mode 100644
index 0000000000..ab3bb965ba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 2n, 62n]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.find(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 39n, "results[0][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[0][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3 arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2n, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3 arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 62n, "results[2][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[2][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3 arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..cbfc687e78
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [noStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var T = this;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.find(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.find(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.find(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..9c5c07eba5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-call-this-strict-strict.js
@@ -0,0 +1,56 @@
+'use strict';
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Verify predicate this on strict mode
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [onlyStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.find(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.find(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..149b44b285
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 3. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.find({});
+ }, "object");
+
+ assert.throws(TypeError, function() {
+ sample.find(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.find(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.find(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.find(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.find(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.find("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.find([]);
+ }, "array");
+
+ assert.throws(TypeError, function() {
+ sample.find(/./);
+ }, "regexp");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..0cb8181ca1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Predicate may detach the buffer
+info: |
+ %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8
+
+ ...
+
+ However, such optimization must not introduce any observable changes in the
+ specified behaviour of the algorithm and must take into account the
+ possibility that calls to predicate may cause the this value to become
+ detached.
+
+
+ Array.prototype.find ( predicate[ , thisArg ] )
+
+ Let O be ? ToObject(this value).
+ Let len be ? LengthOfArrayLike(O).
+ If IsCallable(predicate) is false, throw a TypeError exception.
+ Let k be 0.
+ Repeat, while k < len,
+ Let Pk be ! ToString(𝔽(k)).
+ Let kValue be ? Get(O, Pk).
+ Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ If testResult is true, return kValue.
+ Set k to k + 1.
+ Return undefined.
+
+ IntegerIndexedElementGet ( O, index )
+
+ ...
+ Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ If IsDetachedBuffer(buffer) is true, return undefined.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.find(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..7c863b77c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Predicate is not called on empty instances
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var result = sample.find(function() {
+ called = true;
+ return true;
+ });
+
+ assert.sameValue(
+ called,
+ false,
+ "empty instance does not call predicate"
+ );
+ assert.sameValue(
+ result,
+ undefined,
+ "find returns undefined when predicate is not called"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..406a6618f9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Return abrupt from predicate call.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ var predicate = function() {
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.find(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..bd9d8b9de7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.find,
+ 'function',
+ 'implements TypedArray.prototype.find'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.find(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.find(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the find operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.find(() => {});
+ throw new Test262Error('find completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js
new file mode 100644
index 0000000000..a5c977152a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Return found value if predicate return a boolean true value.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ d. If testResult is true, return kValue.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 2n, 62n]);
+ var called, result;
+
+ called = 0;
+ result = sample.find(function() {
+ called++;
+ return true;
+ });
+ assert.sameValue(result, 39n, "returned true on sample[0]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.find(function(val) {
+ called++;
+ return val === 62n;
+ });
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 62n, "returned true on sample[3]");
+
+ result = sample.find(function() { return "string"; });
+ assert.sameValue(result, 39n, "ToBoolean(string)");
+
+ result = sample.find(function() { return {}; });
+ assert.sameValue(result, 39n, "ToBoolean(object)");
+
+ result = sample.find(function() { return Symbol(""); });
+ assert.sameValue(result, 39n, "ToBoolean(symbol)");
+
+ result = sample.find(function() { return 1; });
+ assert.sameValue(result, 39n, "ToBoolean(number)");
+
+ result = sample.find(function() { return -1; });
+ assert.sameValue(result, 39n, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..43714b5e4a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js
@@ -0,0 +1,62 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Return undefined if predicate always returns a boolean false value.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+ 7. Return undefined.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+ var called = 0;
+
+ var result = sample.find(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, undefined);
+
+ result = sample.find(function() { return ""; });
+ assert.sameValue(result, undefined, "ToBoolean(empty string)");
+
+ result = sample.find(function() { return undefined; });
+ assert.sameValue(result, undefined, "ToBoolean(undefined)");
+
+ result = sample.find(function() { return null; });
+ assert.sameValue(result, undefined, "ToBoolean(null)");
+
+ result = sample.find(function() { return 0; });
+ assert.sameValue(result, undefined, "ToBoolean(0)");
+
+ result = sample.find(function() { return -0; });
+ assert.sameValue(result, undefined, "ToBoolean(-0)");
+
+ result = sample.find(function() { return NaN; });
+ assert.sameValue(result, undefined, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js
new file mode 100644
index 0000000000..3165cc78d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/callbackfn-resize.js
@@ -0,0 +1,76 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.find(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, undefined, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.find(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, undefined, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js
new file mode 100644
index 0000000000..5de4a56041
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.find(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..ff41a27af9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/get-length-ignores-length-prop.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.find(function() { return true; }),
+ 42
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js
new file mode 100644
index 0000000000..e63cc49e07
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var find = TypedArray.prototype.find;
+
+assert.sameValue(typeof find, 'function');
+
+assert.throws(TypeError, function() {
+ find();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js
new file mode 100644
index 0000000000..a4d8b598ba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.find, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.find();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js
new file mode 100644
index 0000000000..1583fe26d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ %TypedArray%.prototype.find.length is 1.
+info: |
+ %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.find.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.find, "length");
+verifyNotWritable(TypedArray.prototype.find, "length");
+verifyConfigurable(TypedArray.prototype.find, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js
new file mode 100644
index 0000000000..1d1f09f6b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ %TypedArray%.prototype.find.name is "find".
+info: |
+ %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.find.name, "find");
+
+verifyNotEnumerable(TypedArray.prototype.find, "name");
+verifyNotWritable(TypedArray.prototype.find, "name");
+verifyConfigurable(TypedArray.prototype.find, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js
new file mode 100644
index 0000000000..c7453c01f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.find does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.find),
+ false,
+ 'isConstructor(TypedArray.prototype.find) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.find(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.find(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js
new file mode 100644
index 0000000000..7dcaccf39b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-changes-value.js
@@ -0,0 +1,80 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Change values during predicate call
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var arr = [1, 2, 3];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.find(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.find(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, 7, "value found");
+
+ sample = new TA(arr);
+ result = sample.find(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7;
+ }
+ return val === 3;
+ });
+ assert.sameValue(result, undefined, "value not found");
+
+ sample = new TA(arr);
+ result = sample.find(function(val, i) {
+ if ( i > 0 ) {
+ sample[0] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, undefined, "value not found - changed after call");
+
+ sample = new TA(arr);
+ result = sample.find(function() {
+ sample[0] = 7;
+ return true;
+ });
+ assert.sameValue(result, 1, "find() returns previous found value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js
new file mode 100644
index 0000000000..3df875dc37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-parameters.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 2, 62]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.find(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 39, "results[0][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[0][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3 arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3 arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 62, "results[2][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[2][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3 arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..b96f0ee394
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-non-strict.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [noStrict]
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var T = this;
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.find(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.find(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.find(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..207b73208c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-call-this-strict-strict.js
@@ -0,0 +1,56 @@
+'use strict';
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Verify predicate this on strict mode
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [onlyStrict]
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.find(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.find(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..40f7c959dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-is-not-callable-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 3. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.find({});
+ }, "object");
+
+ assert.throws(TypeError, function() {
+ sample.find(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.find(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.find(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.find(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.find(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.find("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.find([]);
+ }, "array");
+
+ assert.throws(TypeError, function() {
+ sample.find(/./);
+ }, "regexp");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..ca16ed882d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-may-detach-buffer.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Predicate may detach the buffer
+info: |
+ %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8
+
+ ...
+
+ However, such optimization must not introduce any observable changes in the
+ specified behaviour of the algorithm and must take into account the
+ possibility that calls to predicate may cause the this value to become
+ detached.
+
+
+ Array.prototype.find ( predicate[ , thisArg ] )
+
+ Let O be ? ToObject(this value).
+ Let len be ? LengthOfArrayLike(O).
+ If IsCallable(predicate) is false, throw a TypeError exception.
+ Let k be 0.
+ Repeat, while k < len,
+ Let Pk be ! ToString(F(k)).
+ Let kValue be ? Get(O, Pk).
+ Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, F(k), O »)).
+ If testResult is true, return kValue.
+ Set k to k + 1.
+ Return undefined.
+
+ IntegerIndexedElementGet ( O, index )
+
+ ...
+ Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ If IsDetachedBuffer(buffer) is true, return undefined.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.find(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..7ea189e4b1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Predicate is not called on empty instances
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var result = sample.find(function() {
+ called = true;
+ return true;
+ });
+
+ assert.sameValue(
+ called,
+ false,
+ "empty instance does not call predicate"
+ );
+ assert.sameValue(
+ result,
+ undefined,
+ "find returns undefined when predicate is not called"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js
new file mode 100644
index 0000000000..ed0168a1cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ "find" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'find');
+verifyWritable(TypedArrayPrototype, 'find');
+verifyConfigurable(TypedArrayPrototype, 'find');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..2215239c21
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Return abrupt from predicate call.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ var predicate = function() {
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.find(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..73c4118313
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.find,
+ 'function',
+ 'implements TypedArray.prototype.find'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.find(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.find(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the find operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.find(() => {});
+ throw new Test262Error('find completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js
new file mode 100644
index 0000000000..f5cfd69ff7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Return found value if predicate return a boolean true value.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ d. If testResult is true, return kValue.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 2, 62]);
+ var called, result;
+
+ called = 0;
+ result = sample.find(function() {
+ called++;
+ return true;
+ });
+ assert.sameValue(result, 39, "returned true on sample[0]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.find(function(val) {
+ called++;
+ return val === 62;
+ });
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 62, "returned true on sample[3]");
+
+ result = sample.find(function() { return "string"; });
+ assert.sameValue(result, 39, "ToBoolean(string)");
+
+ result = sample.find(function() { return {}; });
+ assert.sameValue(result, 39, "ToBoolean(object)");
+
+ result = sample.find(function() { return Symbol(""); });
+ assert.sameValue(result, 39, "ToBoolean(symbol)");
+
+ result = sample.find(function() { return 1; });
+ assert.sameValue(result, 39, "ToBoolean(number)");
+
+ result = sample.find(function() { return -1; });
+ assert.sameValue(result, 39, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..bbfa0928e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js
@@ -0,0 +1,62 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Return undefined if predicate always returns a boolean false value.
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.find is a distinct function that implements the same
+ algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length". The implementation of the algorithm may be optimized with
+ the knowledge that the this value is an object that has a fixed length and
+ whose integer indexed properties are not sparse.
+
+ ...
+
+ 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+ 7. Return undefined.
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+ var called = 0;
+
+ var result = sample.find(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, undefined);
+
+ result = sample.find(function() { return ""; });
+ assert.sameValue(result, undefined, "ToBoolean(empty string)");
+
+ result = sample.find(function() { return undefined; });
+ assert.sameValue(result, undefined, "ToBoolean(undefined)");
+
+ result = sample.find(function() { return null; });
+ assert.sameValue(result, undefined, "ToBoolean(null)");
+
+ result = sample.find(function() { return 0; });
+ assert.sameValue(result, undefined, "ToBoolean(0)");
+
+ result = sample.find(function() { return -0; });
+ assert.sameValue(result, undefined, "ToBoolean(-0)");
+
+ result = sample.find(function() { return NaN; });
+ assert.sameValue(result, undefined, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js
new file mode 100644
index 0000000000..9a6479ee49
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var find = TypedArray.prototype.find;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ find.call(undefined, predicate);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ find.call(null, predicate);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ find.call(42, predicate);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ find.call("1", predicate);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ find.call(true, predicate);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ find.call(false, predicate);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ find.call(s, predicate);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..cdec6e01ad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.find
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var find = TypedArray.prototype.find;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ find.call({}, predicate);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ find.call([], predicate);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ find.call(ab, predicate);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ find.call(dv, predicate);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..adc2846924
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.findIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..a6ac97105e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42n]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.findIndex(function() { return true; }),
+ 0
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js
new file mode 100644
index 0000000000..d7ac7f2cd5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Change values during predicate call
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var arr = [10n, 20n, 30n];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.findIndex(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0n, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.findIndex(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, 2, "value found");
+
+ sample = new TA(arr);
+ result = sample.findIndex(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7n;
+ }
+ return val === 30n;
+ });
+ assert.sameValue(result, -1, "value not found");
+
+ sample = new TA(arr);
+ result = sample.findIndex(function(val, i) {
+ if ( i > 0 ) {
+ sample[0] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, -1, "value not found - changed after call");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js
new file mode 100644
index 0000000000..5d29ca105b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js
@@ -0,0 +1,62 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 2n, 62n]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.findIndex(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 39n, "results[0][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[0][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3, arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2n, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3, arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 62n, "results[2][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[2][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3, arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..4a9a19e8fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [noStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var T = this;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.findIndex(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.findIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..1712b2c26f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict-strict.js
@@ -0,0 +1,54 @@
+'use strict';
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [onlyStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.findIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..7bdbbc4f19
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js
@@ -0,0 +1,66 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 3. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.findIndex({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex([]);
+ }, "[]");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(/./);
+ }, "/./");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..345efae749
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2021 Apple Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate may detach the buffer
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(O, Pk).
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+
+ 9.4.5.8 IntegerIndexedElementGet ( O, index )
+
+ ...
+ 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var loops = 0;
+
+ sample.findIndex(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+ assert.sameValue(loops, 2, "predicate is called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..fad5dad300
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate is not called on an empty instance
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+ 7. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var predicate = function() {
+ called = true;
+ return true;
+ };
+
+ var result = sample.findIndex(predicate);
+
+ assert.sameValue(
+ called, false,
+ "does not call predicate"
+ );
+ assert.sameValue(
+ result, -1,
+ "returns -1 on an empty instance"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..aebfdbac18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Return abrupt from predicate call.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ assert.throws(Test262Error, function() {
+ sample.findIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..bbcc356805
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.findIndex,
+ 'function',
+ 'implements TypedArray.prototype.findIndex'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.findIndex(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.findIndex(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the findIndex operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.findIndex(() => {});
+ throw new Test262Error('findIndex completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js
new file mode 100644
index 0000000000..605b95ed9c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Return index if predicate return a boolean true value.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ d. If testResult is true, return k.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 3n, 9n]);
+ var called = 0;
+
+ var result = sample.findIndex(function() {
+ called++;
+ return true;
+ });
+
+ assert.sameValue(result, 0, "returned true on sample[0]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.findIndex(function(val) {
+ called++;
+ return val === 9n;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 2, "returned true on sample[3]");
+
+ result = sample.findIndex(function() { return "string"; });
+ assert.sameValue(result, 0, "ToBoolean(string)");
+
+ result = sample.findIndex(function() { return {}; });
+ assert.sameValue(result, 0, "ToBoolean(object)");
+
+ result = sample.findIndex(function() { return Symbol(""); });
+ assert.sameValue(result, 0, "ToBoolean(symbol)");
+
+ result = sample.findIndex(function() { return 1; });
+ assert.sameValue(result, 0, "ToBoolean(number)");
+
+ result = sample.findIndex(function() { return -1; });
+ assert.sameValue(result, 0, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..3cb8bcd20a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Return -1 if predicate always returns a boolean false value.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+ 7. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 2n, 3n]);
+ var called = 0;
+
+ var result = sample.findIndex(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, -1, "result is -1 when predicate returns are false");
+
+ result = sample.findIndex(function() { return ""; });
+ assert.sameValue(result, -1, "ToBoolean(string)");
+
+ result = sample.findIndex(function() { return undefined; });
+ assert.sameValue(result, -1, "ToBoolean(undefined)");
+
+ result = sample.findIndex(function() { return null; });
+ assert.sameValue(result, -1, "ToBoolean(null)");
+
+ result = sample.findIndex(function() { return 0; });
+ assert.sameValue(result, -1, "ToBoolean(0)");
+
+ result = sample.findIndex(function() { return -0; });
+ assert.sameValue(result, -1, "ToBoolean(-0)");
+
+ result = sample.findIndex(function() { return NaN; });
+ assert.sameValue(result, -1, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js
new file mode 100644
index 0000000000..1986131e11
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/callbackfn-resize.js
@@ -0,0 +1,76 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.findIndex(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, -1, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.findIndex(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, -1, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js
new file mode 100644
index 0000000000..b936c3dc74
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.findIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..19f41d6844
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.findIndex(function() { return true; }),
+ 0
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js
new file mode 100644
index 0000000000..4d1c3dbcaf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var findIndex = TypedArray.prototype.findIndex;
+
+assert.sameValue(typeof findIndex, 'function');
+
+assert.throws(TypeError, function() {
+ findIndex();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js
new file mode 100644
index 0000000000..e787cd2dfc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.findIndex, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.findIndex();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js
new file mode 100644
index 0000000000..47fd253eef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ %TypedArray%.prototype.findIndex.length is 1.
+info: |
+ %TypedArray%.prototype.findIndex (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.findIndex.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.findIndex, "length");
+verifyNotWritable(TypedArray.prototype.findIndex, "length");
+verifyConfigurable(TypedArray.prototype.findIndex, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js
new file mode 100644
index 0000000000..efe006ee61
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ %TypedArray%.prototype.findIndex.name is "findIndex".
+info: |
+ %TypedArray%.prototype.findIndex (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.findIndex.name, "findIndex");
+
+verifyNotEnumerable(TypedArray.prototype.findIndex, "name");
+verifyNotWritable(TypedArray.prototype.findIndex, "name");
+verifyConfigurable(TypedArray.prototype.findIndex, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js
new file mode 100644
index 0000000000..c41db60aef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.findIndex does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.findIndex),
+ false,
+ 'isConstructor(TypedArray.prototype.findIndex) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.findIndex(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.findIndex(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js
new file mode 100644
index 0000000000..8ee1fcccae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-changes-value.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Change values during predicate call
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var arr = [10, 20, 30];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.findIndex(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.findIndex(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, 2, "value found");
+
+ sample = new TA(arr);
+ result = sample.findIndex(function(val, i) {
+ if ( i === 0 ) {
+ sample[2] = 7;
+ }
+ return val === 30;
+ });
+ assert.sameValue(result, -1, "value not found");
+
+ sample = new TA(arr);
+ result = sample.findIndex(function(val, i) {
+ if ( i > 0 ) {
+ sample[0] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, -1, "value not found - changed after call");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js
new file mode 100644
index 0000000000..86ec93c907
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-parameters.js
@@ -0,0 +1,62 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 2, 62]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.findIndex(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 39, "results[0][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[0][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3, arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3, arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 62, "results[2][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[2][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3, arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..db41c2cae1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [noStrict]
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var T = this;
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.findIndex(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.findIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..d13f4c3bcf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-call-this-strict-strict.js
@@ -0,0 +1,54 @@
+'use strict';
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+flags: [onlyStrict]
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.findIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..cc43dfd920
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js
@@ -0,0 +1,66 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 3. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.findIndex({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex([]);
+ }, "[]");
+
+ assert.throws(TypeError, function() {
+ sample.findIndex(/./);
+ }, "/./");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..a86b1b06b0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate may detach the buffer
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ Repeat, while k < len,
+ Let Pk be ! ToString(F(k)).
+ Let kValue be ? Get(O, Pk).
+ Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, F(k), O »)).
+ ...
+
+ IntegerIndexedElementGet ( O, index )
+
+ Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ If IsDetachedBuffer(buffer) is true, return undefined.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var loops = 0;
+
+ sample.findIndex(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+ assert.sameValue(loops, 2, "predicate is called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..5ad0de0f26
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Predicate is not called on an empty instance
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+ 7. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var predicate = function() {
+ called = true;
+ return true;
+ };
+
+ var result = sample.findIndex(predicate);
+
+ assert.sameValue(
+ called, false,
+ "does not call predicate"
+ );
+ assert.sameValue(
+ result, -1,
+ "returns -1 on an empty instance"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js
new file mode 100644
index 0000000000..26f01cd00a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ "findIndex" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'findIndex');
+verifyWritable(TypedArrayPrototype, 'findIndex');
+verifyConfigurable(TypedArrayPrototype, 'findIndex');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..abb7c66056
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Return abrupt from predicate call.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ assert.throws(Test262Error, function() {
+ sample.findIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f8ca0ff7c9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.findIndex,
+ 'function',
+ 'implements TypedArray.prototype.findIndex'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.findIndex(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.findIndex(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the findIndex operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.findIndex(() => {});
+ throw new Test262Error('findIndex completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js
new file mode 100644
index 0000000000..c0c0a8a07b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Return index if predicate return a boolean true value.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 5. Let k be 0.
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ d. If testResult is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 3, 9]);
+ var called = 0;
+
+ var result = sample.findIndex(function() {
+ called++;
+ return true;
+ });
+
+ assert.sameValue(result, 0, "returned true on sample[0]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.findIndex(function(val) {
+ called++;
+ return val === 9;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 2, "returned true on sample[3]");
+
+ result = sample.findIndex(function() { return "string"; });
+ assert.sameValue(result, 0, "ToBoolean(string)");
+
+ result = sample.findIndex(function() { return {}; });
+ assert.sameValue(result, 0, "ToBoolean(object)");
+
+ result = sample.findIndex(function() { return Symbol(""); });
+ assert.sameValue(result, 0, "ToBoolean(symbol)");
+
+ result = sample.findIndex(function() { return 1; });
+ assert.sameValue(result, 0, "ToBoolean(number)");
+
+ result = sample.findIndex(function() { return -1; });
+ assert.sameValue(result, 0, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..e17e63a44b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Return -1 if predicate always returns a boolean false value.
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ %TypedArray%.prototype.findIndex is a distinct function that implements the
+ same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ ...
+
+ 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
+ ...
+ 7. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 3]);
+ var called = 0;
+
+ var result = sample.findIndex(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, -1, "result is -1 when predicate returns are false");
+
+ result = sample.findIndex(function() { return ""; });
+ assert.sameValue(result, -1, "ToBoolean(string)");
+
+ result = sample.findIndex(function() { return undefined; });
+ assert.sameValue(result, -1, "ToBoolean(undefined)");
+
+ result = sample.findIndex(function() { return null; });
+ assert.sameValue(result, -1, "ToBoolean(null)");
+
+ result = sample.findIndex(function() { return 0; });
+ assert.sameValue(result, -1, "ToBoolean(0)");
+
+ result = sample.findIndex(function() { return -0; });
+ assert.sameValue(result, -1, "ToBoolean(-0)");
+
+ result = sample.findIndex(function() { return NaN; });
+ assert.sameValue(result, -1, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js
new file mode 100644
index 0000000000..5297a42273
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var findIndex = TypedArray.prototype.findIndex;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ findIndex.call(undefined, predicate);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ findIndex.call(null, predicate);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ findIndex.call(42, predicate);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ findIndex.call("1", predicate);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ findIndex.call(true, predicate);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ findIndex.call(false, predicate);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ findIndex.call(s, predicate);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..60b87b1561
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findindex
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var findIndex = TypedArray.prototype.findIndex;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ findIndex.call({}, predicate);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ findIndex.call([], predicate);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ findIndex.call(ab, predicate);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ findIndex.call(dv, predicate);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..7e42ffaa8a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/detached-buffer.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.findLast(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..582951473b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ 22.2.3.10 %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+ 3. Let len be O.[[ArrayLength]].
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42n]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.findLast(function() { return true; }),
+ 42n
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js
new file mode 100644
index 0000000000..ffbbdea13f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Change values during predicate call
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var arr = [1n, 2n, 3n];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.findLast(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0n, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.findLast(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, 7n, "value found");
+
+ sample = new TA(arr);
+ result = sample.findLast(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7n;
+ }
+ return val === 1n;
+ });
+ assert.sameValue(result, undefined, "value not found");
+
+ sample = new TA(arr);
+ result = sample.findLast(function(val, i) {
+ if ( i < 2 ) {
+ sample[2] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, undefined, "value not found - changed after call");
+
+ sample = new TA(arr);
+ result = sample.findLast(function() {
+ sample[2] = 7n;
+ return true;
+ });
+ assert.sameValue(result, 3n, "findLast() returns previous found value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js
new file mode 100644
index 0000000000..9eeba6edfb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 2n, 62n]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.findLast(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 62n, "results[0][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[0][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3 arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2n, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3 arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 39n, "results[2][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[2][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3 arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..b0ddca30f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [noStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+var T = this;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLast(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.findLast(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.findLast(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..a9fc757ba6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict-strict.js
@@ -0,0 +1,42 @@
+'use strict';
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Verify predicate this on strict mode
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [onlyStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLast(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.findLast(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..cc2a8381ea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.findLast({});
+ }, "object");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.findLast("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.findLast([]);
+ }, "array");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(/./);
+ }, "regexp");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..a48ee44eeb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Predicate may detach the buffer
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+
+ However, such optimization must not introduce any observable changes in the
+ specified behaviour of the algorithm and must take into account the
+ possibility that calls to predicate may cause the this value to become
+ detached.
+
+ IntegerIndexedElementGet ( O, index )
+
+ ...
+ Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ If IsDetachedBuffer(buffer) is true, return undefined.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.findLast(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..61365a1b3c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Predicate is not called on empty instances
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var result = sample.findLast(function() {
+ called = true;
+ return true;
+ });
+
+ assert.sameValue(
+ called,
+ false,
+ "empty instance does not call predicate"
+ );
+ assert.sameValue(
+ result,
+ undefined,
+ "findLast returns undefined when predicate is not called"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..775b8ff398
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Return abrupt from predicate call.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ var predicate = function() {
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.findLast(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f4075a8af8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, array-find-from-last, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.findLast,
+ 'function',
+ 'implements TypedArray.prototype.findLast'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.findLast(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.findLast(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the findLast operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.findLast(() => {});
+ throw new Test262Error('findLast completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js
new file mode 100644
index 0000000000..30513a47e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Return found value if predicate return a boolean true value.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ d. If testResult is true, return kValue.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 2n, 62n]);
+ var called, result;
+
+ called = 0;
+ result = sample.findLast(function() {
+ called++;
+ return true;
+ });
+ assert.sameValue(result, 62n, "returned true on sample[2]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.findLast(function(val) {
+ called++;
+ return val === 39n;
+ });
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 39n, "returned true on sample[0]");
+
+ result = sample.findLast(function() { return "string"; });
+ assert.sameValue(result, 62n, "ToBoolean(string)");
+
+ result = sample.findLast(function() { return {}; });
+ assert.sameValue(result, 62n, "ToBoolean(object)");
+
+ result = sample.findLast(function() { return Symbol(""); });
+ assert.sameValue(result, 62n, "ToBoolean(symbol)");
+
+ result = sample.findLast(function() { return 1; });
+ assert.sameValue(result, 62n, "ToBoolean(number)");
+
+ result = sample.findLast(function() { return -1; });
+ assert.sameValue(result, 62n, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..239455b309
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Return undefined if predicate always returns a boolean false value.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+ 6. 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+ 7. Return undefined.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+ var called = 0;
+
+ var result = sample.findLast(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, undefined);
+
+ result = sample.findLast(function() { return ""; });
+ assert.sameValue(result, undefined, "ToBoolean(empty string)");
+
+ result = sample.findLast(function() { return undefined; });
+ assert.sameValue(result, undefined, "ToBoolean(undefined)");
+
+ result = sample.findLast(function() { return null; });
+ assert.sameValue(result, undefined, "ToBoolean(null)");
+
+ result = sample.findLast(function() { return 0; });
+ assert.sameValue(result, undefined, "ToBoolean(0)");
+
+ result = sample.findLast(function() { return -0; });
+ assert.sameValue(result, undefined, "ToBoolean(-0)");
+
+ result = sample.findLast(function() { return NaN; });
+ assert.sameValue(result, undefined, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js
new file mode 100644
index 0000000000..9205a424fb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/callbackfn-resize.js
@@ -0,0 +1,76 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var secondElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.findLast(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(BPE);
+ secondElement = undefined;
+ expectedElements = [0];
+ expectedIndices = [0];
+ expectedArrays = [sample];
+ } catch (_) {
+ secondElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [2, 1, 0];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)');
+ assert.compareArray(indices, [2, 1, 0], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, undefined, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.findLast(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, undefined, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js
new file mode 100644
index 0000000000..4aa8408d8b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/detached-buffer.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.findLast(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..2914416949
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+ ...
+ 3. Let len be O.[[ArrayLength]].
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.findLast(function() { return true; }),
+ 42
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js
new file mode 100644
index 0000000000..ccfb329e0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-func.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Throws a TypeError exception when invoked as a function
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var findLast = TypedArray.prototype.findLast;
+
+assert.sameValue(typeof findLast, 'function');
+
+assert.throws(TypeError, function() {
+ findLast();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js
new file mode 100644
index 0000000000..cb1bc32592
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/invoked-as-method.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.findLast, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.findLast();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js
new file mode 100644
index 0000000000..0513865dd8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ %TypedArray%.prototype.findLast.length is 1.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+assert.sameValue(TypedArray.prototype.findLast.length, 1);
+
+verifyProperty(TypedArray.prototype.findLast, "length", {
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js
new file mode 100644
index 0000000000..4ed9497836
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ %TypedArray%.prototype.findLast.name is "findLast".
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+assert.sameValue(TypedArray.prototype.findLast.name, "findLast");
+
+verifyProperty(TypedArray.prototype.findLast, "name", {
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js
new file mode 100644
index 0000000000..0aa9fd189c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.findLast does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray, array-find-from-last]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.findLast),
+ false,
+ 'isConstructor(TypedArray.prototype.findLast) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.findLast(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.findLast(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js
new file mode 100644
index 0000000000..fa6d96cb83
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-changes-value.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Change values during predicate call
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var arr = [1, 2, 3];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.findLast(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.findLast(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, 7, "value found");
+
+ sample = new TA(arr);
+ result = sample.findLast(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7;
+ }
+ return val === 1;
+ });
+ assert.sameValue(result, undefined, "value not found");
+
+ sample = new TA(arr);
+ result = sample.findLast(function(val, i) {
+ if ( i < 2 ) {
+ sample[2] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, undefined, "value not found - changed after call");
+
+ sample = new TA(arr);
+ result = sample.findLast(function() {
+ sample[2] = 7;
+ return true;
+ });
+ assert.sameValue(result, 3, "findLast() returns previous found value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js
new file mode 100644
index 0000000000..b31a93f459
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-parameters.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 2, 62]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.findLast(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 62, "results[0][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[0][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3 arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3 arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 39, "results[2][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[2][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3 arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..b35b25e9f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [noStrict]
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var T = this;
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLast(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.findLast(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.findLast(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..6c9b6936bf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-call-this-strict-strict.js
@@ -0,0 +1,42 @@
+'use strict';
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Verify predicate this on strict mode
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [onlyStrict]
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLast(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.findLast(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..4e46f36162
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.findLast({});
+ }, "object");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.findLast("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.findLast([]);
+ }, "array");
+
+ assert.throws(TypeError, function() {
+ sample.findLast(/./);
+ }, "regexp");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..51cc7dad9a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Predicate may detach the buffer
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+
+ However, such optimization must not introduce any observable changes in the
+ specified behaviour of the algorithm and must take into account the
+ possibility that calls to predicate may cause the this value to become
+ detached.
+
+ IntegerIndexedElementGet ( O, index )
+
+ ...
+ Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ If IsDetachedBuffer(buffer) is true, return undefined.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.findLast(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..ffe6e0a944
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Predicate is not called on empty instances
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var result = sample.findLast(function() {
+ called = true;
+ return true;
+ });
+
+ assert.sameValue(
+ called,
+ false,
+ "empty instance does not call predicate"
+ );
+ assert.sameValue(
+ result,
+ undefined,
+ "findLast returns undefined when predicate is not called"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js
new file mode 100644
index 0000000000..bc0ad32e75
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/prop-desc.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findLast
+description: >
+ "findLast" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyProperty(TypedArray.prototype, "findLast", {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..b18ead0dc0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Return abrupt from predicate call.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ var predicate = function() {
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.findLast(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f0e2cf11ea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer, array-find-from-last]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.findLast,
+ 'function',
+ 'implements TypedArray.prototype.findLast'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.findLast(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.findLast(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the findLast operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.findLast(() => {});
+ throw new Test262Error('findLast completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js
new file mode 100644
index 0000000000..842492b522
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Return found value if predicate return a boolean true value.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 6. Repeat, while k ≥ 0,
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ d. If testResult is true, return kValue.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 2, 62]);
+ var called, result;
+
+ called = 0;
+ result = sample.findLast(function() {
+ called++;
+ return true;
+ });
+ assert.sameValue(result, 62, "returned true on sample[2]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.findLast(function(val) {
+ called++;
+ return val === 39;
+ });
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 39, "returned true on sample[0]");
+
+ result = sample.findLast(function() { return "string"; });
+ assert.sameValue(result, 62, "ToBoolean(string)");
+
+ result = sample.findLast(function() { return {}; });
+ assert.sameValue(result, 62, "ToBoolean(object)");
+
+ result = sample.findLast(function() { return Symbol(""); });
+ assert.sameValue(result, 62, "ToBoolean(symbol)");
+
+ result = sample.findLast(function() { return 1; });
+ assert.sameValue(result, 62, "ToBoolean(number)");
+
+ result = sample.findLast(function() { return -1; });
+ assert.sameValue(result, 62, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..313915e115
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Return undefined if predicate always returns a boolean false value.
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ ...
+ 6. 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+ 7. Return undefined.
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+ var called = 0;
+
+ var result = sample.findLast(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, undefined);
+
+ result = sample.findLast(function() { return ""; });
+ assert.sameValue(result, undefined, "ToBoolean(empty string)");
+
+ result = sample.findLast(function() { return undefined; });
+ assert.sameValue(result, undefined, "ToBoolean(undefined)");
+
+ result = sample.findLast(function() { return null; });
+ assert.sameValue(result, undefined, "ToBoolean(null)");
+
+ result = sample.findLast(function() { return 0; });
+ assert.sameValue(result, undefined, "ToBoolean(0)");
+
+ result = sample.findLast(function() { return -0; });
+ assert.sameValue(result, undefined, "ToBoolean(-0)");
+
+ result = sample.findLast(function() { return NaN; });
+ assert.sameValue(result, undefined, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js
new file mode 100644
index 0000000000..8e3cd5e0fb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-object.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray, array-find-from-last]
+---*/
+
+var findLast = TypedArray.prototype.findLast;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ findLast.call(undefined, predicate);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ findLast.call(null, predicate);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ findLast.call(42, predicate);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ findLast.call("1", predicate);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ findLast.call(true, predicate);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ findLast.call(false, predicate);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ findLast.call(s, predicate);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..d86c6593a8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlast
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ %TypedArray%.prototype.findLast (predicate [ , thisArg ] )
+
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var findlast = TypedArray.prototype.findlast;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ findlast.call({}, predicate);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ findlast.call([], predicate);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ findlast.call(ab, predicate);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ findlast.call(dv, predicate);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..912a877c91
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..6ebea5d93e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 3. Let len be O.[[ArrayLength]].
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42n]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.findLastIndex(function() { return true; }),
+ 0
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js
new file mode 100644
index 0000000000..a2e1ee53d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Change values during predicate call
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var arr = [10n, 20n, 30n];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.findLastIndex(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0n, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.findLastIndex(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, 0, "value found");
+
+ sample = new TA(arr);
+ result = sample.findLastIndex(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7n;
+ }
+ return val === 10n;
+ });
+ assert.sameValue(result, -1, "value not found");
+
+ sample = new TA(arr);
+ result = sample.findLastIndex(function(val, i) {
+ if ( i < 2 ) {
+ sample[2] = 7n;
+ }
+ return val === 7n;
+ });
+ assert.sameValue(result, -1, "value not found - changed after call");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js
new file mode 100644
index 0000000000..e589cb2732
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 2n, 62n]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.findLastIndex(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 62n, "results[0][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[0][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3, arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2n, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3, arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 39n, "results[2][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[2][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3, arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..82c17225c6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [noStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+var T = this;
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLastIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.findLastIndex(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.findLastIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..d9219834fe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict-strict.js
@@ -0,0 +1,44 @@
+'use strict';
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [onlyStrict]
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLastIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.findLastIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..0ad12e72a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.findLastIndex({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex([]);
+ }, "[]");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(/./);
+ }, "/./");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..b4f8e774a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate may detach the buffer
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k ≥ 0,
+ a. Let Pk be ! ToString(𝔽(k)).
+ b. Let kValue be ! Get(O, Pk).
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+
+ IntegerIndexedElementGet ( O, index )
+
+ Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ If IsDetachedBuffer(buffer) is true, return undefined.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var loops = 0;
+
+ sample.findLastIndex(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+ assert.sameValue(loops, 2, "predicate is called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..63090c3b54
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate is not called on an empty instance
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+ 7. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var predicate = function() {
+ called = true;
+ return true;
+ };
+
+ var result = sample.findLastIndex(predicate);
+
+ assert.sameValue(
+ called, false,
+ "does not call predicate"
+ );
+ assert.sameValue(
+ result, -1,
+ "returns -1 on an empty instance"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..4f5b4d6f52
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Return abrupt from predicate call.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ assert.throws(Test262Error, function() {
+ sample.findLastIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..354fd40931
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, array-find-from-last, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.findLastIndex,
+ 'function',
+ 'implements TypedArray.prototype.findLastIndex'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.findLastIndex(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.findLastIndex(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the findLastIndex operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.findLastIndex(() => {});
+ throw new Test262Error('findLastIndex completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js
new file mode 100644
index 0000000000..28a0bff79e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Return index if predicate return a boolean true value.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ d. If testResult is true, return 𝔽(k).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([39n, 3n, 9n]);
+ var called = 0;
+
+ var result = sample.findLastIndex(function() {
+ called++;
+ return true;
+ });
+
+ assert.sameValue(result, 2, "returned true on sample[2]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.findLastIndex(function(val) {
+ called++;
+ return val === 39n;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 0, "returned true on sample[0]");
+
+ result = sample.findLastIndex(function() { return "string"; });
+ assert.sameValue(result, 2, "ToBoolean(string)");
+
+ result = sample.findLastIndex(function() { return {}; });
+ assert.sameValue(result, 2, "ToBoolean(object)");
+
+ result = sample.findLastIndex(function() { return Symbol(""); });
+ assert.sameValue(result, 2, "ToBoolean(symbol)");
+
+ result = sample.findLastIndex(function() { return 1; });
+ assert.sameValue(result, 2, "ToBoolean(number)");
+
+ result = sample.findLastIndex(function() { return -1; });
+ assert.sameValue(result, 2, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..eb08ec96ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Return -1 if predicate always returns a boolean false value.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+ 7. Return -1𝔽.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, array-find-from-last]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 2n, 3n]);
+ var called = 0;
+
+ var result = sample.findLastIndex(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, -1, "result is -1 when predicate returns are false");
+
+ result = sample.findLastIndex(function() { return ""; });
+ assert.sameValue(result, -1, "ToBoolean(string)");
+
+ result = sample.findLastIndex(function() { return undefined; });
+ assert.sameValue(result, -1, "ToBoolean(undefined)");
+
+ result = sample.findLastIndex(function() { return null; });
+ assert.sameValue(result, -1, "ToBoolean(null)");
+
+ result = sample.findLastIndex(function() { return 0; });
+ assert.sameValue(result, -1, "ToBoolean(0)");
+
+ result = sample.findLastIndex(function() { return -0; });
+ assert.sameValue(result, -1, "ToBoolean(-0)");
+
+ result = sample.findLastIndex(function() { return NaN; });
+ assert.sameValue(result, -1, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js
new file mode 100644
index 0000000000..b79f2aa982
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js
@@ -0,0 +1,76 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var secondElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.findLastIndex(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(BPE);
+ secondElement = undefined;
+ expectedElements = [0];
+ expectedIndices = [0];
+ expectedArrays = [sample];
+ } catch (_) {
+ secondElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [2, 1, 0];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)');
+ assert.compareArray(indices, [2, 1, 0], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, -1, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.findLastIndex(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, -1, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js
new file mode 100644
index 0000000000..953b277879
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js
new file mode 100644
index 0000000000..389ec09afa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ [[Get]] of "length" uses [[ArrayLength]]
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 3. Let len be O.[[ArrayLength]].
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ Object.defineProperty(TA.prototype, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([42]);
+
+ Object.defineProperty(sample, "length", {
+ get: function() {
+ throw new Test262Error();
+ },
+ configurable: true
+ });
+
+ assert.sameValue(
+ sample.findLastIndex(function() { return true; }),
+ 0
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js
new file mode 100644
index 0000000000..bec6bb9b56
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Throws a TypeError exception when invoked as a function
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var findLastIndex = TypedArray.prototype.findLastIndex;
+
+assert.sameValue(typeof findLastIndex, 'function');
+
+assert.throws(TypeError, function() {
+ findLastIndex();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js
new file mode 100644
index 0000000000..89ee3f90f7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.findLastIndex, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.findLastIndex();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js
new file mode 100644
index 0000000000..9586c335a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ %TypedArray%.prototype.findLastIndex.length is 1.
+info: |
+ %TypedArray%.prototype.findLastIndex (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+assert.sameValue(TypedArray.prototype.findLastIndex.length, 1);
+
+verifyProperty(TypedArray.prototype.findLastIndex, "length", {
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js
new file mode 100644
index 0000000000..87e4639963
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ %TypedArray%.prototype.findLastIndex.name is "findLastIndex".
+info: |
+ %TypedArray%.prototype.findLastIndex (predicate [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+assert.sameValue(TypedArray.prototype.findLastIndex.name, "findLastIndex");
+
+verifyProperty(TypedArray.prototype.findLastIndex, "name", {
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js
new file mode 100644
index 0000000000..ec57906ae8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.findLastIndex does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray, array-find-from-last]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.findLastIndex),
+ false,
+ 'isConstructor(TypedArray.prototype.findLastIndex) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.findLastIndex(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.findLastIndex(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js
new file mode 100644
index 0000000000..d288354edd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Change values during predicate call
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var arr = [10, 20, 30];
+ var sample;
+ var result;
+
+ sample = new TA(3);
+ sample.findLastIndex(function(val, i) {
+ sample[i] = arr[i];
+
+ assert.sameValue(val, 0, "value is not mapped to instance");
+ });
+ assert(compareArray(sample, arr), "values set during each predicate call");
+
+ sample = new TA(arr);
+ result = sample.findLastIndex(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, 0, "value found");
+
+ sample = new TA(arr);
+ result = sample.findLastIndex(function(val, i) {
+ if ( i === 2 ) {
+ sample[0] = 7;
+ }
+ return val === 10;
+ });
+ assert.sameValue(result, -1, "value not found");
+
+ sample = new TA(arr);
+ result = sample.findLastIndex(function(val, i) {
+ if ( i < 2) {
+ sample[2] = 7;
+ }
+ return val === 7;
+ });
+ assert.sameValue(result, -1, "value not found - changed after call");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js
new file mode 100644
index 0000000000..6fd62813ea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate called as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 2, 62]);
+ var results = [];
+ var result;
+
+ sample.foo = "bar"; // Ignores non integer index properties
+
+ sample.findLastIndex(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "predicate is called for each index");
+
+ result = results[0];
+ assert.sameValue(result[0], 62, "results[0][0] === 62, value");
+ assert.sameValue(result[1], 2, "results[0][1] === 2, index");
+ assert.sameValue(result[2], sample, "results[0][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[0].length === 3, arguments");
+
+ result = results[1];
+ assert.sameValue(result[0], 2, "results[1][0] === 2, value");
+ assert.sameValue(result[1], 1, "results[1][1] === 1, index");
+ assert.sameValue(result[2], sample, "results[1][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[1].length === 3, arguments");
+
+ result = results[2];
+ assert.sameValue(result[0], 39, "results[2][0] === 39, value");
+ assert.sameValue(result[1], 0, "results[2][1] === 0, index");
+ assert.sameValue(result[2], sample, "results[2][2] === sample, instance");
+ assert.sameValue(result.length, 3, "results[2].length === 3, arguments");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js
new file mode 100644
index 0000000000..3c82732709
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Verify predicate this on non-strict mode
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [noStrict]
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var T = this;
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLastIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(result, T, "without thisArg, predicate this is the global");
+
+ result = null;
+ sample.findLastIndex(function() {
+ result = this;
+ }, undefined);
+
+ assert.sameValue(result, T, "predicate this is the global when thisArg is undefined");
+
+ var o = {};
+ result = null;
+ sample.findLastIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js
new file mode 100644
index 0000000000..db22a84372
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict-strict.js
@@ -0,0 +1,44 @@
+'use strict';
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+flags: [onlyStrict]
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ var result;
+
+ sample.findLastIndex(function() {
+ result = this;
+ });
+
+ assert.sameValue(
+ result,
+ undefined,
+ "without thisArg, predicate this is undefined"
+ );
+
+ var o = {};
+ sample.findLastIndex(function() {
+ result = this;
+ }, o);
+
+ assert.sameValue(result, o, "thisArg becomes the predicate this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js
new file mode 100644
index 0000000000..3785ecdac2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Throws a TypeError exception if predicate is not callable.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(predicate) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.throws(TypeError, function() {
+ sample.findLastIndex({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex([]);
+ }, "[]");
+
+ assert.throws(TypeError, function() {
+ sample.findLastIndex(/./);
+ }, "/./");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js
new file mode 100644
index 0000000000..9edb72ff2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate may detach the buffer
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k ≥ 0,
+ a. Let Pk be ! ToString(𝔽(k)).
+ b. Let kValue be ! Get(O, Pk).
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+
+ IntegerIndexedElementGet ( O, index )
+
+ Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ If IsDetachedBuffer(buffer) is true, return undefined.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var loops = 0;
+
+ sample.findLastIndex(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+ assert.sameValue(loops, 2, "predicate is called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js
new file mode 100644
index 0000000000..857a521897
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Predicate is not called on an empty instance
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+ 7. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var called = false;
+
+ var predicate = function() {
+ called = true;
+ return true;
+ };
+
+ var result = sample.findLastIndex(predicate);
+
+ assert.sameValue(
+ called, false,
+ "does not call predicate"
+ );
+ assert.sameValue(
+ result, -1,
+ "returns -1 on an empty instance"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js
new file mode 100644
index 0000000000..344ab98b2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/prop-desc.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ "findLastIndex" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyProperty(TypedArray.prototype, "findLastIndex", {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js
new file mode 100644
index 0000000000..e615464938
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Return abrupt from predicate call.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var predicate = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ assert.throws(Test262Error, function() {
+ sample.findLastIndex(predicate);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..affee74fba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer, array-find-from-last]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.findLastIndex,
+ 'function',
+ 'implements TypedArray.prototype.findLastIndex'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.findLastIndex(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.findLastIndex(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the findLastIndex operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.findLastIndex(() => {});
+ throw new Test262Error('findLastIndex completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js
new file mode 100644
index 0000000000..c81fb38cdf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Return index if predicate return a boolean true value.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ d. If testResult is true, return 𝔽(k).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([39, 3, 9]);
+ var called = 0;
+
+ var result = sample.findLastIndex(function() {
+ called++;
+ return true;
+ });
+
+ assert.sameValue(result, 2, "returned true on sample[2]");
+ assert.sameValue(called, 1, "predicate was called once");
+
+ called = 0;
+ result = sample.findLastIndex(function(val) {
+ called++;
+ return val === 39;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, 0, "returned true on sample[0]");
+
+ result = sample.findLastIndex(function() { return "string"; });
+ assert.sameValue(result, 2, "ToBoolean(string)");
+
+ result = sample.findLastIndex(function() { return {}; });
+ assert.sameValue(result, 2, "ToBoolean(object)");
+
+ result = sample.findLastIndex(function() { return Symbol(""); });
+ assert.sameValue(result, 2, "ToBoolean(symbol)");
+
+ result = sample.findLastIndex(function() { return 1; });
+ assert.sameValue(result, 2, "ToBoolean(number)");
+
+ result = sample.findLastIndex(function() { return -1; });
+ assert.sameValue(result, 2, "ToBoolean(negative number)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js
new file mode 100644
index 0000000000..e535075e9b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Return -1 if predicate always returns a boolean false value.
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 5. Let k be len - 1.
+ 6. Repeat, while k ≥ 0
+ ...
+ c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)).
+ ...
+ 7. Return -1𝔽.
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 3]);
+ var called = 0;
+
+ var result = sample.findLastIndex(function() {
+ called++;
+ return false;
+ });
+
+ assert.sameValue(called, 3, "predicate was called three times");
+ assert.sameValue(result, -1, "result is -1 when predicate returns are false");
+
+ result = sample.findLastIndex(function() { return ""; });
+ assert.sameValue(result, -1, "ToBoolean(string)");
+
+ result = sample.findLastIndex(function() { return undefined; });
+ assert.sameValue(result, -1, "ToBoolean(undefined)");
+
+ result = sample.findLastIndex(function() { return null; });
+ assert.sameValue(result, -1, "ToBoolean(null)");
+
+ result = sample.findLastIndex(function() { return 0; });
+ assert.sameValue(result, -1, "ToBoolean(0)");
+
+ result = sample.findLastIndex(function() { return -0; });
+ assert.sameValue(result, -1, "ToBoolean(-0)");
+
+ result = sample.findLastIndex(function() { return NaN; });
+ assert.sameValue(result, -1, "ToBoolean(NaN)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js
new file mode 100644
index 0000000000..1dbfc3115f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray, array-find-from-last]
+---*/
+
+var findLastIndex = TypedArray.prototype.findLastIndex;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ findLastIndex.call(undefined, predicate);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ findLastIndex.call(null, predicate);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ findLastIndex.call(42, predicate);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ findLastIndex.call("1", predicate);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ findLastIndex.call(true, predicate);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ findLastIndex.call(false, predicate);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ findLastIndex.call(s, predicate);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..cc92b40bec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 Microsoft. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.findlastindex
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )
+
+ ...
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, array-find-from-last]
+---*/
+
+var findLastIndex = TypedArray.prototype.findLastIndex;
+var predicate = function() {};
+
+assert.throws(TypeError, function() {
+ findLastIndex.call({}, predicate);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ findLastIndex.call([], predicate);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ findLastIndex.call(ab, predicate);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ findLastIndex.call(dv, predicate);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js
new file mode 100644
index 0000000000..c3d44249c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ [[ArrayLength]] is accessed in place of performing a [[Get]] of "length"
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(42);
+ var loop = 0;
+
+ Object.defineProperty(sample1, "length", {value: 1});
+
+ sample1.forEach(function() {
+ loop++;
+ });
+
+ assert.sameValue(loop, 42, "data descriptor");
+
+ var sample2 = new TA(7);
+ loop = 0;
+
+ Object.defineProperty(sample2, "length", {
+ get: function() {
+ throw new Test262Error(
+ "Does not return abrupt getting length property"
+ );
+ }
+ });
+
+ sample2.forEach(function() {
+ loop++;
+ });
+
+ assert.sameValue(loop, 7, "accessor descriptor");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..0ba64a9ded
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.forEach(function() {
+ results.push(arguments);
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..fcde28dc17
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.forEach(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..5be9f05476
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.forEach(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js
new file mode 100644
index 0000000000..662b26068e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn is not callable
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(TypeError, function() {
+ sample.forEach();
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(undefined);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(null);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach({});
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(1);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach("");
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(false);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..d94513f649
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.forEach(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+
+ assert.sameValue(results[0][0], 7n, "results[0][0] - kValue");
+ assert.sameValue(results[1][0], 8n, "results[1][0] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..c4be5838d5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().forEach(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..052146907d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(3);
+
+ sample1[1] = 1n;
+
+ sample1.forEach(function() {
+ return 42;
+ });
+
+ assert.sameValue(sample1[0], 0n, "[0] == 0");
+ assert.sameValue(sample1[1], 1n, "[1] == 1");
+ assert.sameValue(sample1[2], 0n, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..2405024122
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.forEach(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..208be545a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.forEach(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7n),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..25e4abc0f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.forEach(function() {
+ results1.push(this);
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.forEach(function() {
+ results2.push(this);
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..3a72de57aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.forEach(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..35bab23806
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.forEach,
+ 'function',
+ 'implements TypedArray.prototype.forEach'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.forEach(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.forEach(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the forEach operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.forEach(() => {});
+ throw new Test262Error('forEach completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/returns-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/returns-undefined.js
new file mode 100644
index 0000000000..b9e14e8695
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/returns-undefined.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Returns undefined
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(42);
+
+ var result1 = sample1.forEach(function() {
+ return 42;
+ });
+
+ assert.sameValue(result1, undefined, "result1");
+
+ var sample2 = new TA(1);
+ var result2 = sample2.forEach(function() {
+ return null;
+ });
+
+ assert.sameValue(result2, undefined, "result2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..f607b8e525
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.forEach(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js
new file mode 100644
index 0000000000..c7e0f770e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/arraylength-internal.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ [[ArrayLength]] is accessed in place of performing a [[Get]] of "length"
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(42);
+ var loop = 0;
+
+ Object.defineProperty(sample1, "length", {value: 1});
+
+ sample1.forEach(function() {
+ loop++;
+ });
+
+ assert.sameValue(loop, 42, "data descriptor");
+
+ var sample2 = new TA(7);
+ loop = 0;
+
+ Object.defineProperty(sample2, "length", {
+ get: function() {
+ throw new Test262Error(
+ "Does not return abrupt getting length property"
+ );
+ }
+ });
+
+ sample2.forEach(function() {
+ loop++;
+ });
+
+ assert.sameValue(loop, 7, "accessor descriptor");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..eb007e15bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.forEach(function() {
+ results.push(arguments);
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..adfda0ac0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.forEach(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..ce1e7515af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.forEach(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js
new file mode 100644
index 0000000000..b831382b20
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn is not callable
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(TypeError, function() {
+ sample.forEach();
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(undefined);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(null);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach({});
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(1);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach("");
+ });
+
+ assert.throws(TypeError, function() {
+ sample.forEach(false);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..011ae6dcbe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.forEach(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+
+ assert.sameValue(results[0][0], 7, "results[0][0] - kValue");
+ assert.sameValue(results[1][0], 8, "results[1][0] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..cdd228a7fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().forEach(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js
new file mode 100644
index 0000000000..0b84275ac4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-resize.js
@@ -0,0 +1,74 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.forEach
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.forEach(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, undefined, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.forEach(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, undefined, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..1d5493d02e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(3);
+
+ sample1[1] = 1;
+
+ sample1.forEach(function() {
+ return 42;
+ });
+
+ assert.sameValue(sample1[0], 0, "[0] == 0");
+ assert.sameValue(sample1[1], 1, "[1] == 1");
+ assert.sameValue(sample1[2], 0, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..a8c3a758e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.forEach(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..414ae3d1e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.forEach(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js
new file mode 100644
index 0000000000..0715e8db66
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/callbackfn-this.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+
+ 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Perform ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.forEach(function() {
+ results1.push(this);
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.forEach(function() {
+ results2.push(this);
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js
new file mode 100644
index 0000000000..e35a41d5e4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.forEach(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js
new file mode 100644
index 0000000000..d4846aefc6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var forEach = TypedArray.prototype.forEach;
+
+assert.sameValue(typeof forEach, 'function');
+
+assert.throws(TypeError, function() {
+ forEach();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js
new file mode 100644
index 0000000000..dad90f6f41
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.forEach, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.forEach();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js
new file mode 100644
index 0000000000..b31c55e2de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ %TypedArray%.prototype.forEach.length is 1.
+info: |
+ %TypedArray%.prototype.forEach (callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.forEach.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.forEach, "length");
+verifyNotWritable(TypedArray.prototype.forEach, "length");
+verifyConfigurable(TypedArray.prototype.forEach, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js
new file mode 100644
index 0000000000..0f492bcbaf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ %TypedArray%.prototype.forEach.name is "forEach".
+info: |
+ %TypedArray%.prototype.forEach (callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.forEach.name, "forEach");
+
+verifyNotEnumerable(TypedArray.prototype.forEach, "name");
+verifyNotWritable(TypedArray.prototype.forEach, "name");
+verifyConfigurable(TypedArray.prototype.forEach, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js
new file mode 100644
index 0000000000..e966540f48
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.forEach does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.forEach),
+ false,
+ 'isConstructor(TypedArray.prototype.forEach) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.forEach(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.forEach(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js
new file mode 100644
index 0000000000..611f1508a6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ "forEach" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'forEach');
+verifyWritable(TypedArrayPrototype, 'forEach');
+verifyConfigurable(TypedArrayPrototype, 'forEach');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f66026b1e8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.forEach,
+ 'function',
+ 'implements TypedArray.prototype.forEach'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.forEach(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.forEach(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the forEach operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.forEach(() => {});
+ throw new Test262Error('forEach completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js
new file mode 100644
index 0000000000..37a0c81076
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/returns-undefined.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Returns undefined
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(42);
+
+ var result1 = sample1.forEach(function() {
+ return 42;
+ });
+
+ assert.sameValue(result1, undefined, "result1");
+
+ var sample2 = new TA(1);
+ var result2 = sample2.forEach(function() {
+ return null;
+ });
+
+ assert.sameValue(result2, undefined, "result2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js
new file mode 100644
index 0000000000..8a228dc6c3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var forEach = TypedArray.prototype.forEach;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ forEach.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ forEach.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ forEach.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ forEach.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ forEach.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ forEach.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ forEach.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..34677e33e4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var forEach = TypedArray.prototype.forEach;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ forEach.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ forEach.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ forEach.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ forEach.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js
new file mode 100644
index 0000000000..9b1fe0706a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/forEach/values-are-not-cached.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.foreach
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.forEach is a distinct function that implements the same
+ algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length"
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ sample.forEach(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js
new file mode 100644
index 0000000000..323885aee8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13.
+
+ When the includes method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return false.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return false.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let elementK be the result of ! Get(O, ! ToString(F(k))).
+ If SameValueZero(searchElement, elementK) is true, return true.
+ Set k to k + 1.
+ Return false.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.includes(0n, fromIndex), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js
new file mode 100644
index 0000000000..875fc9660d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: >
+ Returns false if buffer is detached after ValidateTypedArray and searchElement is a value
+info: |
+ %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13.
+
+ When the includes method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return false.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return false.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let elementK be the result of ! Get(O, ! ToString(F(k))).
+ If SameValueZero(searchElement, elementK) is true, return true.
+ Set k to k + 1.
+ Return false.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.includes(undefined, fromIndex), true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..ca2f008ce7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.includes(0n);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js
new file mode 100644
index 0000000000..7fa2cc8769
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return false if fromIndex >= ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ ...
+ 7. Repeat, while k < len
+ ...
+ 8. Return false.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA(42);
+ assert.sameValue(sample.includes(0n, 42), false);
+ assert.sameValue(sample.includes(0n, 43), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js
new file mode 100644
index 0000000000..b366f1bb2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ 6. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 7. Repeat, while k < len
+ ...
+ 8. Return false.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 43n, 41n]);
+
+ assert.sameValue(
+ sample.includes(43n, Infinity),
+ false,
+ "includes(43, Infinity)"
+ );
+ assert.sameValue(
+ sample.includes(43n, -Infinity),
+ true,
+ "includes(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..d7d70313f3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ ...
+ 7. Repeat, while k < len
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.includes(42n, -0), true, "-0 [0]");
+ assert.sameValue(sample.includes(43n, -0), true, "-0 [1]");
+ assert.sameValue(sample.includes(44n, -0), false, "-0 [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..992515f668
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.includes(7n), true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js
new file mode 100644
index 0000000000..75d998d717
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Returns false if length is 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return false.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.includes(0), false, "returns false");
+ assert.sameValue(sample.includes(), false, "returns false - no arg");
+ assert.sameValue(
+ sample.includes(0n, fromIndex), false,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..0b97d929e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.includes,
+ 'function',
+ 'implements TypedArray.prototype.includes'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.includes(0n);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.includes(0n);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the includes operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.includes(0n);
+ throw new Test262Error('includes completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..df26b72aed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n]);
+
+ assert.throws(TypeError, function() {
+ sample.includes(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..983e19bd93
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n]);
+
+ assert.throws(Test262Error, function() {
+ sample.includes(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js
new file mode 100644
index 0000000000..48edd20630
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: returns true for found index
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ 6. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+ c. Increase k by 1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.includes(42n), true, "includes(42)");
+ assert.sameValue(sample.includes(43n), true, "includes(43)");
+ assert.sameValue(sample.includes(43n, 1), true, "includes(43, 1)");
+ assert.sameValue(sample.includes(42n, 1), true, "includes(42, 1)");
+ assert.sameValue(sample.includes(42n, 2), true, "includes(42, 2)");
+
+ assert.sameValue(sample.includes(42n, -4), true, "includes(42, -4)");
+ assert.sameValue(sample.includes(42n, -3), true, "includes(42, -3)");
+ assert.sameValue(sample.includes(42n, -2), true, "includes(42, -2)");
+ assert.sameValue(sample.includes(42n, -5), true, "includes(42, -5)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js
new file mode 100644
index 0000000000..e99f8e0e56
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: returns false if the element is not found
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ 6. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+ c. Increase k by 1.
+ 8. Return false.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.includes(44n), false, "includes(44)");
+ assert.sameValue(sample.includes(43n, 2), false, "includes(43, 2)");
+ assert.sameValue(sample.includes(42n, 3), false, "includes(42, 3)");
+ assert.sameValue(sample.includes(44n, -4), false, "includes(44, -4)");
+ assert.sameValue(sample.includes(44n, -5), false, "includes(44, -5)");
+ assert.sameValue(sample.includes(42n, -1), false, "includes(42, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js
new file mode 100644
index 0000000000..67e101024c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: get the integer value from fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ ...
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+ c. Increase k by 1.
+ 8. Return false.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.includes(42n, "1"), false, "string [0]");
+ assert.sameValue(sample.includes(43n, "1"), true, "string [1]");
+
+ assert.sameValue(sample.includes(42n, true), false, "true [0]");
+ assert.sameValue(sample.includes(43n, true), true, "true [1]");
+
+ assert.sameValue(sample.includes(42n, false), true, "false [0]");
+ assert.sameValue(sample.includes(43n, false), true, "false [1]");
+
+ assert.sameValue(sample.includes(42n, NaN), true, "NaN [0]");
+ assert.sameValue(sample.includes(43n, NaN), true, "NaN [1]");
+
+ assert.sameValue(sample.includes(42n, null), true, "null [0]");
+ assert.sameValue(sample.includes(43n, null), true, "null [1]");
+
+ assert.sameValue(sample.includes(42n, undefined), true, "undefined [0]");
+ assert.sameValue(sample.includes(43n, undefined), true, "undefined [1]");
+
+ assert.sameValue(sample.includes(42n, null), true, "null [0]");
+ assert.sameValue(sample.includes(43n, null), true, "null [1]");
+
+ assert.sameValue(sample.includes(42n, obj), false, "object [0]");
+ assert.sameValue(sample.includes(43n, obj), true, "object [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js
new file mode 100644
index 0000000000..493f0bc00d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: >
+ Returns false if buffer is detached after ValidateTypedArray and searchElement is a value
+info: |
+ %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13.
+
+ When the includes method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return false.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return false.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let elementK be the result of ! Get(O, ! ToString(F(k))).
+ If SameValueZero(searchElement, elementK) is true, return true.
+ Set k to k + 1.
+ Return false.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.includes(0, fromIndex), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js
new file mode 100644
index 0000000000..43ba9f0629
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: >
+ Returns true if buffer is detached after ValidateTypedArray and searchElement is undefined
+info: |
+ %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13.
+
+ When the includes method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return false.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return false.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let elementK be the result of ! Get(O, ! ToString(F(k))).
+ If SameValueZero(searchElement, elementK) is true, return true.
+ Set k to k + 1.
+ Return false.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.includes(undefined, fromIndex), true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js
new file mode 100644
index 0000000000..3d8dff1368
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.includes(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js
new file mode 100644
index 0000000000..4298fc7c08
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return false if fromIndex >= ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ ...
+ 7. Repeat, while k < len
+ ...
+ 8. Return false.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA(42);
+ assert.sameValue(sample.includes(0, 42), false);
+ assert.sameValue(sample.includes(0, 43), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js
new file mode 100644
index 0000000000..d067193aaa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-infinity.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ 6. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 7. Repeat, while k < len
+ ...
+ 8. Return false.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 43, 41]);
+
+ assert.sameValue(
+ sample.includes(43, Infinity),
+ false,
+ "includes(43, Infinity)"
+ );
+ assert.sameValue(
+ sample.includes(43, -Infinity),
+ true,
+ "includes(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..0bb301447f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/fromIndex-minus-zero.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ ...
+ 7. Repeat, while k < len
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.includes(42, -0), true, "-0 [0]");
+ assert.sameValue(sample.includes(43, -0), true, "-0 [1]");
+ assert.sameValue(sample.includes(44, -0), false, "-0 [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..b7a1f870a0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.includes(7), true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js
new file mode 100644
index 0000000000..d90cc7b111
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var includes = TypedArray.prototype.includes;
+
+assert.sameValue(typeof includes, "function");
+
+assert.throws(TypeError, function() {
+ includes();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js
new file mode 100644
index 0000000000..0d138bfa6c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.includes, "function");
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.includes();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js
new file mode 100644
index 0000000000..ab59a078d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length-zero-returns-false.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Returns false if length is 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return false.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.includes(0), false, "returns false");
+ assert.sameValue(sample.includes(), false, "returns false - no arg");
+ assert.sameValue(
+ sample.includes(0, fromIndex), false,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js
new file mode 100644
index 0000000000..33e7547d6c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: >
+ %TypedArray%.prototype.includes.length is 1.
+info: |
+ %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.includes.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.includes, "length");
+verifyNotWritable(TypedArray.prototype.includes, "length");
+verifyConfigurable(TypedArray.prototype.includes, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js
new file mode 100644
index 0000000000..a76942e846
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: >
+ %TypedArray%.prototype.includes.name is "includes".
+info: |
+ %TypedArray%.prototype.includes (searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.includes.name, "includes");
+
+verifyNotEnumerable(TypedArray.prototype.includes, "name");
+verifyNotWritable(TypedArray.prototype.includes, "name");
+verifyConfigurable(TypedArray.prototype.includes, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js
new file mode 100644
index 0000000000..726d7ec28f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.includes does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.includes),
+ false,
+ 'isConstructor(TypedArray.prototype.includes) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.includes(1);
+}, '`let u8 = new Uint8Array(1); new u8.includes(1)` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js
new file mode 100644
index 0000000000..3931bd6be2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: >
+ "includes" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, "includes");
+verifyWritable(TypedArrayPrototype, "includes");
+verifyConfigurable(TypedArrayPrototype, "includes");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..eba3b912b3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.includes,
+ 'function',
+ 'implements TypedArray.prototype.includes'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.includes(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.includes(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the includes operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.includes(0);
+ throw new Test262Error('includes completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..495c48b1a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7]);
+
+ assert.throws(TypeError, function() {
+ sample.includes(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..ee5c08f7df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7]);
+
+ assert.throws(Test262Error, function() {
+ sample.includes(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js
new file mode 100644
index 0000000000..6b7438d7ce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/samevaluezero.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: search element is compared using SameValueZero
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+ c. Increase k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 0, 1, undefined]);
+ assert.sameValue(sample.includes(), false, "no arg");
+ assert.sameValue(sample.includes(undefined), false, "undefined");
+ assert.sameValue(sample.includes("42"), false, "'42'");
+ assert.sameValue(sample.includes([42]), false, "[42]");
+ assert.sameValue(sample.includes(42.0), true, "42.0");
+ assert.sameValue(sample.includes(-0), true, "-0");
+ assert.sameValue(sample.includes(true), false, "true");
+ assert.sameValue(sample.includes(false), false, "false");
+ assert.sameValue(sample.includes(null), false, "null");
+ assert.sameValue(sample.includes(""), false, "empty string");
+});
+
+testWithTypedArrayConstructors(function(FloatArray) {
+ var sample = new FloatArray([42, 0, 1, undefined, NaN]);
+ assert.sameValue(sample.includes(NaN), true, "NaN");
+}, [Float32Array, Float64Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js
new file mode 100644
index 0000000000..7d2cf925b7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-found-returns-true.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: returns true for found index
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ 6. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+ c. Increase k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.includes(42), true, "includes(42)");
+ assert.sameValue(sample.includes(43), true, "includes(43)");
+ assert.sameValue(sample.includes(43, 1), true, "includes(43, 1)");
+ assert.sameValue(sample.includes(42, 1), true, "includes(42, 1)");
+ assert.sameValue(sample.includes(42, 2), true, "includes(42, 2)");
+
+ assert.sameValue(sample.includes(42, -4), true, "includes(42, -4)");
+ assert.sameValue(sample.includes(42, -3), true, "includes(42, -3)");
+ assert.sameValue(sample.includes(42, -2), true, "includes(42, -2)");
+ assert.sameValue(sample.includes(42, -5), true, "includes(42, -5)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js
new file mode 100644
index 0000000000..f647deebf9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/search-not-found-returns-false.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: returns false if the element is not found
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ 6. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+ c. Increase k by 1.
+ 8. Return false.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.includes(44), false, "includes(44)");
+ assert.sameValue(sample.includes(43, 2), false, "includes(43, 2)");
+ assert.sameValue(sample.includes(42, 3), false, "includes(42, 3)");
+ assert.sameValue(sample.includes(44, -4), false, "includes(44, -4)");
+ assert.sameValue(sample.includes(44, -5), false, "includes(44, -5)");
+ assert.sameValue(sample.includes(42, -1), false, "includes(42, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js
new file mode 100644
index 0000000000..22d65b5c0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/searchelement-not-integer.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Google. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Check that search element is not coerced if not an integer
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the same algorithm as Array.prototype.includes as defined in 22.1.3.13
+
+ 22.1.3.13 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ 8. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(10);
+ function throwFunc(){
+ throw Test262Error()
+ return 0;
+ }
+
+ assert.sameValue(sample.includes({valueOf : throwFunc}), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js
new file mode 100644
index 0000000000..ffaadb48fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var includes = TypedArray.prototype.includes;
+
+assert.throws(TypeError, function() {
+ includes.call(undefined, 42);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ includes.call(null, 42);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ includes.call(42, 42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ includes.call("1", 42);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ includes.call(true, 42);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ includes.call(false, 42);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ includes.call(s, 42);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..3a7d86dcd3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var includes = TypedArray.prototype.includes;
+
+assert.throws(TypeError, function() {
+ includes.call({}, 42);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ includes.call([], 42);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ includes.call(ab, 42);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ includes.call(dv, 42);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js
new file mode 100644
index 0000000000..ad25ab47d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/includes/tointeger-fromindex.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.includes
+description: get the integer value from fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.includes is a distinct function that implements the
+ same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that
+ the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ ...
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ b. If SameValueZero(searchElement, elementK) is true, return true.
+ c. Increase k by 1.
+ 8. Return false.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.includes(42, "1"), false, "string [0]");
+ assert.sameValue(sample.includes(43, "1"), true, "string [1]");
+
+ assert.sameValue(sample.includes(42, true), false, "true [0]");
+ assert.sameValue(sample.includes(43, true), true, "true [1]");
+
+ assert.sameValue(sample.includes(42, false), true, "false [0]");
+ assert.sameValue(sample.includes(43, false), true, "false [1]");
+
+ assert.sameValue(sample.includes(42, NaN), true, "NaN [0]");
+ assert.sameValue(sample.includes(43, NaN), true, "NaN [1]");
+
+ assert.sameValue(sample.includes(42, null), true, "null [0]");
+ assert.sameValue(sample.includes(43, null), true, "null [1]");
+
+ assert.sameValue(sample.includes(42, undefined), true, "undefined [0]");
+ assert.sameValue(sample.includes(43, undefined), true, "undefined [1]");
+
+ assert.sameValue(sample.includes(42, null), true, "null [0]");
+ assert.sameValue(sample.includes(43, null), true, "null [1]");
+
+ assert.sameValue(sample.includes(42, obj), false, "object [0]");
+ assert.sameValue(sample.includes(43, obj), true, "object [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
new file mode 100644
index 0000000000..47b1f45d07
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(undefined, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
new file mode 100644
index 0000000000..320ed9a30b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(0n, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..84c4b0c14f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.indexOf(0n);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js
new file mode 100644
index 0000000000..925de9d041
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA(42);
+ assert.sameValue(sample.indexOf(0n, 42), -1);
+ assert.sameValue(sample.indexOf(0n, 43), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js
new file mode 100644
index 0000000000..96251608b6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 43n, 41n]);
+
+ assert.sameValue(sample.indexOf(43n, Infinity), -1, "indexOf(43, Infinity)");
+ assert.sameValue(sample.indexOf(43n, -Infinity), 1, "indexOf(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..523e0a6dfb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.indexOf(42n, -0), 0, "-0 [0]");
+ assert.sameValue(sample.indexOf(43n, -0), 1, "-0 [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..7dd8af55a0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.indexOf(7n), 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js
new file mode 100644
index 0000000000..8699512769
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Returns -1 if length is 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return -1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.indexOf(0n), -1, "returns -1");
+ assert.sameValue(
+ sample.indexOf(0n, fromIndex), -1,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.js
new file mode 100644
index 0000000000..e2833a5936
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/no-arg.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ If `searchElement` is not supplied, -1 is returned.
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements
+ the same algorithm as Array.prototype.indexOf as defined in 22.1.3.14
+ except that the this value's [[ArrayLength]] internal slot is accessed
+ in place of performing a [[Get]] of "length".
+
+ Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ [...]
+ 10. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.indexOf(), -1);
+
+ var ta2 = new TA([0n, 1n, 2n]);
+ assert.sameValue(ta2.indexOf(), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..8a774ae4e2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.indexOf,
+ 'function',
+ 'implements TypedArray.prototype.indexOf'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.indexOf(0n);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.indexOf(0n);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the indexOf operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.indexOf(0n);
+ throw new Test262Error('indexOf completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..4d7c7950af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.indexOf(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..59a2d78222
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(Test262Error, function() {
+ sample.indexOf(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js
new file mode 100644
index 0000000000..70c5d26c8e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: returns index for the first found element
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.indexOf(42n), 0, "indexOf(42)");
+ assert.sameValue(sample.indexOf(43n), 1, "indexOf(43)");
+ assert.sameValue(sample.indexOf(43n, 1), 1, "indexOf(43, 1)");
+ assert.sameValue(sample.indexOf(42n, 1), 2, "indexOf(42, 1)");
+ assert.sameValue(sample.indexOf(42n, 2), 2, "indexOf(42, 2)");
+
+ assert.sameValue(sample.indexOf(42n, -4), 0, "indexOf(42, -4)");
+ assert.sameValue(sample.indexOf(42n, -3), 2, "indexOf(42, -3)");
+ assert.sameValue(sample.indexOf(42n, -2), 2, "indexOf(42, -2)");
+ assert.sameValue(sample.indexOf(42n, -5), 0, "indexOf(42, -5)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js
new file mode 100644
index 0000000000..bb62c56ffe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: returns -1 if the element if not found
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ ...
+ 9. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.indexOf(44n), -1, "indexOf(44)");
+ assert.sameValue(sample.indexOf(43n, 2), -1, "indexOf(43, 2)");
+ assert.sameValue(sample.indexOf(42n, 3), -1, "indexOf(42, 3)");
+ assert.sameValue(sample.indexOf(44n, -4), -1, "indexOf(44, -4)");
+ assert.sameValue(sample.indexOf(44n, -5), -1, "indexOf(44, -5)");
+ assert.sameValue(sample.indexOf(42n, -1), -1, "indexOf(42, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js
new file mode 100644
index 0000000000..7f141f9ef0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength - converted values
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.indexOf(42n, "1"), -1, "string [0]");
+ assert.sameValue(sample.indexOf(43n, "1"), 1, "string [1]");
+
+ assert.sameValue(sample.indexOf(42n, true), -1, "true [0]");
+ assert.sameValue(sample.indexOf(43n, true), 1, "true [1]");
+
+ assert.sameValue(sample.indexOf(42n, false), 0, "false [0]");
+ assert.sameValue(sample.indexOf(43n, false), 1, "false [1]");
+
+ assert.sameValue(sample.indexOf(42n, NaN), 0, "NaN [0]");
+ assert.sameValue(sample.indexOf(43n, NaN), 1, "NaN [1]");
+
+ assert.sameValue(sample.indexOf(42n, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43n, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42n, undefined), 0, "undefined [0]");
+ assert.sameValue(sample.indexOf(43n, undefined), 1, "undefined [1]");
+
+ assert.sameValue(sample.indexOf(42n, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43n, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42n, obj), -1, "object [0]");
+ assert.sameValue(sample.indexOf(43n, obj), 1, "object [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
new file mode 100644
index 0000000000..7081b55ed5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(undefined, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
new file mode 100644
index 0000000000..8fff2cbb75
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14.
+
+ When the indexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ Let n be ? ToIntegerOrInfinity(fromIndex).
+ Assert: If fromIndex is undefined, then n is 0.
+ If n is +∞, return -1F.
+ Else if n is -∞, set n to 0.
+ If n ≥ 0, then
+ Let k be n.
+ Else,
+ Let k be len + n.
+ If k < 0, set k to 0.
+ Repeat, while k < len,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k + 1.
+ Return -1F.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.indexOf(0, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js
new file mode 100644
index 0000000000..60c374ad87
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.indexOf(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js
new file mode 100644
index 0000000000..de345d49a2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA(42);
+ assert.sameValue(sample.indexOf(0, 42), -1);
+ assert.sameValue(sample.indexOf(0, 43), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js
new file mode 100644
index 0000000000..1f75f72769
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-infinity.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 43, 41]);
+
+ assert.sameValue(sample.indexOf(43, Infinity), -1, "indexOf(43, Infinity)");
+ assert.sameValue(sample.indexOf(43, -Infinity), 1, "indexOf(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..6bd0d4b447
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.indexOf(42, -0), 0, "-0 [0]");
+ assert.sameValue(sample.indexOf(43, -0), 1, "-0 [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..04738cec2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.indexOf(7), 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js
new file mode 100644
index 0000000000..84ca275587
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var indexOf = TypedArray.prototype.indexOf;
+
+assert.sameValue(typeof indexOf, 'function');
+
+assert.throws(TypeError, function() {
+ indexOf();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js
new file mode 100644
index 0000000000..a0617fd2a2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.indexOf, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.indexOf();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js
new file mode 100644
index 0000000000..37163cf2aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Returns -1 if length is 0
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return -1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.indexOf(0), -1, "returns -1");
+ assert.sameValue(
+ sample.indexOf(0, fromIndex), -1,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js
new file mode 100644
index 0000000000..5c866bebad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ %TypedArray%.prototype.indexOf.length is 1.
+info: |
+ %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.indexOf.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.indexOf, "length");
+verifyNotWritable(TypedArray.prototype.indexOf, "length");
+verifyConfigurable(TypedArray.prototype.indexOf, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js
new file mode 100644
index 0000000000..54aea8a605
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ %TypedArray%.prototype.indexOf.name is "indexOf".
+info: |
+ %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.indexOf.name, "indexOf");
+
+verifyNotEnumerable(TypedArray.prototype.indexOf, "name");
+verifyNotWritable(TypedArray.prototype.indexOf, "name");
+verifyConfigurable(TypedArray.prototype.indexOf, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js
new file mode 100644
index 0000000000..57015f26c9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/no-arg.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ If `searchElement` is not supplied, -1 is returned.
+info: |
+ %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements
+ the same algorithm as Array.prototype.indexOf as defined in 22.1.3.14
+ except that the this value's [[ArrayLength]] internal slot is accessed
+ in place of performing a [[Get]] of "length".
+
+ Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ [...]
+ 10. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.indexOf(), -1);
+
+ var ta2 = new TA([0, 1, 2]);
+ assert.sameValue(ta2.indexOf(), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js
new file mode 100644
index 0000000000..7ada33c348
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.indexOf does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.indexOf),
+ false,
+ 'isConstructor(TypedArray.prototype.indexOf) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.indexOf();
+}, '`let u8 = new Uint8Array(1); new u8.indexOf()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js
new file mode 100644
index 0000000000..be05ced431
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ "indexOf" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'indexOf');
+verifyWritable(TypedArrayPrototype, 'indexOf');
+verifyConfigurable(TypedArrayPrototype, 'indexOf');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..ec11f3167c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.indexOf,
+ 'function',
+ 'implements TypedArray.prototype.indexOf'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.indexOf(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.indexOf(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the indexOf operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.indexOf(0);
+ throw new Test262Error('indexOf completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..21820e40ae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.indexOf(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..7789414bdc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(Test262Error, function() {
+ sample.indexOf(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js
new file mode 100644
index 0000000000..810caadd88
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-found-returns-index.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: returns index for the first found element
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ 8. Repeat, while k < len
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.indexOf(42), 0, "indexOf(42)");
+ assert.sameValue(sample.indexOf(43), 1, "indexOf(43)");
+ assert.sameValue(sample.indexOf(43, 1), 1, "indexOf(43, 1)");
+ assert.sameValue(sample.indexOf(42, 1), 2, "indexOf(42, 1)");
+ assert.sameValue(sample.indexOf(42, 2), 2, "indexOf(42, 2)");
+
+ assert.sameValue(sample.indexOf(42, -4), 0, "indexOf(42, -4)");
+ assert.sameValue(sample.indexOf(42, -3), 2, "indexOf(42, -3)");
+ assert.sameValue(sample.indexOf(42, -2), 2, "indexOf(42, -2)");
+ assert.sameValue(sample.indexOf(42, -5), 0, "indexOf(42, -5)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js
new file mode 100644
index 0000000000..e270f87c37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: returns -1 if the element if not found
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 6. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be n.
+ 7. Else n < 0,
+ a. Let k be len + n.
+ b. If k < 0, let k be 0.
+ ...
+ 9. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.indexOf(44), -1, "indexOf(44)");
+ assert.sameValue(sample.indexOf(43, 2), -1, "indexOf(43, 2)");
+ assert.sameValue(sample.indexOf(42, 3), -1, "indexOf(42, 3)");
+ assert.sameValue(sample.indexOf(44, -4), -1, "indexOf(44, -4)");
+ assert.sameValue(sample.indexOf(44, -5), -1, "indexOf(44, -5)");
+ assert.sameValue(sample.indexOf(42, -1), -1, "indexOf(42, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js
new file mode 100644
index 0000000000..64e9e774e5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/strict-comparison.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: search element is compared using strict comparing (===)
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 0, 1, undefined, NaN]);
+ assert.sameValue(sample.indexOf("42"), -1, "'42'");
+ assert.sameValue(sample.indexOf([42]), -1, "[42]");
+ assert.sameValue(sample.indexOf(42.0), 0, "42.0");
+ assert.sameValue(sample.indexOf(-0), 1, "-0");
+ assert.sameValue(sample.indexOf(true), -1, "true");
+ assert.sameValue(sample.indexOf(false), -1, "false");
+ assert.sameValue(sample.indexOf(NaN), -1, "NaN === NaN is false");
+ assert.sameValue(sample.indexOf(null), -1, "null");
+ assert.sameValue(sample.indexOf(undefined), -1, "undefined");
+ assert.sameValue(sample.indexOf(""), -1, "empty string");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js
new file mode 100644
index 0000000000..9bb19be858
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var indexOf = TypedArray.prototype.indexOf;
+
+assert.throws(TypeError, function() {
+ indexOf.call(undefined, 42);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ indexOf.call(null, 42);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ indexOf.call(42, 42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ indexOf.call("1", 42);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ indexOf.call(true, 42);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ indexOf.call(false, 42);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ indexOf.call(s, 42);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..22fff52e60
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var indexOf = TypedArray.prototype.indexOf;
+
+assert.throws(TypeError, function() {
+ indexOf.call({}, 42);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ indexOf.call([], 42);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ indexOf.call(ab, 42);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ indexOf.call(dv, 42);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js
new file mode 100644
index 0000000000..07f6808fdc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/indexOf/tointeger-fromindex.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.indexof
+description: Return -1 if fromIndex >= ArrayLength - converted values
+info: |
+ 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.indexOf is a distinct function that implements the same
+ algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
+ produces the value 0.)
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.indexOf(42, "1"), -1, "string [0]");
+ assert.sameValue(sample.indexOf(43, "1"), 1, "string [1]");
+
+ assert.sameValue(sample.indexOf(42, true), -1, "true [0]");
+ assert.sameValue(sample.indexOf(43, true), 1, "true [1]");
+
+ assert.sameValue(sample.indexOf(42, false), 0, "false [0]");
+ assert.sameValue(sample.indexOf(43, false), 1, "false [1]");
+
+ assert.sameValue(sample.indexOf(42, NaN), 0, "NaN [0]");
+ assert.sameValue(sample.indexOf(43, NaN), 1, "NaN [1]");
+
+ assert.sameValue(sample.indexOf(42, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42, undefined), 0, "undefined [0]");
+ assert.sameValue(sample.indexOf(43, undefined), 1, "undefined [1]");
+
+ assert.sameValue(sample.indexOf(42, null), 0, "null [0]");
+ assert.sameValue(sample.indexOf(43, null), 1, "null [1]");
+
+ assert.sameValue(sample.indexOf(42, obj), -1, "object [0]");
+ assert.sameValue(sample.indexOf(43, obj), 1, "object [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js
new file mode 100644
index 0000000000..f1bd47bc53
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js
@@ -0,0 +1,80 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: >
+ Concatenates the result of toString for each value with custom separator
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 7. If element0 is undefined or null, let R be the empty String; otherwise, let
+ R be ? ToString(element0).
+ 8. Let k be 1.
+ 9. Repeat, while k < len
+ a. Let S be the String value produced by concatenating R and sep.
+ b. Let element be ? Get(O, ! ToString(k)).
+ c. If element is undefined or null, let next be the empty String; otherwise,
+ let next be ? ToString(element).
+ d. Let R be a String value produced by concatenating S and next.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 0n, 2n, 3n, 42n, 127n]);
+
+ var result;
+
+ result = sample.join(",");
+ assert.sameValue(result, "1,0,2,3,42,127");
+
+ result = sample.join(undefined);
+ assert.sameValue(result, "1,0,2,3,42,127");
+
+ result = sample.join(null);
+ assert.sameValue(result, "1null0null2null3null42null127");
+
+ result = sample.join(",,");
+ assert.sameValue(result, "1,,0,,2,,3,,42,,127");
+
+ result = sample.join(0);
+ assert.sameValue(result, "10002030420127");
+
+ result = sample.join("");
+ assert.sameValue(result, "102342127");
+
+ result = sample.join(" a b c ");
+ assert.sameValue(result, "1 a b c 0 a b c 2 a b c 3 a b c 42 a b c 127");
+
+ result = sample.join({});
+ assert.sameValue(result, "1[object Object]0[object Object]2[object Object]3[object Object]42[object Object]127");
+
+ result = sample.join(true);
+ assert.sameValue(result, "1true0true2true3true42true127");
+
+ result = sample.join({ toString: function() { return "foo"; }});
+ assert.sameValue(result, "1foo0foo2foo3foo42foo127");
+
+ result = sample.join({ toString: undefined, valueOf: function() { return "bar"; }});
+ assert.sameValue(result, "1bar0bar2bar3bar42bar127");
+
+ result = sample.join(false);
+ assert.sameValue(result, "1false0false2false3false42false127");
+
+ result = sample.join(-1);
+ assert.sameValue(result, "1-10-12-13-142-1127");
+
+ result = sample.join(-0);
+ assert.sameValue(result, "10002030420127");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js
new file mode 100644
index 0000000000..d5d51beb51
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Returns single separator if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.join ( separator )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15.
+
+ When the join method is called with one argument separator, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If separator is undefined, let sep be the single-element String ",".
+ Else, let sep be ? ToString(separator).
+ Let R be the empty String.
+ Let k be 0.
+ Repeat, while k < len,
+ If k > 0, set R to the string-concatenation of R and sep.
+ Let element be ! Get(O, ! ToString(𝔽(k))).
+ If element is undefined or null, let next be the empty String; otherwise, let next be ! ToString(element).
+ Set R to the string-concatenation of R and next.
+ Set k to k + 1.
+ Return R.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA([1n,2n,3n]);
+ const separator = {
+ toString() {
+ $DETACHBUFFER(sample.buffer);
+ return ',';
+ }
+ };
+
+ assert.sameValue(sample.join(separator), ',,');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..e7aeb7c15e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/detached-buffer.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.join ( separator )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15.
+
+ When the join method is called with one argument separator, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ ...
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+let obj = {
+ toString() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, () => {
+ sample.join(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js
new file mode 100644
index 0000000000..3636e8c8a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return the empty String if length is 0
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 4. Let sep be ? ToString(separator).
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.sameValue(sample.join(), "");
+ assert.sameValue(sample.join("test262"), "");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..28e6929360
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ var result = sample.join();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.notSameValue(result, "", "result is not affected but custom length 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js
new file mode 100644
index 0000000000..905cb9dc48
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Concatenates the result of toString for each simple value
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 7. If element0 is undefined or null, let R be the empty String; otherwise, let
+ R be ? ToString(element0).
+ 8. Let k be 1.
+ 9. Repeat, while k < len
+ a. Let S be the String value produced by concatenating R and sep.
+ b. Let element be ? Get(O, ! ToString(k)).
+ c. If element is undefined or null, let next be the empty String; otherwise,
+ let next be ? ToString(element).
+ d. Let R be a String value produced by concatenating S and next.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 0n, 2n, 3n, 42n, 127n]);
+
+ var result = sample.join();
+
+ assert.sameValue(result, "1,0,2,3,42,127");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js
new file mode 100644
index 0000000000..d4162a247f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return abrupt from ToString(Symbol separator)
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 4. Let sep be ? ToString(separator).
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.join(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js
new file mode 100644
index 0000000000..6c280a1326
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return abrupt from ToString(separator)
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 4. Let sep be ? ToString(separator).
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.join(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..7b8d2a5db7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.join,
+ 'function',
+ 'implements TypedArray.prototype.join'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.join(',');
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.join(',');
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the join operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.join(',');
+ throw new Test262Error('join completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js
new file mode 100644
index 0000000000..319f85e9c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js
@@ -0,0 +1,80 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: >
+ Concatenates the result of toString for each value with custom separator
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 7. If element0 is undefined or null, let R be the empty String; otherwise, let
+ R be ? ToString(element0).
+ 8. Let k be 1.
+ 9. Repeat, while k < len
+ a. Let S be the String value produced by concatenating R and sep.
+ b. Let element be ? Get(O, ! ToString(k)).
+ c. If element is undefined or null, let next be the empty String; otherwise,
+ let next be ? ToString(element).
+ d. Let R be a String value produced by concatenating S and next.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 0, 2, 3, 42, 127]);
+
+ var result;
+
+ result = sample.join(",");
+ assert.sameValue(result, "1,0,2,3,42,127");
+
+ result = sample.join(undefined);
+ assert.sameValue(result, "1,0,2,3,42,127");
+
+ result = sample.join(null);
+ assert.sameValue(result, "1null0null2null3null42null127");
+
+ result = sample.join(",,");
+ assert.sameValue(result, "1,,0,,2,,3,,42,,127");
+
+ result = sample.join(0);
+ assert.sameValue(result, "10002030420127");
+
+ result = sample.join("");
+ assert.sameValue(result, "102342127");
+
+ result = sample.join(" a b c ");
+ assert.sameValue(result, "1 a b c 0 a b c 2 a b c 3 a b c 42 a b c 127");
+
+ result = sample.join({});
+ assert.sameValue(result, "1[object Object]0[object Object]2[object Object]3[object Object]42[object Object]127");
+
+ result = sample.join(true);
+ assert.sameValue(result, "1true0true2true3true42true127");
+
+ result = sample.join({ toString: function() { return "foo"; }});
+ assert.sameValue(result, "1foo0foo2foo3foo42foo127");
+
+ result = sample.join({ toString: undefined, valueOf: function() { return "bar"; }});
+ assert.sameValue(result, "1bar0bar2bar3bar42bar127");
+
+ result = sample.join(false);
+ assert.sameValue(result, "1false0false2false3false42false127");
+
+ result = sample.join(-1);
+ assert.sameValue(result, "1-10-12-13-142-1127");
+
+ result = sample.join(-0);
+ assert.sameValue(result, "10002030420127");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js
new file mode 100644
index 0000000000..02235e1b35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js
@@ -0,0 +1,137 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: >
+ Concatenates the result of toString for each value with custom separator
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 7. If element0 is undefined or null, let R be the empty String; otherwise, let
+ R be ? ToString(element0).
+ 8. Let k be 1.
+ 9. Repeat, while k < len
+ a. Let S be the String value produced by concatenating R and sep.
+ b. Let element be ? Get(O, ! ToString(k)).
+ c. If element is undefined or null, let next be the empty String; otherwise,
+ let next be ? ToString(element).
+ d. Let R be a String value produced by concatenating S and next.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992];
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(arr);
+ var result, separator, expected;
+
+ separator = ",";
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected);
+
+ separator = undefined;
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = null;
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = ",,";
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = 0;
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = "";
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = " a b c ";
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = {};
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = { toString: function() { return "foo"; }};
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = { toString: undefined, valueOf: function() { return "bar"; }};
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = true;
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = false;
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = 1;
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+
+ separator = 0;
+ expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join(separator);
+ result = sample.join(separator);
+ assert.sameValue(result, expected, "using: " + separator);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js
new file mode 100644
index 0000000000..660c1e497d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Returns single separator if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.join ( separator )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15.
+
+ When the join method is called with one argument separator, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If separator is undefined, let sep be the single-element String ",".
+ Else, let sep be ? ToString(separator).
+ Let R be the empty String.
+ Let k be 0.
+ Repeat, while k < len,
+ If k > 0, set R to the string-concatenation of R and sep.
+ Let element be ! Get(O, ! ToString(𝔽(k))).
+ If element is undefined or null, let next be the empty String; otherwise, let next be ! ToString(element).
+ Set R to the string-concatenation of R and next.
+ Set k to k + 1.
+ Return R.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA([1,2,3]);
+ const separator = {
+ toString() {
+ $DETACHBUFFER(sample.buffer);
+ return ',';
+ }
+ };
+
+ assert.sameValue(sample.join(separator), ',,');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js
new file mode 100644
index 0000000000..a78b14a226
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/detached-buffer.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Throws a TypeError if this has a detached buffer
+info: |
+ %TypedArray%.prototype.join ( separator )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15.
+
+ When the join method is called with one argument separator, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ ...
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+let obj = {
+ toString() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ let sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, () => {
+ sample.join(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js
new file mode 100644
index 0000000000..54e40f5194
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/empty-instance-empty-string.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return the empty String if length is 0
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 4. Let sep be ? ToString(separator).
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.sameValue(sample.join(), "");
+ assert.sameValue(sample.join("test262"), "");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..95b4bac090
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ var result = sample.join();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.notSameValue(result, "", "result is not affected but custom length 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js
new file mode 100644
index 0000000000..035a040719
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.14 %TypedArray%.prototype.join ( separator )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var join = TypedArray.prototype.join;
+
+assert.sameValue(typeof join, 'function');
+
+assert.throws(TypeError, function() {
+ join();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js
new file mode 100644
index 0000000000..d57a9cd0b3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.14 %TypedArray%.prototype.join ( separator )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.join, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.join();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js
new file mode 100644
index 0000000000..2ba19e6f94
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.join
+description: >
+ %TypedArray%.prototype.join.length is 1.
+info: |
+ %TypedArray%.prototype.join ( separator )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.join.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.join, "length");
+verifyNotWritable(TypedArray.prototype.join, "length");
+verifyConfigurable(TypedArray.prototype.join, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js
new file mode 100644
index 0000000000..df6cec6248
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.join
+description: >
+ %TypedArray%.prototype.join.name is "join".
+info: |
+ %TypedArray%.prototype.join ( separator )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.join.name, "join");
+
+verifyNotEnumerable(TypedArray.prototype.join, "name");
+verifyNotWritable(TypedArray.prototype.join, "name");
+verifyConfigurable(TypedArray.prototype.join, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js
new file mode 100644
index 0000000000..7ab017fbf1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.join does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.join),
+ false,
+ 'isConstructor(TypedArray.prototype.join) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.join();
+}, '`let u8 = new Uint8Array(1); new u8.join()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js
new file mode 100644
index 0000000000..c42df0790b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: >
+ "join" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'join');
+verifyWritable(TypedArrayPrototype, 'join');
+verifyConfigurable(TypedArrayPrototype, 'join');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js
new file mode 100644
index 0000000000..9a21ff741a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Concatenates the result of toString for each simple value
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 7. If element0 is undefined or null, let R be the empty String; otherwise, let
+ R be ? ToString(element0).
+ 8. Let k be 1.
+ 9. Repeat, while k < len
+ a. Let S be the String value produced by concatenating R and sep.
+ b. Let element be ? Get(O, ! ToString(k)).
+ c. If element is undefined or null, let next be the empty String; otherwise,
+ let next be ? ToString(element).
+ d. Let R be a String value produced by concatenating S and next.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 0, 2, 3, 42, 127]);
+
+ var result = sample.join();
+
+ assert.sameValue(result, "1,0,2,3,42,127");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js
new file mode 100644
index 0000000000..082e482b9f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/result-from-tostring-on-each-value.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Concatenates the result of toString for each value
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 7. If element0 is undefined or null, let R be the empty String; otherwise, let
+ R be ? ToString(element0).
+ 8. Let k be 1.
+ 9. Repeat, while k < len
+ a. Let S be the String value produced by concatenating R and sep.
+ b. Let element be ? Get(O, ! ToString(k)).
+ c. If element is undefined or null, let next be the empty String; otherwise,
+ let next be ? ToString(element).
+ d. Let R be a String value produced by concatenating S and next.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992];
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(arr);
+
+ // Use converted values using Array methods as helpers
+ var expected = arr.map(function(_, i) {
+ return sample[i].toString();
+ }).join();
+
+ var result = sample.join();
+
+ assert.sameValue(result, expected);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js
new file mode 100644
index 0000000000..ce5ad17b4b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return abrupt from ToString(Symbol separator)
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 4. Let sep be ? ToString(separator).
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.join(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js
new file mode 100644
index 0000000000..a530a4714b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-separator.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return abrupt from ToString(separator)
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ %TypedArray%.prototype.join is a distinct function that implements the same
+ algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.13 Array.prototype.join (separator)
+
+ ...
+ 4. Let sep be ? ToString(separator).
+ 5. If len is zero, return the empty String.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.join(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..c732fa7f4d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.join,
+ 'function',
+ 'implements TypedArray.prototype.join'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.join(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.join(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the join operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.join(0);
+ throw new Test262Error('join completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js
new file mode 100644
index 0000000000..ff4ef67fd1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var join = TypedArray.prototype.join;
+
+assert.throws(TypeError, function() {
+ join.call(undefined, "");
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ join.call(null, "");
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ join.call(42, "");
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ join.call("1", "");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ join.call(true, "");
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ join.call(false, "");
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ join.call(s, "");
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..926c39a97e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.join
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var join = TypedArray.prototype.join;
+
+assert.throws(TypeError, function() {
+ join.call({}, "");
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ join.call([], "");
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ join.call(ab, "");
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ join.call(dv, "");
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..de2496958a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/detached-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.keys();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/iter-prototype.js
new file mode 100644
index 0000000000..1a1a31d0f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/iter-prototype.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: >
+ The prototype of the returned iterator is ArrayIteratorPrototype
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key").
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.iterator, TypedArray]
+---*/
+
+var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]());
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n, 42n, 64n]);
+ var iter = sample.keys();
+
+ assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..dcba1b2983
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.keys,
+ 'function',
+ 'implements TypedArray.prototype.keys'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.keys();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.keys();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the keys operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.keys();
+ throw new Test262Error('keys completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js
new file mode 100644
index 0000000000..7c6d00ea99
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/return-itor.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Return an iterator for the keys.
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key").
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var sample = [0n, 42n, 64n];
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(sample);
+ var itor = typedArray.keys();
+
+ var next = itor.next();
+ assert.sameValue(next.value, 0);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 1);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 2);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, undefined);
+ assert.sameValue(next.done, true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js
new file mode 100644
index 0000000000..3221123031
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/detached-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.keys();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js
new file mode 100644
index 0000000000..130d3c9220
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.15 %TypedArray%.prototype.keys ( )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var keys = TypedArray.prototype.keys;
+
+assert.sameValue(typeof keys, 'function');
+
+assert.throws(TypeError, function() {
+ keys();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js
new file mode 100644
index 0000000000..15ac944e05
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.15 %TypedArray%.prototype.keys ( )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.keys, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.keys();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js
new file mode 100644
index 0000000000..427367bb4e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/iter-prototype.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: >
+ The prototype of the returned iterator is ArrayIteratorPrototype
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key").
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]());
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([0, 42, 64]);
+ var iter = sample.keys();
+
+ assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js
new file mode 100644
index 0000000000..73abbf3fb9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: >
+ %TypedArray%.prototype.keys.length is 0.
+info: |
+ %TypedArray%.prototype.keys ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.keys.length, 0);
+
+verifyNotEnumerable(TypedArray.prototype.keys, "length");
+verifyNotWritable(TypedArray.prototype.keys, "length");
+verifyConfigurable(TypedArray.prototype.keys, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js
new file mode 100644
index 0000000000..f0f097382f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: >
+ %TypedArray%.prototype.keys.name is "keys".
+info: |
+ %TypedArray%.prototype.keys ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.keys.name, "keys");
+
+verifyNotEnumerable(TypedArray.prototype.keys, "name");
+verifyNotWritable(TypedArray.prototype.keys, "name");
+verifyConfigurable(TypedArray.prototype.keys, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js
new file mode 100644
index 0000000000..a5475acf51
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.keys does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.keys),
+ false,
+ 'isConstructor(TypedArray.prototype.keys) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.keys();
+}, '`let u8 = new Uint8Array(1); new u8.keys()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js
new file mode 100644
index 0000000000..8e2f483c11
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: >
+ "keys" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'keys');
+verifyWritable(TypedArrayPrototype, 'keys');
+verifyConfigurable(TypedArrayPrototype, 'keys');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..17fc8a8e66
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.keys,
+ 'function',
+ 'implements TypedArray.prototype.keys'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.keys();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.keys();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the keys operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.keys();
+ throw new Test262Error('keys completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js
new file mode 100644
index 0000000000..5f06a7de97
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/return-itor.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Return an iterator for the keys.
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "key").
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var sample = [0, 42, 64];
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(sample);
+ var itor = typedArray.keys();
+
+ var next = itor.next();
+ assert.sameValue(next.value, 0);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 1);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 2);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, undefined);
+ assert.sameValue(next.done, true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js
new file mode 100644
index 0000000000..57d767940d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-object.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var keys = TypedArray.prototype.keys;
+
+assert.throws(TypeError, function() {
+ keys.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ keys.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ keys.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ keys.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ keys.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ keys.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ keys.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..d2c1ecfea8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.keys
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.16 %TypedArray%.prototype.keys ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var keys = TypedArray.prototype.keys;
+
+assert.throws(TypeError, function() {
+ keys.call({});
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ keys.call([]);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ keys.call(ab);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ keys.call(dv);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
new file mode 100644
index 0000000000..458639da70
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17.
+
+ When the lastIndexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1.
+ If n is -∞, return -1F.
+ If n ≥ 0, then
+ Let k be min(n, len - 1).
+ Else,
+ Let k be len + n.
+ Repeat, while k ≥ 0,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k - 1.
+ Return -1F.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.lastIndexOf(undefined, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
new file mode 100644
index 0000000000..f3b01be14a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17.
+
+ When the lastIndexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1.
+ If n is -∞, return -1F.
+ If n ≥ 0, then
+ Let k be min(n, len - 1).
+ Else,
+ Let k be len + n.
+ Repeat, while k ≥ 0,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k - 1.
+ Return -1F.
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.lastIndexOf(0n, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..0f68c3e0b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.lastIndexOf(0n);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js
new file mode 100644
index 0000000000..0a47fd2977
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ 6. Else n < 0,
+ a. Let k be len + n.
+ 7. Repeat, while k ≥ 0
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 43n, 41n]);
+
+ assert.sameValue(sample.lastIndexOf(43n, Infinity), 2, "lastIndexOf(43, Infinity)");
+ assert.sameValue(sample.lastIndexOf(43n, -Infinity), -1, "lastIndexOf(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..9f2317a0fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.lastIndexOf(42n, -0), 0, "-0 [0]");
+ assert.sameValue(sample.lastIndexOf(43n, -0), -1, "-0 [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..a201e44d1f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.lastIndexOf(7n), 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js
new file mode 100644
index 0000000000..3d61fa75c9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Returns -1 if length is 0
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return -1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.lastIndexOf(0), -1, "returns -1");
+ assert.sameValue(
+ sample.lastIndexOf(0n, fromIndex), -1,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js
new file mode 100644
index 0000000000..92290ed589
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: >
+ If `searchElement` is not supplied, -1 is returned.
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements
+ the same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.17
+ except that the this value's [[ArrayLength]] internal slot is accessed
+ in place of performing a [[Get]] of "length".
+
+ Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ [...]
+ 8. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.lastIndexOf(), -1);
+
+ var ta2 = new TA([0n, 1n, 2n]);
+ assert.sameValue(ta2.lastIndexOf(), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..a5b1c10767
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.lastIndexOf,
+ 'function',
+ 'implements TypedArray.prototype.lastIndexOf'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.lastIndexOf(0n);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.lastIndexOf(0n);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the lastIndexOf operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.lastIndexOf(0n);
+ throw new Test262Error('lastIndexOf completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..e1c12c6efe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let
+ n be len-1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.lastIndexOf(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..e25b5c5778
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let
+ n be len-1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(Test262Error, function() {
+ sample.lastIndexOf(7n, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js
new file mode 100644
index 0000000000..c0160be2d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: returns index for the first found element
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ 6. Else n < 0,
+ a. Let k be len + n.
+ 7. Repeat, while k ≥ 0
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.lastIndexOf(42n), 2, "lastIndexOf(42)");
+ assert.sameValue(sample.lastIndexOf(43n), 1, "lastIndexOf(43)");
+ assert.sameValue(sample.lastIndexOf(41n), 3, "lastIndexOf(41)");
+ assert.sameValue(sample.lastIndexOf(41n, 3), 3, "lastIndexOf(41, 3)");
+ assert.sameValue(sample.lastIndexOf(41n, 4), 3, "lastIndexOf(41, 4)");
+ assert.sameValue(sample.lastIndexOf(43n, 1), 1, "lastIndexOf(43, 1)");
+ assert.sameValue(sample.lastIndexOf(43n, 2), 1, "lastIndexOf(43, 2)");
+ assert.sameValue(sample.lastIndexOf(43n, 3), 1, "lastIndexOf(43, 3)");
+ assert.sameValue(sample.lastIndexOf(43n, 4), 1, "lastIndexOf(43, 4)");
+ assert.sameValue(sample.lastIndexOf(42n, 0), 0, "lastIndexOf(42, 0)");
+ assert.sameValue(sample.lastIndexOf(42n, 1), 0, "lastIndexOf(42, 1)");
+ assert.sameValue(sample.lastIndexOf(42n, 2), 2, "lastIndexOf(42, 2)");
+ assert.sameValue(sample.lastIndexOf(42n, 3), 2, "lastIndexOf(42, 3)");
+ assert.sameValue(sample.lastIndexOf(42n, 4), 2, "lastIndexOf(42, 4)");
+ assert.sameValue(sample.lastIndexOf(42n, -4), 0, "lastIndexOf(42, -4)");
+ assert.sameValue(sample.lastIndexOf(42n, -3), 0, "lastIndexOf(42, -3)");
+ assert.sameValue(sample.lastIndexOf(42n, -2), 2, "lastIndexOf(42, -2)");
+ assert.sameValue(sample.lastIndexOf(42n, -1), 2, "lastIndexOf(42, -1)");
+ assert.sameValue(sample.lastIndexOf(43n, -3), 1, "lastIndexOf(43, -3)");
+ assert.sameValue(sample.lastIndexOf(43n, -2), 1, "lastIndexOf(43, -2)");
+ assert.sameValue(sample.lastIndexOf(43n, -1), 1, "lastIndexOf(43, -1)");
+ assert.sameValue(sample.lastIndexOf(41n, -1), 3, "lastIndexOf(41, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js
new file mode 100644
index 0000000000..32e59c6e18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: returns -1 if the element if not found
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ 6. Else n < 0,
+ a. Let k be len + n.
+ 7. Repeat, while k ≥ 0
+ ...
+ 8. Return -1.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n, 42n, 41n]);
+ assert.sameValue(sample.lastIndexOf(44n), -1, "lastIndexOf(44)");
+ assert.sameValue(sample.lastIndexOf(44n, -4), -1, "lastIndexOf(44, -4)");
+ assert.sameValue(sample.lastIndexOf(44n, -5), -1, "lastIndexOf(44, -5)");
+ assert.sameValue(sample.lastIndexOf(42n, -5), -1, "lastIndexOf(42, -5)");
+ assert.sameValue(sample.lastIndexOf(43n, -4), -1, "lastIndexOf(43, -4)");
+ assert.sameValue(sample.lastIndexOf(43n, -5), -1, "lastIndexOf(43, -5)");
+ assert.sameValue(sample.lastIndexOf(41n, 0), -1, "lastIndexOf(41, 0)");
+ assert.sameValue(sample.lastIndexOf(41n, 1), -1, "lastIndexOf(41, 1)");
+ assert.sameValue(sample.lastIndexOf(41n, 2), -1, "lastIndexOf(41, 2)");
+ assert.sameValue(sample.lastIndexOf(43n, 0), -1, "lastIndexOf(43, 0)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js
new file mode 100644
index 0000000000..d93763019a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return -1 if fromIndex >= ArrayLength - converted values
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let
+ n be len-1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42n, 43n]);
+ assert.sameValue(sample.lastIndexOf(42n, "1"), 0, "string [0]");
+ assert.sameValue(sample.lastIndexOf(43n, "1"), 1, "string [1]");
+
+ assert.sameValue(sample.lastIndexOf(42n, true), 0, "true [0]");
+ assert.sameValue(sample.lastIndexOf(43n, true), 1, "true [1]");
+
+ assert.sameValue(sample.lastIndexOf(42n, false), 0, "false [0]");
+ assert.sameValue(sample.lastIndexOf(43n, false), -1, "false [1]");
+
+ assert.sameValue(sample.lastIndexOf(42n, NaN), 0, "NaN [0]");
+ assert.sameValue(sample.lastIndexOf(43n, NaN), -1, "NaN [1]");
+
+ assert.sameValue(sample.lastIndexOf(42n, null), 0, "null [0]");
+ assert.sameValue(sample.lastIndexOf(43n, null), -1, "null [1]");
+
+ assert.sameValue(sample.lastIndexOf(42n, undefined), 0, "undefined [0]");
+ assert.sameValue(sample.lastIndexOf(43n, undefined), -1, "undefined [1]");
+
+ assert.sameValue(sample.lastIndexOf(42n, null), 0, "null [0]");
+ assert.sameValue(sample.lastIndexOf(43n, null), -1, "null [1]");
+
+ assert.sameValue(sample.lastIndexOf(42n, obj), 0, "object [0]");
+ assert.sameValue(sample.lastIndexOf(43n, obj), 1, "object [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
new file mode 100644
index 0000000000..d950512ac3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17.
+
+ When the lastIndexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1.
+ If n is -∞, return -1F.
+ If n ≥ 0, then
+ Let k be min(n, len - 1).
+ Else,
+ Let k be len + n.
+ Repeat, while k ≥ 0,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k - 1.
+ Return -1F.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.lastIndexOf(undefined, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
new file mode 100644
index 0000000000..6d4460d294
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Returns -1 if buffer is detached after ValidateTypedArray
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ The interpretation and use of the arguments of %TypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17.
+
+ When the lastIndexOf method is called with one or two arguments, the following steps are taken:
+
+ Let O be the this value.
+ Perform ? ValidateTypedArray(O).
+ Let len be O.[[ArrayLength]].
+ If len is 0, return -1F.
+ If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1.
+ If n is -∞, return -1F.
+ If n ≥ 0, then
+ Let k be min(n, len - 1).
+ Else,
+ Let k be len + n.
+ Repeat, while k ≥ 0,
+ Let kPresent be ! HasProperty(O, ! ToString(F(k))).
+ If kPresent is true, then
+ Let elementK be ! Get(O, ! ToString(F(k))).
+ Let same be the result of performing Strict Equality Comparison searchElement === elementK.
+ If same is true, return F(k).
+ Set k to k - 1.
+ Return -1F.
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ const sample = new TA(1);
+ const fromIndex = {
+ valueOf() {
+ $DETACHBUFFER(sample.buffer);
+ return 0;
+ }
+ };
+
+ assert.sameValue(sample.lastIndexOf(0, fromIndex), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js
new file mode 100644
index 0000000000..65a6620143
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.lastIndexOf(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js
new file mode 100644
index 0000000000..0ed0db309b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: handle Infinity values for fromIndex
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ 6. Else n < 0,
+ a. Let k be len + n.
+ 7. Repeat, while k ≥ 0
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 43, 41]);
+
+ assert.sameValue(sample.lastIndexOf(43, Infinity), 2, "lastIndexOf(43, Infinity)");
+ assert.sameValue(sample.lastIndexOf(43, -Infinity), -1, "lastIndexOf(43, -Infinity)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..8a7658c44c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: -0 fromIndex becomes 0
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.lastIndexOf(42, -0), 0, "-0 [0]");
+ assert.sameValue(sample.lastIndexOf(43, -0), -1, "-0 [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..3c20d9e937
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+Object.defineProperty(TypedArray.prototype, "length", {value: 0});
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7]);
+
+ Object.defineProperty(TA.prototype, "length", {value: 0});
+ Object.defineProperty(sample, "length", {value: 0});
+
+ assert.sameValue(sample.lastIndexOf(7), 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js
new file mode 100644
index 0000000000..d5808cc179
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.16 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var lastIndexOf = TypedArray.prototype.lastIndexOf;
+
+assert.sameValue(typeof lastIndexOf, 'function');
+
+assert.throws(TypeError, function() {
+ lastIndexOf();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js
new file mode 100644
index 0000000000..a79f2a2de6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.16 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.lastIndexOf, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.lastIndexOf();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js
new file mode 100644
index 0000000000..722e7cb618
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Returns -1 if length is 0
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ 3. If len is 0, return -1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.lastIndexOf(0), -1, "returns -1");
+ assert.sameValue(
+ sample.lastIndexOf(0, fromIndex), -1,
+ "length is checked before ToInteger(fromIndex)"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js
new file mode 100644
index 0000000000..4361948ea9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: >
+ %TypedArray%.prototype.lastIndexOf.length is 1.
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.lastIndexOf.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.lastIndexOf, "length");
+verifyNotWritable(TypedArray.prototype.lastIndexOf, "length");
+verifyConfigurable(TypedArray.prototype.lastIndexOf, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js
new file mode 100644
index 0000000000..392c531592
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: >
+ %TypedArray%.prototype.lastIndexOf.name is "lastIndexOf".
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.lastIndexOf.name, "lastIndexOf");
+
+verifyNotEnumerable(TypedArray.prototype.lastIndexOf, "name");
+verifyNotWritable(TypedArray.prototype.lastIndexOf, "name");
+verifyConfigurable(TypedArray.prototype.lastIndexOf, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js
new file mode 100644
index 0000000000..850f393c60
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/no-arg.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: >
+ If `searchElement` is not supplied, -1 is returned.
+info: |
+ %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements
+ the same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.17
+ except that the this value's [[ArrayLength]] internal slot is accessed
+ in place of performing a [[Get]] of "length".
+
+ Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ [...]
+ 8. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.lastIndexOf(), -1);
+
+ var ta2 = new TA([0, 1, 2]);
+ assert.sameValue(ta2.lastIndexOf(), -1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js
new file mode 100644
index 0000000000..7bd22e16b3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.lastIndexOf does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.lastIndexOf),
+ false,
+ 'isConstructor(TypedArray.prototype.lastIndexOf) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.lastIndexOf();
+}, '`let u8 = new Uint8Array(1); new u8.lastIndexOf()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js
new file mode 100644
index 0000000000..50422e3001
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: >
+ "lastIndexOf" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'lastIndexOf');
+verifyWritable(TypedArrayPrototype, 'lastIndexOf');
+verifyConfigurable(TypedArrayPrototype, 'lastIndexOf');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..819cd1d16e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.lastIndexOf,
+ 'function',
+ 'implements TypedArray.prototype.lastIndexOf'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.lastIndexOf(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.lastIndexOf(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the lastIndexOf operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.lastIndexOf(0);
+ throw new Test262Error('lastIndexOf completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..f5a7b107dc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let
+ n be len-1.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var fromIndex = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.lastIndexOf(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..621460a5b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return abrupt from ToInteger(fromIndex)
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let
+ n be len-1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(Test262Error, function() {
+ sample.lastIndexOf(7, fromIndex);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js
new file mode 100644
index 0000000000..439473494a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: returns index for the first found element
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ 6. Else n < 0,
+ a. Let k be len + n.
+ 7. Repeat, while k ≥ 0
+ a. Let kPresent be ? HasProperty(O, ! ToString(k)).
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.lastIndexOf(42), 2, "lastIndexOf(42)");
+ assert.sameValue(sample.lastIndexOf(43), 1, "lastIndexOf(43)");
+ assert.sameValue(sample.lastIndexOf(41), 3, "lastIndexOf(41)");
+ assert.sameValue(sample.lastIndexOf(41, 3), 3, "lastIndexOf(41, 3)");
+ assert.sameValue(sample.lastIndexOf(41, 4), 3, "lastIndexOf(41, 4)");
+ assert.sameValue(sample.lastIndexOf(43, 1), 1, "lastIndexOf(43, 1)");
+ assert.sameValue(sample.lastIndexOf(43, 2), 1, "lastIndexOf(43, 2)");
+ assert.sameValue(sample.lastIndexOf(43, 3), 1, "lastIndexOf(43, 3)");
+ assert.sameValue(sample.lastIndexOf(43, 4), 1, "lastIndexOf(43, 4)");
+ assert.sameValue(sample.lastIndexOf(42, 0), 0, "lastIndexOf(42, 0)");
+ assert.sameValue(sample.lastIndexOf(42, 1), 0, "lastIndexOf(42, 1)");
+ assert.sameValue(sample.lastIndexOf(42, 2), 2, "lastIndexOf(42, 2)");
+ assert.sameValue(sample.lastIndexOf(42, 3), 2, "lastIndexOf(42, 3)");
+ assert.sameValue(sample.lastIndexOf(42, 4), 2, "lastIndexOf(42, 4)");
+ assert.sameValue(sample.lastIndexOf(42, -4), 0, "lastIndexOf(42, -4)");
+ assert.sameValue(sample.lastIndexOf(42, -3), 0, "lastIndexOf(42, -3)");
+ assert.sameValue(sample.lastIndexOf(42, -2), 2, "lastIndexOf(42, -2)");
+ assert.sameValue(sample.lastIndexOf(42, -1), 2, "lastIndexOf(42, -1)");
+ assert.sameValue(sample.lastIndexOf(43, -3), 1, "lastIndexOf(43, -3)");
+ assert.sameValue(sample.lastIndexOf(43, -2), 1, "lastIndexOf(43, -2)");
+ assert.sameValue(sample.lastIndexOf(43, -1), 1, "lastIndexOf(43, -1)");
+ assert.sameValue(sample.lastIndexOf(41, -1), 3, "lastIndexOf(41, -1)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js
new file mode 100644
index 0000000000..ea611e2f89
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: returns -1 if the element if not found
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. If n is -0, let k be +0; else let k be min(n, len - 1).
+ 6. Else n < 0,
+ a. Let k be len + n.
+ 7. Repeat, while k ≥ 0
+ ...
+ 8. Return -1.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43, 42, 41]);
+ assert.sameValue(sample.lastIndexOf(44), -1, "lastIndexOf(44)");
+ assert.sameValue(sample.lastIndexOf(44, -4), -1, "lastIndexOf(44, -4)");
+ assert.sameValue(sample.lastIndexOf(44, -5), -1, "lastIndexOf(44, -5)");
+ assert.sameValue(sample.lastIndexOf(42, -5), -1, "lastIndexOf(42, -5)");
+ assert.sameValue(sample.lastIndexOf(43, -4), -1, "lastIndexOf(43, -4)");
+ assert.sameValue(sample.lastIndexOf(43, -5), -1, "lastIndexOf(43, -5)");
+ assert.sameValue(sample.lastIndexOf(41, 0), -1, "lastIndexOf(41, 0)");
+ assert.sameValue(sample.lastIndexOf(41, 1), -1, "lastIndexOf(41, 1)");
+ assert.sameValue(sample.lastIndexOf(41, 2), -1, "lastIndexOf(41, 2)");
+ assert.sameValue(sample.lastIndexOf(43, 0), -1, "lastIndexOf(43, 0)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js
new file mode 100644
index 0000000000..09c3da772d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/strict-comparison.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: search element is compared using strict comparing (===)
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 7. Repeat, while k ≥ 0
+ ...
+ b. If kPresent is true, then
+ i. Let elementK be ? Get(O, ! ToString(k)).
+ ii. Let same be the result of performing Strict Equality Comparison
+ searchElement === elementK.
+ iii. If same is true, return k.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, undefined, NaN, 0, 1]);
+ assert.sameValue(sample.lastIndexOf("42"), -1, "'42'");
+ assert.sameValue(sample.lastIndexOf([42]), -1, "[42]");
+ assert.sameValue(sample.lastIndexOf(42.0), 0, "42.0");
+ assert.sameValue(sample.lastIndexOf(-0), 3, "-0");
+ assert.sameValue(sample.lastIndexOf(true), -1, "true");
+ assert.sameValue(sample.lastIndexOf(false), -1, "false");
+ assert.sameValue(sample.lastIndexOf(NaN), -1, "NaN === NaN is false");
+ assert.sameValue(sample.lastIndexOf(null), -1, "null");
+ assert.sameValue(sample.lastIndexOf(undefined), -1, "undefined");
+ assert.sameValue(sample.lastIndexOf(""), -1, "empty string");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js
new file mode 100644
index 0000000000..b393b8925d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var lastIndexOf = TypedArray.prototype.lastIndexOf;
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call(undefined, 42);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call(null, 42);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call(42, 42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call("1", 42);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call(true, 42);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call(false, 42);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ lastIndexOf.call(s, 42);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..2972430535
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var lastIndexOf = TypedArray.prototype.lastIndexOf;
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call({}, 42);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ lastIndexOf.call([], 42);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ lastIndexOf.call(ab, 42);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ lastIndexOf.call(dv, 42);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js
new file mode 100644
index 0000000000..77465b511e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.lastindexof
+description: Return -1 if fromIndex >= ArrayLength - converted values
+info: |
+ 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ %TypedArray%.prototype.lastIndexOf is a distinct function that implements the
+ same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
+
+ ...
+ 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let
+ n be len-1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([42, 43]);
+ assert.sameValue(sample.lastIndexOf(42, "1"), 0, "string [0]");
+ assert.sameValue(sample.lastIndexOf(43, "1"), 1, "string [1]");
+
+ assert.sameValue(sample.lastIndexOf(42, true), 0, "true [0]");
+ assert.sameValue(sample.lastIndexOf(43, true), 1, "true [1]");
+
+ assert.sameValue(sample.lastIndexOf(42, false), 0, "false [0]");
+ assert.sameValue(sample.lastIndexOf(43, false), -1, "false [1]");
+
+ assert.sameValue(sample.lastIndexOf(42, NaN), 0, "NaN [0]");
+ assert.sameValue(sample.lastIndexOf(43, NaN), -1, "NaN [1]");
+
+ assert.sameValue(sample.lastIndexOf(42, null), 0, "null [0]");
+ assert.sameValue(sample.lastIndexOf(43, null), -1, "null [1]");
+
+ assert.sameValue(sample.lastIndexOf(42, undefined), 0, "undefined [0]");
+ assert.sameValue(sample.lastIndexOf(43, undefined), -1, "undefined [1]");
+
+ assert.sameValue(sample.lastIndexOf(42, null), 0, "null [0]");
+ assert.sameValue(sample.lastIndexOf(43, null), -1, "null [1]");
+
+ assert.sameValue(sample.lastIndexOf(42, obj), 0, "object [0]");
+ assert.sameValue(sample.lastIndexOf(43, obj), 1, "object [1]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..7b2a54ab7f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: Returns 0 if the instance has a detached buffer
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ ...
+ 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 6. If IsDetachedBuffer(buffer) is true, return 0.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.length, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js
new file mode 100644
index 0000000000..54aa11b805
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js
@@ -0,0 +1,56 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the dynamically-sized TypedArray instance
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE);
+ var expected = 3;
+
+ assert.sameValue(array.length, expected, "initial value");
+
+ try {
+ ab.resize(BPE * 5);
+ expected = 4;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ expected = 2;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following shrink (within bounds)");
+
+ try {
+ ab.resize(BPE);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following shrink (on boundary)");
+
+ try {
+ ab.resize(0);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js
new file mode 100644
index 0000000000..0aada8a10b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js
@@ -0,0 +1,49 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the fixed-sized TypedArray instance
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ assert.sameValue(array.length, 2, "initial value");
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.length, 2, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.length, 2, "following shrink (within bounds)");
+
+ var expected;
+ try {
+ ab.resize(BPE * 2);
+ expected = 0;
+ } catch (_) {
+ expected = 2;
+ }
+
+ assert.sameValue(array.length, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/return-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/return-length.js
new file mode 100644
index 0000000000..23ef34454f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/return-length.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ Return value from the [[ArrayLength]] internal slot
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ ...
+ 6. Let length be the value of O's [[ArrayLength]] internal slot.
+ 7. Return length.
+
+ ---
+
+ The current tests on `prop-desc.js` and `length.js` already assert `length` is
+ not a dynamic property as in regular arrays.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.length, 0);
+
+ var ta2 = new TA(42);
+ assert.sameValue(ta2.length, 42);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js
new file mode 100644
index 0000000000..4f34f05a30
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/detached-buffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: Returns 0 if the instance has a detached buffer
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ ...
+ 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 6. If IsDetachedBuffer(buffer) is true, return 0.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+ $DETACHBUFFER(sample.buffer);
+ assert.sameValue(sample.length, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js
new file mode 100644
index 0000000000..b1856a3872
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-accessor.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ Requires this value to have a [[ViewedArrayBuffer]] internal slot
+info: |
+ 22.2.3.17 get %TypedArray%.prototype.length
+
+ 1. Let O be the this value.
+ ...
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.length;
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js
new file mode 100644
index 0000000000..73bfed75a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/invoked-as-func.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.17 get %TypedArray%.prototype.length
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, 'length'
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js
new file mode 100644
index 0000000000..bb6d86ba78
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ get %TypedArray%.prototype.length.length is 0.
+info: |
+ get %TypedArray%.prototype.length
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js
new file mode 100644
index 0000000000..d5ff3cfc37
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/name.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ get %TypedArray%.prototype.length.name is "get length".
+info: |
+ get %TypedArray%.prototype.length
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length");
+
+assert.sameValue(desc.get.name, "get length");
+
+verifyNotEnumerable(desc.get, "name");
+verifyNotWritable(desc.get, "name");
+verifyConfigurable(desc.get, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js
new file mode 100644
index 0000000000..4dd62e29bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/prop-desc.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ "length" property of TypedArrayPrototype
+info: |
+ %TypedArray%.prototype.length is an accessor property whose set accessor
+ function is undefined.
+
+ Section 17: Every accessor property described in clauses 18 through 26 and in
+ Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true }
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "length");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(TypedArrayPrototype, "length");
+verifyConfigurable(TypedArrayPrototype, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js
new file mode 100644
index 0000000000..919ea0da40
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-auto.js
@@ -0,0 +1,56 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the dynamically-sized TypedArray instance
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE);
+ var expected = 3;
+
+ assert.sameValue(array.length, expected, "initial value");
+
+ try {
+ ab.resize(BPE * 5);
+ expected = 4;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ expected = 2;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following shrink (within bounds)");
+
+ try {
+ ab.resize(BPE);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following shrink (on boundary)");
+
+ try {
+ ab.resize(0);
+ expected = 0;
+ } catch (_) {}
+
+ assert.sameValue(array.length, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js
new file mode 100644
index 0000000000..ebb2f32bbf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/resizable-array-buffer-fixed.js
@@ -0,0 +1,49 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: |
+ reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of
+ the fixed-sized TypedArray instance
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, "function");
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ assert.sameValue(array.length, 2, "initial value");
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ assert.sameValue(array.length, 2, "following grow");
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ assert.sameValue(array.length, 2, "following shrink (within bounds)");
+
+ var expected;
+ try {
+ ab.resize(BPE * 2);
+ expected = 0;
+ } catch (_) {
+ expected = 2;
+ }
+
+ assert.sameValue(array.length, expected, "following shrink (out of bounds)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js
new file mode 100644
index 0000000000..56c987fdf3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/return-length.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ Return value from the [[ArrayLength]] internal slot
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ ...
+ 6. Let length be the value of O's [[ArrayLength]] internal slot.
+ 7. Return length.
+
+ ---
+
+ The current tests on `prop-desc.js` and `length.js` already assert `length` is
+ not a dynamic property as in regular arrays.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta1 = new TA();
+ assert.sameValue(ta1.length, 0);
+
+ var ta2 = new TA(42);
+ assert.sameValue(ta2.length, 42);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js
new file mode 100644
index 0000000000..25effb5786
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: >
+ Throws a TypeError exception when `this` does not have a [[TypedArrayName]]
+ internal slot
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [DataView, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "length"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+});
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+});
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+});
+
+var dv = new DataView(new ArrayBuffer(8), 0);
+assert.throws(TypeError, function() {
+ getter.call(dv);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js
new file mode 100644
index 0000000000..56d3e96207
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/length/this-is-not-object.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%typedarray%.prototype.length
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.18 get %TypedArray%.prototype.length
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+var getter = Object.getOwnPropertyDescriptor(
+ TypedArrayPrototype, "length"
+).get;
+
+
+assert.throws(TypeError, function() {
+ getter.call(undefined);
+}, "undefined");
+
+assert.throws(TypeError, function() {
+ getter.call(null);
+}, "null");
+
+assert.throws(TypeError, function() {
+ getter.call(42);
+}, "number");
+
+assert.throws(TypeError, function() {
+ getter.call("1");
+}, "string");
+
+assert.throws(TypeError, function() {
+ getter.call(true);
+}, "true");
+
+assert.throws(TypeError, function() {
+ getter.call(false);
+}, "false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ getter.call(s);
+}, "symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js
new file mode 100644
index 0000000000..e038d8da60
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/arraylength-internal.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ [[ArrayLength]] is accessed in place of performing a [[Get]] of "length"
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. Let len be the value of O's [[ArrayLength]] internal slot.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(42);
+ var loop = 0;
+
+ Object.defineProperty(sample1, "length", {value: 1});
+
+ sample1.map(function() {
+ loop++;
+ return 0n;
+ });
+ assert.sameValue(loop, 42, "data descriptor");
+
+ loop = 0;
+ var sample2 = new TA(4);
+ Object.defineProperty(sample2, "length", {
+ get: function() {
+ throw new Test262Error(
+ "Does not return abrupt getting length property"
+ );
+ }
+ });
+
+ sample2.map(function() {
+ loop++;
+ return 0n;
+ });
+ assert.sameValue(loop, 4, "accessor descriptor");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..136bace8bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.map(function() {
+ results.push(arguments);
+ return 0n;
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..8d29b81a90
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.map(function() {
+ results.push(arguments);
+ return 0n;
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..a21476ea34
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.map(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js
new file mode 100644
index 0000000000..8a8f22473d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn is not callable
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(TypeError, function() {
+ sample.map();
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(undefined);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(null);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map({});
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(1);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map("");
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(false);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js
new file mode 100644
index 0000000000..814b2dd35c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.map(function() {
+ results.push(arguments);
+ return 0n;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+
+ assert.sameValue(results[0][0], 7n, "results[0][0] - kValue");
+ assert.sameValue(results[1][0], 8n, "results[1][0] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..8405822991
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().map(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js
new file mode 100644
index 0000000000..0f8fcf65ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ The callbackfn returned values are applied to the new instance
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ d. Perform ? Set(A, Pk, mappedValue, true).
+ ...
+ 9. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 2n, 4n]);
+ var result = sample.map(function(v) {
+ return v * 3n;
+ });
+
+ assert.sameValue(result[0], 3n, "result[0] == 3");
+ assert.sameValue(result[1], 6n, "result[1] == 6");
+ assert.sameValue(result[2], 12n, "result[2] == 12");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..9405e276f3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ The callbackfn return does not change the `this` instance
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(3);
+
+ sample1[1] = 1n;
+
+ sample1.map(function() {
+ return 42n;
+ });
+
+ assert.sameValue(sample1[0], 0n, "[0] == 0");
+ assert.sameValue(sample1[1], 1n, "[1] == 1");
+ assert.sameValue(sample1[2], 0n, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js
new file mode 100644
index 0000000000..3518e390b0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Does not copy non-integer properties to returned value
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+ var bar = Symbol("1");
+
+ sample.foo = 42;
+ sample[bar] = 1;
+
+ var result = sample.map(function() {
+ return 0n;
+ });
+
+ assert.sameValue(result.length, 2, "result.length");
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(result, "foo"),
+ undefined,
+ "foo"
+ );
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(result, bar),
+ undefined,
+ "bar"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..880d124eb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.map(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..55849c02da
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.map(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7n),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ return 0n;
+ });
+
+ assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..c8aeffaa22
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/callbackfn-this.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.map(function() {
+ results1.push(this);
+ return 0n;
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.map(function() {
+ results2.push(this);
+ return 0n;
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..d26dc3485b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..5ccc7ca1b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.map,
+ 'function',
+ 'implements TypedArray.prototype.map'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.map(() => 0n);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.map(() => 0n);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the map operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.map(() => 0n);
+ throw new Test262Error('map completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js
new file mode 100644
index 0000000000..6b09264a29
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns a new typedArray instance from the same constructor with the same
+ length and a new buffer object - testing on an instance with length == 0
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+ 9. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(0);
+
+ var result = sample.map(function() {});
+
+ assert.notSameValue(result, sample, "new typedArray object");
+ assert.sameValue(result.constructor, TA, "same constructor");
+ assert(result instanceof TA, "result is an instance of " + TA.name);
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "result has the same prototype of sample"
+ );
+ assert.sameValue(result.length, 0, "same length");
+ assert.notSameValue(result.buffer, sample.buffer, "new buffer");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js
new file mode 100644
index 0000000000..712241641a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns a new typedArray instance from the same constructor with the same
+ length and a new buffer object - testing on an instance with length > 0
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+ 9. Return A.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var result = sample.map(function(v) {
+ return v;
+ });
+
+ assert.notSameValue(result, sample, "new typedArray object");
+ assert.sameValue(result.constructor, sample.constructor, "same constructor");
+ assert.sameValue(result.length, 3, "same length");
+ assert.notSameValue(result.buffer, sample.buffer, "new buffer");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..d0a8044e66
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var callCount = 0;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.map(function() {
+ callCount++;
+ });
+ });
+ assert.sameValue(callCount, 0, "callback should not be called");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..cc3b73e3f8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,66 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.map(function() {
+ return 0n;
+ });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..f7a6a54e72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var callbackfn = function() { return 0n; };
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..6bbfca9989
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.map(function() { return 0n; });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..dc36b88037
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.map(function() { return 0n; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..8e1fc1b005
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 42n, 42n]);
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(count);
+ };
+
+ sample.map(function(v) { return v === 42n; });
+
+ assert.sameValue(result.length, 1, "called with 1 argument");
+ assert.sameValue(result[0], 3, "[0] is the length");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 0000000000..127a1142fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Throws a TypeError if new typedArray's length < len
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA();
+ };
+
+ assert.throws(TypeError, function() {
+ sample.map(function() { return 0; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 0000000000..0e9e7a3fd7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Does not throw a TypeError if new typedArray's length >= len
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var customCount, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA(customCount);
+ };
+
+ customCount = 2;
+ result = sample.map(function() { return 0n; });
+ assert.sameValue(result.length, customCount, "length == count");
+
+ customCount = 5;
+ result = sample.map(function() { return 0n; });
+ assert.sameValue(result.length, customCount, "length > count");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..82fa940644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Custom @@species constructor may return a different TypedArray
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n]);
+ var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ var other = new otherTA([1n, 0n, 1n]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.map(function(a) { return a + 7n; });
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [47n, 0n, 1n]), "values are set on returned typedarray");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..f56a8374a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = Array;
+
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..25cd7e12b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var calls = 0;
+ var other, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(len) {
+ calls++;
+ other = new TA(len);
+ return other;
+ };
+
+ result = sample.map(function(a) { return a + 7n; });
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert.sameValue(result, other, "return is instance of custom constructor");
+ assert(compareArray(result, [47n, 48n, 49n]), "values are set on the new obj");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..6431d37d25
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..5943e9b850
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.map(function() { return 0n; });
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.map(function() { return 0n; });
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js
new file mode 100644
index 0000000000..30431bbf6a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.map(function() { return 0n; });
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..73b72e7e3d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/BigInt/values-are-not-cached.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.map(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+
+ return 0n;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js
new file mode 100644
index 0000000000..4d50955331
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/arraylength-internal.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ [[ArrayLength]] is accessed in place of performing a [[Get]] of "length"
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. Let len be the value of O's [[ArrayLength]] internal slot.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(42);
+ var loop = 0;
+
+ Object.defineProperty(sample1, "length", {value: 1});
+
+ sample1.map(function() {
+ loop++;
+ return 0;
+ });
+ assert.sameValue(loop, 42, "data descriptor");
+
+ loop = 0;
+ var sample2 = new TA(4);
+ Object.defineProperty(sample2, "length", {
+ get: function() {
+ throw new Test262Error(
+ "Does not return abrupt getting length property"
+ );
+ }
+ });
+
+ sample2.map(function() {
+ loop++;
+ return 0;
+ });
+ assert.sameValue(loop, 4, "accessor descriptor");
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..dd2f599d91
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.map(function() {
+ results.push(arguments);
+ return 0;
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..14e593c926
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.map(function() {
+ results.push(arguments);
+ return 0;
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..cead041854
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-detachbuffer.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.map(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js
new file mode 100644
index 0000000000..c6ca42907e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-is-not-callable.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn is not callable
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(TypeError, function() {
+ sample.map();
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(undefined);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(null);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map({});
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(1);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map("");
+ });
+
+ assert.throws(TypeError, function() {
+ sample.map(false);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js
new file mode 100644
index 0000000000..4bbceeac78
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.map(function() {
+ results.push(arguments);
+ return 0;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+
+ assert.sameValue(results[0][0], 7, "results[0][0] - kValue");
+ assert.sameValue(results[1][0], 8, "results[1][0] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..d2c14b4635
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().map(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js
new file mode 100644
index 0000000000..9d3ba7229a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-resize.js
@@ -0,0 +1,79 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var NaNvalue = (TA === Float32Array || TA === Float64Array) ? NaN : 0;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.map(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+
+ return index;
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.compareArray(result, [0, 1, 2], 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.map(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+
+ return index;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.compareArray(result, expectedIndices, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js
new file mode 100644
index 0000000000..8627c187a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ The callbackfn returned values are applied to the new instance
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ d. Perform ? Set(A, Pk, mappedValue, true).
+ ...
+ 9. Return A.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 4]);
+ var result = sample.map(function(v) {
+ return v * 3;
+ });
+
+ assert.sameValue(result[0], 3, "result[0] == 3");
+ assert.sameValue(result[1], 6, "result[1] == 6");
+ assert.sameValue(result[2], 12, "result[2] == 12");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..a386d40389
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ The callbackfn return does not change the `this` instance
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample1 = new TA(3);
+
+ sample1[1] = 1;
+
+ sample1.map(function() {
+ return 42;
+ });
+
+ assert.sameValue(sample1[0], 0, "[0] == 0");
+ assert.sameValue(sample1[1], 1, "[1] == 1");
+ assert.sameValue(sample1[2], 0, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js
new file mode 100644
index 0000000000..228d5fca0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Does not copy non-integer properties to returned value
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ a. Let Pk be ! ToString(k).
+ b. Let kValue be ? Get(O, Pk).
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+ var bar = Symbol("1");
+
+ sample.foo = 42;
+ sample[bar] = 1;
+
+ var result = sample.map(function() {
+ return 0;
+ });
+
+ assert.sameValue(result.length, 2, "result.length");
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(result, "foo"),
+ undefined,
+ "foo"
+ );
+ assert.sameValue(
+ Object.getOwnPropertyDescriptor(result, bar),
+ undefined,
+ "bar"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..1849feee03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-returns-abrupt.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.map(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..3367d09ed7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.map(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ return 0;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js
new file mode 100644
index 0000000000..f32ca0efa0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/callbackfn-this.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.map(function() {
+ results1.push(this);
+ return 0;
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.map(function() {
+ results2.push(this);
+ return 0;
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js
new file mode 100644
index 0000000000..91ae25122b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js
new file mode 100644
index 0000000000..390cc0f907
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.18 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var map = TypedArray.prototype.map;
+
+assert.sameValue(typeof map, 'function');
+
+assert.throws(TypeError, function() {
+ map();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js
new file mode 100644
index 0000000000..412ec13842
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.18 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.map, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.map();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js
new file mode 100644
index 0000000000..005f678a2a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ %TypedArray%.prototype.map.length is 1.
+info: |
+ %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.map.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.map, "length");
+verifyNotWritable(TypedArray.prototype.map, "length");
+verifyConfigurable(TypedArray.prototype.map, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js
new file mode 100644
index 0000000000..318e83fc91
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ %TypedArray%.prototype.map.name is "map".
+info: |
+ %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.map.name, "map");
+
+verifyNotEnumerable(TypedArray.prototype.map, "name");
+verifyNotWritable(TypedArray.prototype.map, "name");
+verifyConfigurable(TypedArray.prototype.map, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js
new file mode 100644
index 0000000000..c4f000f14d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.map does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.map),
+ false,
+ 'isConstructor(TypedArray.prototype.map) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.map(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.map(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js
new file mode 100644
index 0000000000..4aff20321f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ "map" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'map');
+verifyWritable(TypedArrayPrototype, 'map');
+verifyConfigurable(TypedArrayPrototype, 'map');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..266cbd5320
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.map,
+ 'function',
+ 'implements TypedArray.prototype.map'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.map(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.map(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the map operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.map(() => {});
+ throw new Test262Error('map completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js
new file mode 100644
index 0000000000..ae26889ad9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js
@@ -0,0 +1,73 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Consistent canonicalization of NaN values
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ d. Perform ? Set(A, Pk, mappedValue, true).
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ ...
+ 8. If type is "Float32", then
+ a. Set rawBytes to a List containing the 4 bytes that are the result
+ of converting value to IEEE 754-2008 binary32 format using “Round to
+ nearest, ties to even” rounding mode. If isLittleEndian is false, the
+ bytes are arranged in big endian order. Otherwise, the bytes are
+ arranged in little endian order. If value is NaN, rawValue may be set
+ to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number
+ encoding. An implementation must always choose the same encoding for
+ each implementation distinguishable NaN value.
+ 9. Else, if type is "Float64", then
+ a. Set rawBytes to a List containing the 8 bytes that are the IEEE
+ 754-2008 binary64 format encoding of value. If isLittleEndian is false,
+ the bytes are arranged in big endian order. Otherwise, the bytes are
+ arranged in little endian order. If value is NaN, rawValue may be set
+ to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number
+ encoding. An implementation must always choose the same encoding for
+ each implementation distinguishable NaN value.
+ ...
+includes: [nans.js, testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+function body(FloatArray) {
+ var sample = new FloatArray(NaNs);
+ var sampleBytes, resultBytes;
+ var i = 0;
+
+ var result = sample.map(function() {
+ return NaNs[i++];
+ });
+
+ sampleBytes = new Uint8Array(sample.buffer);
+ resultBytes = new Uint8Array(result.buffer);
+
+ assert(compareArray(sampleBytes, resultBytes));
+}
+
+testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js
new file mode 100644
index 0000000000..95607e6bf6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Verify conversion values on returned instance
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ d. Perform ? Set(A, Pk, mappedValue, true).
+ ...
+
+ IntegerIndexedElementSet ( O, index, value )
+
+ Assert: O is an Integer-Indexed exotic object.
+ If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
+ Otherwise, let numValue be ? ToNumber(value).
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then
+ Let offset be O.[[ByteOffset]].
+ Let arrayTypeName be the String value of O.[[TypedArrayName]].
+ Let elementSize be the Element Size value specified in Table 62 for arrayTypeName.
+ Let indexedPosition be (ℝ(index) × elementSize) + offset.
+ Let elementType be the Element Type value in Table 62 for arrayTypeName.
+ Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered).
+ Return NormalCompletion(undefined).
+
+ 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ ,
+ isLittleEndian ] )
+
+ ...
+ 8. If type is "Float32", then
+ ...
+ 9. Else, if type is "Float64", then
+ ...
+ 10. Else,
+ ...
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 50 for Element Type type.
+ c. Let intValue be convOp(value).
+ d. If intValue ≥ 0, then
+ ...
+ e. Else,
+ ...
+includes: [byteConversionValues.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
+ var sample = new TA([initial]);
+
+ var result = sample.map(function() {
+ return value;
+ });
+
+ assert.sameValue(result[0], expected, value + " converts to " + expected);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js
new file mode 100644
index 0000000000..caf14ee0e7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns a new typedArray instance from the same constructor with the same
+ length and a new buffer object - testing on an instance with length == 0
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+ 9. Return A.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(0);
+
+ var result = sample.map(function() {});
+
+ assert.notSameValue(result, sample, "new typedArray object");
+ assert.sameValue(result.constructor, TA, "same constructor");
+ assert(result instanceof TA, "result is an instance of " + TA.name);
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "result has the same prototype of sample"
+ );
+ assert.sameValue(result.length, 0, "same length");
+ assert.notSameValue(result.buffer, sample.buffer, "new buffer");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js
new file mode 100644
index 0000000000..781e95ed79
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns a new typedArray instance from the same constructor with the same
+ length and a new buffer object - testing on an instance with length > 0
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ 7. Let k be 0.
+ 8. Repeat, while k < len
+ ...
+ c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »).
+ ...
+ 9. Return A.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var result = sample.map(function(v) {
+ return v;
+ });
+
+ assert.notSameValue(result, sample, "new typedArray object");
+ assert.sameValue(result.constructor, sample.constructor, "same constructor");
+ assert.sameValue(result.length, 3, "same length");
+ assert.notSameValue(result.buffer, sample.buffer, "new buffer");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..8cb024e74f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var callCount = 0;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.map(function() {
+ callCount++;
+ });
+ });
+ assert.sameValue(callCount, 0, "callback should not be called");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..69461a29bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,66 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.map(function() {
+ return 0;
+ });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..5f2498a20b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var callbackfn = function() { return 0; };
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.map(callbackfn);
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..867e80d95e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.map(function() { return 0; });
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..e13dc1fa89
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.map(function() { return 0; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..31f2b4e2c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 42, 42]);
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(count);
+ };
+
+ sample.map(function(v) { return v === 42; });
+
+ assert.sameValue(result.length, 1, "called with 1 argument");
+ assert.sameValue(result[0], 3, "[0] is the length");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 0000000000..cfee782837
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Throws a TypeError if new typedArray's length < len
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA();
+ };
+
+ assert.throws(TypeError, function() {
+ sample.map(function() { return 0; });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 0000000000..adaf755194
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Does not throw a TypeError if new typedArray's length >= len
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var customCount, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA(customCount);
+ };
+
+ customCount = 2;
+ result = sample.map(function() { return 0; });
+ assert.sameValue(result.length, customCount, "length == count");
+
+ customCount = 5;
+ result = sample.map(function() { return 0; });
+ assert.sameValue(result.length, customCount, "length > count");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..5891ee6291
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Custom @@species constructor may return a different TypedArray
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40]);
+ var otherTA = TA === Int8Array ? Int16Array : Int8Array;
+ var other = new otherTA([1, 0, 1]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.map(function(a) { return a + 7; });
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [47, 0, 1]), "values are set on returned typedarray");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..cc914eb35c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = Array;
+
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..cc5cd4a718
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+ var calls = 0;
+ var other, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(len) {
+ calls++;
+ other = new TA(len);
+ return other;
+ };
+
+ result = sample.map(function(a) { return a + 7; });
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert.sameValue(result, other, "return is instance of custom constructor");
+ assert(compareArray(result, [47, 48, 49]), "values are set on the new obj");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..7c2d50f58a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.map(function() {});
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..1f69a5f099
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.map(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.map(function() {});
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js
new file mode 100644
index 0000000000..ebb6be8c28
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/speciesctor-get-species.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2018 Peter Wong. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Let A be ? TypedArraySpeciesCreate(O, « len »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.map(function() {});
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js
new file mode 100644
index 0000000000..5ffe12583d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var map = TypedArray.prototype.map;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ map.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ map.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ map.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ map.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ map.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ map.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ map.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..214354fa23
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var map = TypedArray.prototype.map;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ map.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ map.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ map.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ map.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js
new file mode 100644
index 0000000000..b65af8329f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/map/values-are-not-cached.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.map
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] )
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ sample.map(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+
+ return 0;
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js
new file mode 100644
index 0000000000..762f6896ce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn arguments using custom accumulator
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.reduce(function(accumulator) {
+ results.push(arguments);
+ return accumulator + 1;
+ }, 7);
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[0].length");
+ assert.sameValue(results[0][0], 7, "results[0][0] - accumulator");
+ assert.sameValue(results[0][1], 42n, "results[0][1] - kValue");
+ assert.sameValue(results[0][2], 0, "results[0][2] - k");
+ assert.sameValue(results[0][3], sample, "results[0][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[1].length");
+ assert.sameValue(results[1][0], 8, "results[1][0] - accumulator");
+ assert.sameValue(results[1][1], 43n, "results[1][1] - kValue");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+ assert.sameValue(results[1][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[2].length, 4, "results[2].length");
+ assert.sameValue(results[2][0], 9, "results[2][0] - accumulator");
+ assert.sameValue(results[2][1], 44n, "results[2][1] - kValue");
+ assert.sameValue(results[2][2], 2, "results[2][2] - k");
+ assert.sameValue(results[2][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js
new file mode 100644
index 0000000000..3f37559d74
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn arguments using default accumulator (value at index 0)
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ a. Let kPresent be false.
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.reduce(function(accumulator) {
+ results.push(arguments);
+ return accumulator - 1n;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[1].length");
+ assert.sameValue(results[0][0], 42n, "results[1][0] - accumulator");
+ assert.sameValue(results[0][1], 43n, "results[1][1] - kValue");
+ assert.sameValue(results[0][2], 1, "results[1][2] - k");
+ assert.sameValue(results[0][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[2].length");
+ assert.sameValue(results[1][0], 41n, "results[2][0] - accumulator");
+ assert.sameValue(results[1][1], 44n, "results[2][1] - kValue");
+ assert.sameValue(results[1][2], 2, "results[2][2] - k");
+ assert.sameValue(results[1][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..344e7deaee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.reduce(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ }, 0);
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js
new file mode 100644
index 0000000000..bf9a51b527
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.reduce();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.reduce({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.reduce("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(Symbol(""));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js
new file mode 100644
index 0000000000..7b23880d92
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.reduce(function() {
+ results.push(arguments);
+ }, 0);
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][2], 0, "results[0][2] - k");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+
+ assert.sameValue(results[0][1], 7n, "results[0][1] - kValue");
+ assert.sameValue(results[1][1], 8n, "results[1][1] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..ffc057e473
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().reduce(function() {
+ called++;
+ }, undefined);
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..a59d946ee5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ The callbackfn return does not change the `this` instance
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n, 1n, 0n]);
+
+ sample.reduce(function() {
+ return 42;
+ }, 7);
+
+ assert.sameValue(sample[0], 0n, "[0] == 0");
+ assert.sameValue(sample[1], 1n, "[1] == 1");
+ assert.sameValue(sample[2], 0n, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..fc0f0856eb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(Test262Error, function() {
+ sample.reduce(function() {
+ throw new Test262Error();
+ });
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.reduce(function() {
+ throw new Test262Error();
+ }, 0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js
new file mode 100644
index 0000000000..1d62357347
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.reduce(function(acc, val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7n),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ }, 0);
+
+ assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..901b8ae0d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results = [];
+
+ sample.reduce(function() {
+ results.push(this);
+ }, 0);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(results[0], expected, "[0]");
+ assert.sameValue(results[1], expected, "[1]");
+ assert.sameValue(results[2], expected, "[2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..2fda7511ab
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.reduce(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js
new file mode 100644
index 0000000000..e888cd589d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns given initialValue on empty instances without calling callbackfn
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA().reduce(function() {
+ called = true;
+ }, 42);
+
+ assert.sameValue(result, 42);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js
new file mode 100644
index 0000000000..bbc77b69aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ If len is 0 and initialValue is not present, throw a TypeError exception.
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ assert.throws(TypeError, function() {
+ new TA().reduce(function() {
+ called++;
+ });
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..d10d56a344
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.reduce(function() {
+ calls++;
+ }, 0);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js
new file mode 100644
index 0000000000..efb3026781
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns last accumulator value
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var calls, result;
+
+ calls = 0;
+ result = new TA([1n, 2n, 3n]).reduce(function() {
+ calls++;
+
+ if (calls == 2) {
+ return 42;
+ }
+ });
+ assert.sameValue(result, 42, "using default accumulator");
+
+ calls = 0;
+ result = new TA([1n, 2n, 3n]).reduce(function() {
+ calls++;
+
+ if (calls == 3) {
+ return 7;
+ }
+ }, 0);
+ assert.sameValue(result, 7, "using custom accumulator");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js
new file mode 100644
index 0000000000..911b5f2be8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Result can be of any type without any number conversions
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ [
+ ["test262", "string"],
+ ["", "empty string"],
+ [undefined, "undefined"],
+ [null, "null"],
+ [-0, "-0"],
+ [42, "integer"],
+ [NaN, "NaN"],
+ [Infinity, "Infinity"],
+ [0.6, "float number"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol(""), "symbol"],
+ [{}, "object"]
+ ].forEach(function(item) {
+ var result;
+
+ result = sample.reduce(function() {
+ return item[0];
+ });
+ assert.sameValue(result, item[0], item[1] + " - using default accumulator");
+
+ result = sample.reduce(function() {
+ return item[0];
+ }, 0);
+
+ assert.sameValue(result, item[0], item[1] + " - using custom accumulator");
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..0564ee92a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.reduce,
+ 'function',
+ 'implements TypedArray.prototype.reduce'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.reduce(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.reduce(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reduce operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.reduce(() => {});
+ throw new Test262Error('reduce completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js
new file mode 100644
index 0000000000..7fe9a17a29
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns [0] without calling callbackfn if length is 1 and initialValue is not
+ present.
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA([42n]).reduce(function() {
+ called = true;
+ });
+
+ assert.sameValue(result, 42n);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..919b728856
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.reduce(function(a, v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ }, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js
new file mode 100644
index 0000000000..c94056f7af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn arguments using custom accumulator
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.reduce(function(accumulator) {
+ results.push(arguments);
+ return accumulator + 1;
+ }, 7);
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[0].length");
+ assert.sameValue(results[0][0], 7, "results[0][0] - accumulator");
+ assert.sameValue(results[0][1], 42, "results[0][1] - kValue");
+ assert.sameValue(results[0][2], 0, "results[0][2] - k");
+ assert.sameValue(results[0][3], sample, "results[0][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[1].length");
+ assert.sameValue(results[1][0], 8, "results[1][0] - accumulator");
+ assert.sameValue(results[1][1], 43, "results[1][1] - kValue");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+ assert.sameValue(results[1][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[2].length, 4, "results[2].length");
+ assert.sameValue(results[2][0], 9, "results[2][0] - accumulator");
+ assert.sameValue(results[2][1], 44, "results[2][1] - kValue");
+ assert.sameValue(results[2][2], 2, "results[2][2] - k");
+ assert.sameValue(results[2][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js
new file mode 100644
index 0000000000..da27455283
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn arguments using default accumulator (value at index 0)
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ a. Let kPresent be false.
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.reduce(function(accumulator) {
+ results.push(arguments);
+ return accumulator - 1;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[1].length");
+ assert.sameValue(results[0][0], 42, "results[1][0] - accumulator");
+ assert.sameValue(results[0][1], 43, "results[1][1] - kValue");
+ assert.sameValue(results[0][2], 1, "results[1][2] - k");
+ assert.sameValue(results[0][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[2].length");
+ assert.sameValue(results[1][0], 41, "results[2][0] - accumulator");
+ assert.sameValue(results[1][1], 44, "results[2][1] - kValue");
+ assert.sameValue(results[1][2], 2, "results[2][2] - k");
+ assert.sameValue(results[1][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..a9e4cc7cdc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.reduce(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ }, 0);
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js
new file mode 100644
index 0000000000..b604544757
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.reduce();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.reduce({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.reduce("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.reduce(Symbol(""));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js
new file mode 100644
index 0000000000..d7dca0aa6b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.reduce(function() {
+ results.push(arguments);
+ }, 0);
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][2], 0, "results[0][2] - k");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+
+ assert.sameValue(results[0][1], 7, "results[0][1] - kValue");
+ assert.sameValue(results[1][1], 8, "results[1][1] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..775ccc995b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().reduce(function() {
+ called++;
+ }, undefined);
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js
new file mode 100644
index 0000000000..a10f3adf0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-resize.js
@@ -0,0 +1,78 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3});
+ var sample = new TA(buffer);
+ var finalNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays;
+ var prevs, nexts, indices, arrays, result;
+
+ prevs = [];
+ nexts = [];
+ indices = [];
+ arrays = [];
+ result = sample.reduce(function(prev, next, index, array) {
+ if (prevs.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalNext = undefined;
+ expectedPrevs = [262, 0];
+ expectedNexts = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalNext = 0;
+ expectedPrevs = [262, 0, 1];
+ expectedNexts = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ prevs.push(prev);
+ nexts.push(next);
+ indices.push(index);
+ arrays.push(array);
+ return index;
+ }, 262);
+
+ assert.compareArray(prevs, [262, 0, 1], 'prevs (shrink)');
+ assert.compareArray(nexts, [0, 0, finalNext], 'nexts (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, 2, 'result (shrink)');
+
+ prevs = [];
+ nexts = [];
+ indices = [];
+ arrays = [];
+ result = sample.reduce(function(prev, next, index, array) {
+ if (prevs.length === 0) {
+ try {
+ buffer.resize(3 * BPE);
+ } catch (_) {}
+ }
+
+ prevs.push(prev);
+ nexts.push(next);
+ indices.push(index);
+ arrays.push(array);
+ return index;
+ }, 262);
+
+ assert.compareArray(prevs, expectedPrevs, 'prevs (grow)');
+ assert.compareArray(nexts, expectedNexts, 'nexts (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..6c08f0cb18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ The callbackfn return does not change the `this` instance
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([0, 1, 0]);
+
+ sample.reduce(function() {
+ return 42;
+ }, 7);
+
+ assert.sameValue(sample[0], 0, "[0] == 0");
+ assert.sameValue(sample[1], 1, "[1] == 1");
+ assert.sameValue(sample[2], 0, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..5999871cca
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(Test262Error, function() {
+ sample.reduce(function() {
+ throw new Test262Error();
+ });
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.reduce(function() {
+ throw new Test262Error();
+ }, 0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js
new file mode 100644
index 0000000000..8fd43bad16
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.reduce(function(acc, val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ }, 0);
+
+ assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js
new file mode 100644
index 0000000000..9bec756c34
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/callbackfn-this.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results = [];
+
+ sample.reduce(function() {
+ results.push(this);
+ }, 0);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(results[0], expected, "[0]");
+ assert.sameValue(results[1], expected, "[1]");
+ assert.sameValue(results[2], expected, "[2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js
new file mode 100644
index 0000000000..77ef5a447f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.reduce(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js
new file mode 100644
index 0000000000..49863aad95
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns given initialValue on empty instances without calling callbackfn
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA().reduce(function() {
+ called = true;
+ }, 42);
+
+ assert.sameValue(result, 42);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js
new file mode 100644
index 0000000000..9924f89ae2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ If len is 0 and initialValue is not present, throw a TypeError exception.
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ assert.throws(TypeError, function() {
+ new TA().reduce(function() {
+ called++;
+ });
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..301955fc2d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.reduce(function() {
+ calls++;
+ }, 0);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js
new file mode 100644
index 0000000000..fd0a92b827
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.19 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var reduce = TypedArray.prototype.reduce;
+
+assert.sameValue(typeof reduce, 'function');
+
+assert.throws(TypeError, function() {
+ reduce();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js
new file mode 100644
index 0000000000..cb355bdbbc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.19 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.reduce, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.reduce();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js
new file mode 100644
index 0000000000..8c3e198e11
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ %TypedArray%.prototype.reduce.length is 1.
+info: |
+ %TypedArray%.prototype.reduce ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reduce.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.reduce, "length");
+verifyNotWritable(TypedArray.prototype.reduce, "length");
+verifyConfigurable(TypedArray.prototype.reduce, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js
new file mode 100644
index 0000000000..0daed85804
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ %TypedArray%.prototype.reduce.name is "reduce".
+info: |
+ %TypedArray%.prototype.reduce ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reduce.name, "reduce");
+
+verifyNotEnumerable(TypedArray.prototype.reduce, "name");
+verifyNotWritable(TypedArray.prototype.reduce, "name");
+verifyConfigurable(TypedArray.prototype.reduce, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js
new file mode 100644
index 0000000000..4cc53d856d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.reduce does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.reduce),
+ false,
+ 'isConstructor(TypedArray.prototype.reduce) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.reduce(() => {}, []);
+}, '`let u8 = new Uint8Array(1); new u8.reduce(() => {}, [])` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js
new file mode 100644
index 0000000000..ace3661a03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ "reduce" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'reduce');
+verifyWritable(TypedArrayPrototype, 'reduce');
+verifyConfigurable(TypedArrayPrototype, 'reduce');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js
new file mode 100644
index 0000000000..12b86326a6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns last accumulator value
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var calls, result;
+
+ calls = 0;
+ result = new TA([1, 2, 3]).reduce(function() {
+ calls++;
+
+ if (calls == 2) {
+ return 42;
+ }
+ });
+ assert.sameValue(result, 42, "using default accumulator");
+
+ calls = 0;
+ result = new TA([1, 2, 3]).reduce(function() {
+ calls++;
+
+ if (calls == 3) {
+ return 7;
+ }
+ }, 0);
+ assert.sameValue(result, 7, "using custom accumulator");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js
new file mode 100644
index 0000000000..2950251b61
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/result-of-any-type.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Result can be of any type without any number conversions
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ [
+ ["test262", "string"],
+ ["", "empty string"],
+ [undefined, "undefined"],
+ [null, "null"],
+ [-0, "-0"],
+ [42, "integer"],
+ [NaN, "NaN"],
+ [Infinity, "Infinity"],
+ [0.6, "float number"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol(""), "symbol"],
+ [{}, "object"]
+ ].forEach(function(item) {
+ var result;
+
+ result = sample.reduce(function() {
+ return item[0];
+ });
+ assert.sameValue(result, item[0], item[1] + " - using default accumulator");
+
+ result = sample.reduce(function() {
+ return item[0];
+ }, 0);
+
+ assert.sameValue(result, item[0], item[1] + " - using custom accumulator");
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..5466d1210f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.reduce,
+ 'function',
+ 'implements TypedArray.prototype.reduce'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.reduce(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.reduce(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reduce operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.reduce(() => {});
+ throw new Test262Error('reduce completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js
new file mode 100644
index 0000000000..2b591cfd84
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Returns [0] without calling callbackfn if length is 1 and initialValue is not
+ present.
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k < len
+ ...
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Increase k by 1.
+ ...
+ 8. Repeat, while k < len
+ ...
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA([42]).reduce(function() {
+ called = true;
+ });
+
+ assert.sameValue(result, 42);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js
new file mode 100644
index 0000000000..baee34b2c7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var reduce = TypedArray.prototype.reduce;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ reduce.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ reduce.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ reduce.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ reduce.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ reduce.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ reduce.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ reduce.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..a1d606915e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var reduce = TypedArray.prototype.reduce;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ reduce.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ reduce.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ reduce.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ reduce.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js
new file mode 100644
index 0000000000..dcc9f8567a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduce/values-are-not-cached.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduce
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduce is a distinct function that implements the same
+ algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ sample.reduce(function(a, v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ }, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js
new file mode 100644
index 0000000000..9de661f3cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn arguments using custom accumulator
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.reduceRight(function(accumulator) {
+ results.push(arguments);
+ return accumulator + 1;
+ }, 7);
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[0].length");
+ assert.sameValue(results[0][0], 7, "results[0][0] - accumulator");
+ assert.sameValue(results[0][1], 44n, "results[0][1] - kValue");
+ assert.sameValue(results[0][2], 2, "results[0][2] - k");
+ assert.sameValue(results[0][3], sample, "results[0][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[1].length");
+ assert.sameValue(results[1][0], 8, "results[1][0] - accumulator");
+ assert.sameValue(results[1][1], 43n, "results[1][1] - kValue");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+ assert.sameValue(results[1][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[2].length, 4, "results[2].length");
+ assert.sameValue(results[2][0], 9, "results[2][0] - accumulator");
+ assert.sameValue(results[2][1], 42n, "results[2][1] - kValue");
+ assert.sameValue(results[2][2], 0, "results[2][2] - k");
+ assert.sameValue(results[2][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js
new file mode 100644
index 0000000000..9f57accb0a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn arguments using default accumulator (value at last index)
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.reduceRight(function(accumulator) {
+ results.push(arguments);
+ return accumulator + 1n;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[1].length");
+ assert.sameValue(results[0][0], 44n, "results[1][0] - accumulator");
+ assert.sameValue(results[0][1], 43n, "results[1][1] - kValue");
+ assert.sameValue(results[0][2], 1, "results[1][2] - k");
+ assert.sameValue(results[0][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[2].length");
+ assert.sameValue(results[1][0], 45n, "results[2][0] - accumulator");
+ assert.sameValue(results[1][1], 42n, "results[2][1] - kValue");
+ assert.sameValue(results[1][2], 0, "results[2][2] - k");
+ assert.sameValue(results[1][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..c6ed68fa27
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.reduceRight(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ }, 0);
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js
new file mode 100644
index 0000000000..8ff2828a6c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(Symbol(""));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js
new file mode 100644
index 0000000000..4f3c3ac19e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.reduceRight(function() {
+ results.push(arguments);
+ }, 0);
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][2], 1, "results[0][2] - k");
+ assert.sameValue(results[1][2], 0, "results[1][2] - k");
+
+ assert.sameValue(results[0][1], 8n, "results[0][1] - kValue");
+ assert.sameValue(results[1][1], 7n, "results[1][1] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..54962728ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().reduceRight(function() {
+ called++;
+ }, undefined);
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..6644e5e9eb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ The callbackfn return does not change the `this` instance
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n, 1n, 0n]);
+
+ sample.reduceRight(function() {
+ return 42;
+ }, 7);
+
+ assert.sameValue(sample[0], 0n, "[0] == 0");
+ assert.sameValue(sample[1], 1n, "[1] == 1");
+ assert.sameValue(sample[2], 0n, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..31e90e15e2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(Test262Error, function() {
+ sample.reduceRight(function() {
+ throw new Test262Error();
+ });
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.reduceRight(function() {
+ throw new Test262Error();
+ }, 0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js
new file mode 100644
index 0000000000..5105c5c7b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.reduceRight(function(acc, val, i) {
+ if (i < sample.length - 1) {
+ assert.sameValue(
+ sample[i + 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 2, 7n),
+ true,
+ "re-set a value for sample[2]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ }, 0);
+
+ assert.sameValue(sample[0], 2n, "changed values after iteration [0] == 2");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 7n, "changed values after iteration [2] == 7");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..d49c171623
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results = [];
+
+ sample.reduceRight(function() {
+ results.push(this);
+ }, 0);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(results[0], expected, "[0]");
+ assert.sameValue(results[1], expected, "[1]");
+ assert.sameValue(results[2], expected, "[2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..8f9c3043fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.reduceRight(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js
new file mode 100644
index 0000000000..509ef7c349
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns given initialValue on empty instances without calling callbackfn
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA().reduceRight(function() {
+ called = true;
+ }, 42);
+
+ assert.sameValue(result, 42);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js
new file mode 100644
index 0000000000..b20f594790
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ If len is 0 and initialValue is not present, throw a TypeError exception.
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ assert.throws(TypeError, function() {
+ new TA().reduceRight(function() {
+ called++;
+ });
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..7f82e9fe2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.reduceRight(function() {
+ calls++;
+ }, 0);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js
new file mode 100644
index 0000000000..8df0ab71de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns last accumulator value
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var calls, result;
+
+ calls = 0;
+ result = new TA([1n, 2n, 3n]).reduceRight(function() {
+ calls++;
+
+ if (calls == 2) {
+ return 42;
+ }
+ });
+ assert.sameValue(result, 42, "using default accumulator");
+
+ calls = 0;
+ result = new TA([1n, 2n, 3n]).reduceRight(function() {
+ calls++;
+
+ if (calls == 3) {
+ return 7;
+ }
+ }, 0);
+ assert.sameValue(result, 7, "using custom accumulator");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js
new file mode 100644
index 0000000000..fc8909a781
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Result can be of any type without any number conversions
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ [
+ ["test262", "string"],
+ ["", "empty string"],
+ [undefined, "undefined"],
+ [null, "null"],
+ [-0, "-0"],
+ [42, "integer"],
+ [NaN, "NaN"],
+ [Infinity, "Infinity"],
+ [0.6, "float number"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol(""), "symbol"],
+ [{}, "object"]
+ ].forEach(function(item) {
+ var result;
+
+ result = sample.reduceRight(function() {
+ return item[0];
+ });
+ assert.sameValue(result, item[0], item[1] + " - using default accumulator");
+
+ result = sample.reduceRight(function() {
+ return item[0];
+ }, 0);
+
+ assert.sameValue(result, item[0], item[1] + " - using custom accumulator");
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..2f14282ea0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.reduceRight,
+ 'function',
+ 'implements TypedArray.prototype.reduceRight'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.reduceRight(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.reduceRight(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reduceRight operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.reduceRight(() => {});
+ throw new Test262Error('reduceRight completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js
new file mode 100644
index 0000000000..1ee5b0002e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns [0] without calling callbackfn if length is 1 and initialValue is not
+ present.
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ 9. Return accumulator.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA([42n]).reduceRight(function() {
+ called = true;
+ });
+
+ assert.sameValue(result, 42n);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..b24d37651a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([44n, 43n, 42n]);
+
+ sample.reduceRight(function(a, v, i) {
+ if (i > 0) {
+ sample[i-1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ }, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js
new file mode 100644
index 0000000000..4d4bc07f7b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn arguments using custom accumulator
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.reduceRight(function(accumulator) {
+ results.push(arguments);
+ return accumulator + 1;
+ }, 7);
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[0].length");
+ assert.sameValue(results[0][0], 7, "results[0][0] - accumulator");
+ assert.sameValue(results[0][1], 44, "results[0][1] - kValue");
+ assert.sameValue(results[0][2], 2, "results[0][2] - k");
+ assert.sameValue(results[0][3], sample, "results[0][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[1].length");
+ assert.sameValue(results[1][0], 8, "results[1][0] - accumulator");
+ assert.sameValue(results[1][1], 43, "results[1][1] - kValue");
+ assert.sameValue(results[1][2], 1, "results[1][2] - k");
+ assert.sameValue(results[1][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[2].length, 4, "results[2].length");
+ assert.sameValue(results[2][0], 9, "results[2][0] - accumulator");
+ assert.sameValue(results[2][1], 42, "results[2][1] - kValue");
+ assert.sameValue(results[2][2], 0, "results[2][2] - k");
+ assert.sameValue(results[2][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js
new file mode 100644
index 0000000000..980cac7ae0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn arguments using default accumulator (value at last index)
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.reduceRight(function(accumulator) {
+ results.push(arguments);
+ return accumulator + 1;
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0].length, 4, "results[1].length");
+ assert.sameValue(results[0][0], 44, "results[1][0] - accumulator");
+ assert.sameValue(results[0][1], 43, "results[1][1] - kValue");
+ assert.sameValue(results[0][2], 1, "results[1][2] - k");
+ assert.sameValue(results[0][3], sample, "results[1][3] - this");
+
+ assert.sameValue(results[1].length, 4, "results[2].length");
+ assert.sameValue(results[1][0], 45, "results[2][0] - accumulator");
+ assert.sameValue(results[1][1], 42, "results[2][1] - kValue");
+ assert.sameValue(results[1][2], 0, "results[2][2] - k");
+ assert.sameValue(results[1][3], sample, "results[2][3] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..48cc0be33c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.reduceRight(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return true;
+ }, 0);
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js
new file mode 100644
index 0000000000..8de1268a44
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Throws TypeError if callbackfn is not callable
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight();
+ }, "no arg");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(1);
+ }, "1");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight("");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.reduceRight(Symbol(""));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js
new file mode 100644
index 0000000000..dcf8d628e8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Does not iterate over non-integer properties
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.reduceRight(function() {
+ results.push(arguments);
+ }, 0);
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][2], 1, "results[0][2] - k");
+ assert.sameValue(results[1][2], 0, "results[1][2] - k");
+
+ assert.sameValue(results[0][1], 8, "results[0][1] - kValue");
+ assert.sameValue(results[1][1], 7, "results[1][1] - kValue");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..cd881b9b72
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().reduceRight(function() {
+ called++;
+ }, undefined);
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js
new file mode 100644
index 0000000000..910645a263
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-resize.js
@@ -0,0 +1,78 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3});
+ var sample = new TA(buffer);
+ var secondNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays;
+ var prevs, nexts, indices, arrays, result;
+
+ prevs = [];
+ nexts = [];
+ indices = [];
+ arrays = [];
+ result = sample.reduceRight(function(prev, next, index, array) {
+ if (prevs.length === 0) {
+ try {
+ buffer.resize(BPE);
+ secondNext = undefined;
+ expectedPrevs = [262];
+ expectedNexts = [0];
+ expectedIndices = [0];
+ expectedArrays = [sample];
+ } catch (_) {
+ secondNext = 0;
+ expectedPrevs = [262, 2, 1];
+ expectedNexts = [0, 0, 0];
+ expectedIndices = [2, 1, 0];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ prevs.push(prev);
+ nexts.push(next);
+ indices.push(index);
+ arrays.push(array);
+ return index;
+ }, 262);
+
+ assert.compareArray(prevs, [262, 2, 1], 'prevs (shrink)');
+ assert.compareArray(nexts, [0, secondNext, 0], 'nexts (shrink)');
+ assert.compareArray(indices, [2, 1, 0], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, 0, 'result (shrink)');
+
+ prevs = [];
+ nexts = [];
+ indices = [];
+ arrays = [];
+ result = sample.reduceRight(function(prev, next, index, array) {
+ if (prevs.length === 0) {
+ try {
+ buffer.resize(3 * BPE);
+ } catch (_) {}
+ }
+
+ prevs.push(prev);
+ nexts.push(next);
+ indices.push(index);
+ arrays.push(array);
+ return index;
+ }, 262);
+
+ assert.compareArray(prevs, expectedPrevs, 'prevs (grow)');
+ assert.compareArray(nexts, expectedNexts, 'nexts (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..7a9e8244d3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ The callbackfn return does not change the `this` instance
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([0, 1, 0]);
+
+ sample.reduceRight(function() {
+ return 42;
+ }, 7);
+
+ assert.sameValue(sample[0], 0, "[0] == 0");
+ assert.sameValue(sample[1], 1, "[1] == 1");
+ assert.sameValue(sample[2], 0, "[2] == 0");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..e37d426ce8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns abrupt from callbackfn
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue,
+ k, O »).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(Test262Error, function() {
+ sample.reduceRight(function() {
+ throw new Test262Error();
+ });
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.reduceRight(function() {
+ throw new Test262Error();
+ }, 0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js
new file mode 100644
index 0000000000..3381fc34e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.reduceRight(function(acc, val, i) {
+ if (i < sample.length - 1) {
+ assert.sameValue(
+ sample[i + 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 2, 7),
+ true,
+ "re-set a value for sample[2]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ }, 0);
+
+ assert.sameValue(sample[0], 2, "changed values after iteration [0] == 2");
+ assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 7, "changed values after iteration [2] == 7");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js
new file mode 100644
index 0000000000..bc62313fbe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/callbackfn-this.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results = [];
+
+ sample.reduceRight(function() {
+ results.push(this);
+ }, 0);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(results[0], expected, "[0]");
+ assert.sameValue(results[1], expected, "[1]");
+ assert.sameValue(results[2], expected, "[2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js
new file mode 100644
index 0000000000..703125d148
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.reduceRight(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js
new file mode 100644
index 0000000000..eb3a4f12bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns given initialValue on empty instances without calling callbackfn
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA().reduceRight(function() {
+ called = true;
+ }, 42);
+
+ assert.sameValue(result, 42);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js
new file mode 100644
index 0000000000..e65a06ee40
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ If len is 0 and initialValue is not present, throw a TypeError exception.
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 4. If len is 0 and initialValue is not present, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ assert.throws(TypeError, function() {
+ new TA().reduceRight(function() {
+ called++;
+ });
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..63d2ba2c75
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.reduceRight(function() {
+ calls++;
+ }, 0);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js
new file mode 100644
index 0000000000..0dd4b313ee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var reduceRight = TypedArray.prototype.reduceRight;
+
+assert.sameValue(typeof reduceRight, 'function');
+
+assert.throws(TypeError, function() {
+ reduceRight();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js
new file mode 100644
index 0000000000..74f48b50d6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.20 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.reduceRight, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.reduceRight();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js
new file mode 100644
index 0000000000..075fdf1d6a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ %TypedArray%.prototype.reduceRight.length is 1.
+info: |
+ %TypedArray%.prototype.reduceRight ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reduceRight.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.reduceRight, "length");
+verifyNotWritable(TypedArray.prototype.reduceRight, "length");
+verifyConfigurable(TypedArray.prototype.reduceRight, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js
new file mode 100644
index 0000000000..46b5b553bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ %TypedArray%.prototype.reduceRight.name is "reduceRight".
+info: |
+ %TypedArray%.prototype.reduceRight ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reduceRight.name, "reduceRight");
+
+verifyNotEnumerable(TypedArray.prototype.reduceRight, "name");
+verifyNotWritable(TypedArray.prototype.reduceRight, "name");
+verifyConfigurable(TypedArray.prototype.reduceRight, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js
new file mode 100644
index 0000000000..a208f6e644
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.reduceRight does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.reduceRight),
+ false,
+ 'isConstructor(TypedArray.prototype.reduceRight) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.reduceRight(() => {}, []);
+}, '`let u8 = new Uint8Array(1); new u8.reduceRight(() => {}, [])` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js
new file mode 100644
index 0000000000..b3e98bf99d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ "reduceRight" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'reduceRight');
+verifyWritable(TypedArrayPrototype, 'reduceRight');
+verifyConfigurable(TypedArrayPrototype, 'reduceRight');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js
new file mode 100644
index 0000000000..cdac8406de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns last accumulator value
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var calls, result;
+
+ calls = 0;
+ result = new TA([1, 2, 3]).reduceRight(function() {
+ calls++;
+
+ if (calls == 2) {
+ return 42;
+ }
+ });
+ assert.sameValue(result, 42, "using default accumulator");
+
+ calls = 0;
+ result = new TA([1, 2, 3]).reduceRight(function() {
+ calls++;
+
+ if (calls == 3) {
+ return 7;
+ }
+ }, 0);
+ assert.sameValue(result, 7, "using custom accumulator");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js
new file mode 100644
index 0000000000..24e3da9059
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/result-of-any-type.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Result can be of any type without any number conversions
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ [
+ ["test262", "string"],
+ ["", "empty string"],
+ [undefined, "undefined"],
+ [null, "null"],
+ [-0, "-0"],
+ [42, "integer"],
+ [NaN, "NaN"],
+ [Infinity, "Infinity"],
+ [0.6, "float number"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol(""), "symbol"],
+ [{}, "object"]
+ ].forEach(function(item) {
+ var result;
+
+ result = sample.reduceRight(function() {
+ return item[0];
+ });
+ assert.sameValue(result, item[0], item[1] + " - using default accumulator");
+
+ result = sample.reduceRight(function() {
+ return item[0];
+ }, 0);
+
+ assert.sameValue(result, item[0], item[1] + " - using custom accumulator");
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..29269658d7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.reduceRight,
+ 'function',
+ 'implements TypedArray.prototype.reduceRight'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.reduceRight(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.reduceRight(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reduceRight operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.reduceRight(() => {});
+ throw new Test262Error('reduceRight completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js
new file mode 100644
index 0000000000..ec61d34c4d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Returns [0] without calling callbackfn if length is 1 and initialValue is not
+ present.
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 7. Else initialValue is not present,
+ ...
+ b. Repeat, while kPresent is false and k ≥ 0
+ ...
+ ii. Let kPresent be ? HasProperty(O, Pk).
+ iii. If kPresent is true, then
+ 1. Let accumulator be ? Get(O, Pk).
+ iv. Decrease k by 1.
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ 9. Return accumulator.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = false;
+ var result = new TA([42]).reduceRight(function() {
+ called = true;
+ });
+
+ assert.sameValue(result, 42);
+ assert.sameValue(called, false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js
new file mode 100644
index 0000000000..64730d4df4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var reduceRight = TypedArray.prototype.reduceRight;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ reduceRight.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ reduceRight.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ reduceRight.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ reduceRight.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ reduceRight.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ reduceRight.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ reduceRight.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..f55fd60dc2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var reduceRight = TypedArray.prototype.reduceRight;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ reduceRight.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ reduceRight.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ reduceRight.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ reduceRight.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js
new file mode 100644
index 0000000000..55afeef5d1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reduceRight/values-are-not-cached.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reduceright
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ %TypedArray%.prototype.reduceRight is a distinct function that implements the
+ same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except
+ that the this object's [[ArrayLength]] internal slot is accessed in place of
+ performing a [[Get]] of "length".
+
+ 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )
+
+ ...
+ 8. Repeat, while k ≥ 0
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator,
+ kValue, k, O »).
+ d. Decrease k by 1.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([44, 43, 42]);
+
+ sample.reduceRight(function(a, v, i) {
+ if (i > 0) {
+ sample[i-1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ }, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..9c68741252
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.reverse();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..5cdde77f44
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.reverse();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js
new file mode 100644
index 0000000000..ae87074215
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Preserves non numeric properties
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ ...
+ 6. Return O.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample, result;
+
+ sample = new TA(2);
+ sample.foo = 42;
+ sample.bar = "bar";
+ sample[s] = 1;
+ result = sample.reverse();
+ assert.sameValue(result.foo, 42, "sample.foo === 42");
+ assert.sameValue(result.bar, "bar", "sample.bar === 'bar'");
+ assert.sameValue(result[s], 1, "sample[s] === 1");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..8b4a48b0e8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.reverse,
+ 'function',
+ 'implements TypedArray.prototype.reverse'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.reverse();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.reverse();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reverse operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.reverse();
+ throw new Test262Error('reverse completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/returns-original-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/returns-original-object.js
new file mode 100644
index 0000000000..4d118e0a96
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/returns-original-object.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Returns the same object
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ ...
+ 6. Return O.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(64);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample, result, expectedLength;
+
+ sample = new TA(buffer, 0);
+ expectedLength = sample.length;
+ result = sample.reverse();
+ assert.sameValue(result, sample, "returns the same object");
+ assert.sameValue(sample.buffer, buffer, "keeps the same buffer");
+ assert.sameValue(sample.length, expectedLength, "length is preserved");
+
+ sample = new TA(buffer, 0, 0);
+ result = sample.reverse();
+ assert.sameValue(result, sample, "returns the same object (empty instance)");
+ assert.sameValue(sample.buffer, buffer, "keeps the same buffer (empty instance)");
+ assert.sameValue(sample.length, 0, "length is preserved (empty instance)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/reverts.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/reverts.js
new file mode 100644
index 0000000000..00e13a2baf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/reverts.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Reverts values
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ ...
+ 6. Return O.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(64);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(buffer, 0, 4);
+ var other = new TA(buffer, 0, 5);
+
+ sample[0] = 42n;
+ sample[1] = 43n;
+ sample[2] = 2n;
+ sample[3] = 1n;
+ other[4] = 7n;
+
+ sample.reverse();
+ assert(
+ compareArray(sample, [1n, 2n, 43n, 42n])
+ );
+
+ assert(
+ compareArray(other, [1n, 2n, 43n, 42n, 7n])
+ );
+
+ sample[0] = 7n;
+ sample[1] = 17n;
+ sample[2] = 1n;
+ sample[3] = 0n;
+ other[4] = 42n;
+
+ other.reverse();
+ assert(
+ compareArray(other, [42n, 0n, 1n, 17n, 7n])
+ );
+
+ assert(
+ compareArray(sample, [42n, 0n, 1n, 17n])
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js
new file mode 100644
index 0000000000..896082d81c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.reverse();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..5cead93847
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.reverse();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js
new file mode 100644
index 0000000000..370572c694
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reverse ( )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var reverse = TypedArray.prototype.reverse;
+
+assert.sameValue(typeof reverse, 'function');
+
+assert.throws(TypeError, function() {
+ reverse();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js
new file mode 100644
index 0000000000..90f2791edd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.21 %TypedArray%.prototype.reverse ( )
+
+ ...
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.reverse, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.reverse();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js
new file mode 100644
index 0000000000..b0387a8bc5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: >
+ %TypedArray%.prototype.reverse.length is 0.
+info: |
+ %TypedArray%.prototype.reverse ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reverse.length, 0);
+
+verifyNotEnumerable(TypedArray.prototype.reverse, "length");
+verifyNotWritable(TypedArray.prototype.reverse, "length");
+verifyConfigurable(TypedArray.prototype.reverse, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js
new file mode 100644
index 0000000000..0d39739566
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: >
+ %TypedArray%.prototype.reverse.name is "reverse".
+info: |
+ %TypedArray%.prototype.reverse ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.reverse.name, "reverse");
+
+verifyNotEnumerable(TypedArray.prototype.reverse, "name");
+verifyNotWritable(TypedArray.prototype.reverse, "name");
+verifyConfigurable(TypedArray.prototype.reverse, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js
new file mode 100644
index 0000000000..0a0bd3b968
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.reverse does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.reverse),
+ false,
+ 'isConstructor(TypedArray.prototype.reverse) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.reverse();
+}, '`let u8 = new Uint8Array(1); new u8.reverse()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js
new file mode 100644
index 0000000000..3d04d8a0ac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Preserves non numeric properties
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ ...
+ 6. Return O.
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, result;
+
+ sample = new TA(2);
+ sample.foo = 42;
+ sample.bar = "bar";
+ sample[s] = 1;
+ result = sample.reverse();
+ assert.sameValue(result.foo, 42, "sample.foo === 42");
+ assert.sameValue(result.bar, "bar", "sample.bar === 'bar'");
+ assert.sameValue(result[s], 1, "sample[s] === 1");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js
new file mode 100644
index 0000000000..caba22fd33
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: >
+ "reverse" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'reverse');
+verifyWritable(TypedArrayPrototype, 'reverse');
+verifyConfigurable(TypedArrayPrototype, 'reverse');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..4be4854517
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.reverse,
+ 'function',
+ 'implements TypedArray.prototype.reverse'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.reverse();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.reverse();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reverse operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.reverse();
+ throw new Test262Error('reverse completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js
new file mode 100644
index 0000000000..732dd0d193
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/returns-original-object.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Returns the same object
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ ...
+ 6. Return O.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(64);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, result, expectedLength;
+
+ sample = new TA(buffer, 0);
+ expectedLength = sample.length;
+ result = sample.reverse();
+ assert.sameValue(result, sample, "returns the same object");
+ assert.sameValue(sample.buffer, buffer, "keeps the same buffer");
+ assert.sameValue(sample.length, expectedLength, "length is preserved");
+
+ sample = new TA(buffer, 0, 0);
+ result = sample.reverse();
+ assert.sameValue(result, sample, "returns the same object (empty instance)");
+ assert.sameValue(sample.buffer, buffer, "keeps the same buffer (empty instance)");
+ assert.sameValue(sample.length, 0, "length is preserved (empty instance)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js
new file mode 100644
index 0000000000..8f476a8201
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/reverts.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Reverts values
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ %TypedArray%.prototype.reverse is a distinct function that implements the same
+ algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the
+ this object's [[ArrayLength]] internal slot is accessed in place of performing
+ a [[Get]] of "length".
+
+ 22.1.3.21 Array.prototype.reverse ( )
+
+ ...
+ 6. Return O.
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var buffer = new ArrayBuffer(64);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(buffer, 0, 4);
+ var other = new TA(buffer, 0, 5);
+
+ sample[0] = 42;
+ sample[1] = 43;
+ sample[2] = 2;
+ sample[3] = 1;
+ other[4] = 7;
+
+ sample.reverse();
+ assert(
+ compareArray(sample, [1, 2, 43, 42])
+ );
+
+ assert(
+ compareArray(other, [1, 2, 43, 42, 7])
+ );
+
+ sample[0] = 7;
+ sample[1] = 17;
+ sample[2] = 1;
+ sample[3] = 0;
+ other[4] = 42;
+
+ other.reverse();
+ assert(
+ compareArray(other, [42, 0, 1, 17, 7])
+ );
+
+ assert(
+ compareArray(sample, [42, 0, 1, 17])
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js
new file mode 100644
index 0000000000..aed6161e54
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var reverse = TypedArray.prototype.reverse;
+
+assert.throws(TypeError, function() {
+ reverse.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ reverse.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ reverse.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ reverse.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ reverse.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ reverse.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ reverse.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..f5e662b567
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.reverse
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.22 %TypedArray%.prototype.reverse ( )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var reverse = TypedArray.prototype.reverse;
+
+assert.throws(TypeError, function() {
+ reverse.call({});
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ reverse.call([]);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ reverse.call(ab);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ reverse.call(dv);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js
new file mode 100644
index 0000000000..6631699cb4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Throw a RangeError exception if targetOffset < 0
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ 7. If targetOffset < 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+
+ assert.throws(RangeError, function() {
+ sample.set([1n], -1);
+ }, "-1");
+
+ assert.throws(RangeError, function() {
+ sample.set([1n], -1.00001);
+ }, "-1.00001");
+
+ assert.throws(RangeError, function() {
+ sample.set([1n], -Infinity);
+ }, "-Infinity");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js
new file mode 100644
index 0000000000..5853c74c1e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js
@@ -0,0 +1,97 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ ToInteger(offset) operations
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ 7. If targetOffset < 0, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], "");
+ assert(compareArray(sample, [42n, 2n]), "the empty string");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], "0");
+ assert(compareArray(sample, [42n, 2n]), "'0'");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], false);
+ assert(compareArray(sample, [42n, 2n]), "false");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], 0.1);
+ assert(compareArray(sample, [42n, 2n]), "0.1");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], 0.9);
+ assert(compareArray(sample, [42n, 2n]), "0.9");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], -0.5);
+ assert(compareArray(sample, [42n, 2n]), "-0.5");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], 1.1);
+ assert(compareArray(sample, [1n, 42n]), "1.1");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], NaN);
+ assert(compareArray(sample, [42n, 2n]), "NaN");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], null);
+ assert(compareArray(sample, [42n, 2n]), "null");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], undefined);
+ assert(compareArray(sample, [42n, 2n]), "undefined");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], {});
+ assert(compareArray(sample, [42n, 2n]), "{}");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], []);
+ assert(compareArray(sample, [42n, 2n]), "[]");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], [0]);
+ assert(compareArray(sample, [42n, 2n]), "[0]");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], true);
+ assert(compareArray(sample, [1n, 42n]), "true");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], "1");
+ assert(compareArray(sample, [1n, 42n]), "'1'");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], [1]);
+ assert(compareArray(sample, [1n, 42n]), "[1]");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], { valueOf: function() {return 1;} });
+ assert(compareArray(sample, [1n, 42n]), "valueOf");
+
+ sample = new TA([1n, 2n]);
+ sample.set([42n], { toString: function() {return 1;} });
+ assert(compareArray(sample, [1n, 42n]), "toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js
new file mode 100644
index 0000000000..d2fe88d0d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Primitive `array` argument is coerced to an object.
+info: |
+ %TypedArray%.prototype.set ( typedArray [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object
+ with a [[TypedArrayName]] internal slot. If it is such an Object,
+ the definition in 22.2.3.23.2 applies.
+ [...]
+ 14. Let src be ? ToObject(array).
+ 15. Let srcLength be ? LengthOfArrayLike(src).
+ [...]
+ 19. Let limit be targetByteIndex + targetElementSize × srcLength.
+ 20. Repeat, while targetByteIndex < limit,
+ a. Let Pk be ! ToString(k).
+ b. Let value be ? Get(src, Pk).
+ c. If target.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
+ [...]
+ f. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, Unordered).
+ [...]
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray, Symbol]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ta1 = new TA([1n, 2n, 3n, 4n]);
+ ta1.set("567");
+ assert.compareArray(ta1, [5n, 6n, 7n, 4n], "string");
+
+ var ta2 = new TA([1n, 2n, 3n]);
+ ta2.set(-10, 2);
+ assert.compareArray(ta2, [1n, 2n, 3n], "number");
+
+ var ta3 = new TA([1n]);
+ ta3.set(false);
+ assert.compareArray(ta3, [1n], "boolean");
+
+ var ta4 = new TA([1n, 2n]);
+ ta4.set(Symbol("desc"), 0);
+ assert.compareArray(ta4, [1n, 2n], "symbol");
+
+ var ta5 = new TA([1n, 2n]);
+ ta5.set(4n, 1);
+ assert.compareArray(ta5, [1n, 2n], "bigint");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js
new file mode 100644
index 0000000000..86b73fc62d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt getting src "length"
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {};
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 2n, 3n]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js
new file mode 100644
index 0000000000..6d1a90022e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from getting src property value
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var obj = {
+ length: 4,
+ "0": 42n,
+ "1": 43n,
+ "3": 44n
+ };
+ Object.defineProperty(obj, "2", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([1n, 2n, 3n, 4n]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj);
+ });
+
+ assert(
+ compareArray(sample, [42n, 43n, 3n, 4n]),
+ "values are set until exception"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js
new file mode 100644
index 0000000000..aee3df52d8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt getting src "length" as symbol
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var obj = {
+ length: Symbol("1")
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 2n, 3n]);
+
+ assert.throws(TypeError, function() {
+ sample.set(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js
new file mode 100644
index 0000000000..4c8f69a59b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToLength(src "length")
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj1 = {
+ length: {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ }
+};
+
+var obj2 = {
+ length: {
+ toString: function() {
+ throw new Test262Error();
+ }
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 2n, 3n]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj1);
+ }, "valueOf");
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj2);
+ }, "toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js
new file mode 100644
index 0000000000..df47d391a4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToNumber(src property symbol value)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var obj = {
+ length: 4,
+ "0": 42n,
+ "1": 43n,
+ "2": Symbol("1"),
+ "3": 44n
+ };
+
+ var sample = new TA([1n, 2n, 3n, 4n]);
+
+ assert.throws(TypeError, function() {
+ sample.set(obj);
+ });
+
+ assert(
+ compareArray(sample, [42n, 43n, 3n, 4n]),
+ "values are set until exception"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js
new file mode 100644
index 0000000000..99ba4c3b67
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToNumber(src property value)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var obj = {
+ length: 4,
+ "0": 42n,
+ "1": 43n,
+ "2": {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ },
+ "3": 44n
+ };
+
+ var sample = new TA([1n, 2n, 3n, 4n]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj);
+ });
+
+ assert(
+ compareArray(sample, [42n, 43n, 3n, 4n]),
+ "values are set until exception"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js
new file mode 100644
index 0000000000..be0d63523a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToInteger(Symbol offset)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.set([1n], s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js
new file mode 100644
index 0000000000..680bd3591c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToInteger(offset)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.set([], obj1);
+ }, "abrupt from valueOf");
+
+ assert.throws(Test262Error, function() {
+ sample.set([], obj2);
+ }, "abrupt from toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js
new file mode 100644
index 0000000000..f0170ebe63
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToObject(array)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 15. Let src be ? ToObject(array).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([1n, 2n, 3n]);
+
+ assert.throws(TypeError, function() {
+ sample.set(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.set(null);
+ }, "null");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js
new file mode 100644
index 0000000000..9449aeca3b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js
@@ -0,0 +1,74 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Get and set each value in order
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(5);
+ var calls = [];
+ var obj = {
+ length: 3
+ };
+ Object.defineProperty(obj, 0, {
+ get: function() {
+ calls.push(0);
+ calls.push(sample.join());
+ return 42n;
+ }
+ });
+
+ Object.defineProperty(obj, 1, {
+ get: function() {
+ calls.push(1);
+ calls.push(sample.join());
+ return 43n;
+ }
+ });
+
+ Object.defineProperty(obj, 2, {
+ get: function() {
+ calls.push(2);
+ calls.push(sample.join());
+ return 44n;
+ }
+ });
+
+ Object.defineProperty(obj, 3, {
+ get: function() {
+ throw new Test262Error("Should not call obj[3]");
+ }
+ });
+
+ sample.set(obj, 1);
+
+ assert(
+ compareArray(sample, [0n, 42n, 43n, 44n, 0n]),
+ "values are set for src length"
+ );
+
+ assert(
+ compareArray(calls, [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]),
+ "values are set in order"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js
new file mode 100644
index 0000000000..d2a420b70c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-set-values.js
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Set values to target and return undefined
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ Let Pk be ! ToString(k).
+ Let kNumber be ? ToNumber(? Get(src, Pk)).
+ If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber).
+ ...
+ 22. Return undefined.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var src = [42n, 43n];
+ var srcObj = {
+ length: 2,
+ '0': 7n,
+ '1': 17n
+ };
+ var sample, result;
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(srcObj, 0);
+ assert(compareArray(sample, [7n, 17n, 3n, 4n]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(srcObj, 1);
+ assert(compareArray(sample, [1n, 7n, 17n, 4n]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(srcObj, 2);
+ assert(compareArray(sample, [1n, 2n, 7n, 17n]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js
new file mode 100644
index 0000000000..ffffc3d976
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Type conversions on ToNumber(src property value)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var obj1 = {
+ valueOf: function() {
+ return 42n;
+ }
+ };
+
+ var obj2 = {
+ toString: function() {
+ return "42";
+ }
+ };
+
+ var arr = [false, true, obj1, [], [1]];
+
+ var sample = new TA(arr.length);
+ var expected = new TA([0n, 1n, 42n, 0n, 1n]);
+
+ sample.set(arr);
+
+ assert(
+ compareArray(sample, expected),
+ "sample: [" + sample + "], expected: [" + expected + "]"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js
new file mode 100644
index 0000000000..669d1d2aa2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Values from src array are not cached
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(5);
+ var obj = {
+ length: 5,
+ '1': 7n,
+ '2': 7n,
+ '3': 7n,
+ '4': 7n
+ };
+ Object.defineProperty(obj, 0, {
+ get: function() {
+ obj[1] = 43n;
+ obj[2] = 44n;
+ obj[3] = 45n;
+ obj[4] = 46n;
+ return 42n;
+ }
+ });
+
+ sample.set(obj);
+
+ assert(compareArray(sample, [42n, 43n, 44n, 45n, 46n]));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js
new file mode 100644
index 0000000000..a6d14c115b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Uses target's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 10. Let targetLength be the value of target's [[ArrayLength]] internal slot.
+ ...
+ 17. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.set([42n, 43n]);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js
new file mode 100644
index 0000000000..b469bd044d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Throws a TypeError if targetBuffer is detached on ToInteger(offset)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal
+ slot.
+ 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calledOffset = 0;
+ var obj = {
+ valueOf: function() {
+ $DETACHBUFFER(sample.buffer);
+ calledOffset += 1;
+ }
+ };
+
+ assert.throws(TypeError, function() {
+ sample.set([1n], obj);
+ });
+
+ assert.sameValue(calledOffset, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js
new file mode 100644
index 0000000000..9c2f286b3e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Throws a TypeError if targetBuffer is detached
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal
+ slot.
+ 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ ...
+ 15. Let src be ? ToObject(array).
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {};
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ $DETACHBUFFER(sample.buffer);
+
+ assert.throws(TypeError, function() {
+ sample.set([1n]);
+ }, "regular check");
+
+ assert.throws(TypeError, function() {
+ sample.set(obj);
+ }, "IsDetachedBuffer happens before Get(src.length)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js
new file mode 100644
index 0000000000..1cd0db81eb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js
@@ -0,0 +1,90 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Behavior for input array of BigInts
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )
+ ...
+ 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian).
+ ...
+
+ NumberToRawBytes( type, value, isLittleEndian )
+ ...
+ 3. Else,
+ a. Let n be the Number value of the Element Size specified in Table
+ [The TypedArray Constructors] for Element Type type.
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 9 for Element Type type.
+
+ The TypedArray Constructors
+ Element Type: BigInt64
+ Conversion Operation: ToBigInt64
+
+ ToBigInt64 ( argument )
+ The abstract operation ToBigInt64 converts argument to one of 264 integer
+ values in the range -2^63 through 2^63-1, inclusive.
+ This abstract operation functions as follows:
+ 1. Let n be ? ToBigInt(argument).
+ 2. Let int64bit be n modulo 2^64.
+ 3. If int64bit ≥ 2^63, return int64bit - 2^64; otherwise return int64bit.
+
+features: [BigInt, TypedArray]
+---*/
+
+var vals = [
+ 18446744073709551618n, // 2n ** 64n + 2n
+ 9223372036854775810n, // 2n ** 63n + 2n
+ 2n,
+ 0n,
+ -2n,
+ -9223372036854775810n, // -(2n ** 63n) - 2n
+ -18446744073709551618n, // -(2n ** 64n) - 2n
+];
+
+var typedArray = new BigInt64Array(vals.length);
+typedArray.set(vals);
+
+assert.sameValue(typedArray[0], 2n,
+ "ToBigInt64(2n ** 64n + 2n) => 2n");
+
+assert.sameValue(typedArray[1], -9223372036854775806n, // 2n - 2n ** 63n
+ "ToBigInt64(2n ** 63n + 2n) => -9223372036854775806n");
+
+assert.sameValue(typedArray[2], 2n,
+ "ToBigInt64(2n) => 2n");
+
+assert.sameValue(typedArray[3], 0n,
+ "ToBigInt64(0n) => 0n");
+
+assert.sameValue(typedArray[4], -2n,
+ "ToBigInt64( -2n) => -2n");
+
+assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2
+ "ToBigInt64( -(2n ** 64n) - 2n) => 9223372036854775806n");
+
+assert.sameValue(typedArray[6], -2n,
+ "ToBigInt64( -(2n ** 64n) - 2n) => -2n");
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js
new file mode 100644
index 0000000000..c649f8db07
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js
@@ -0,0 +1,89 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Behavior for input array of BigInts
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isTypedArray, order [ , isLittleEndian ] )
+ ...
+ 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian).
+ ...
+
+ NumberToRawBytes( type, value, isLittleEndian )
+ ...
+ 3. Else,
+ a. Let n be the Number value of the Element Size specified in Table
+ [The TypedArray Constructors] for Element Type type.
+ b. Let convOp be the abstract operation named in the Conversion Operation
+ column in Table 9 for Element Type type.
+
+ The TypedArray Constructors
+ Element Type: BigUint64
+ Conversion Operation: ToBigUint64
+
+ ToBigUint64 ( argument )
+ The abstract operation ToBigInt64 converts argument to one of 264 integer
+ values in the range -2^63 through 2^63-1, inclusive.
+ This abstract operation functions as follows:
+ 1. Let n be ? ToBigInt(argument).
+ 2. Let int64bit be n modulo 2^64.
+ 3. Return int64bit.
+
+features: [BigInt, TypedArray]
+---*/
+
+var vals = [
+ 18446744073709551618n, // 2n ** 64n + 2n
+ 9223372036854775810n, // 2n ** 63n + 2n
+ 2n,
+ 0n,
+ -2n,
+ -9223372036854775810n, // -(2n ** 63n) - 2n
+ -18446744073709551618n, // -(2n ** 64n) - 2n
+];
+
+var typedArray = new BigUint64Array(vals.length);
+typedArray.set(vals);
+
+assert.sameValue(typedArray[0], 2n,
+ "ToBigUint64(2n ** 64n + 2n) => 2n");
+
+assert.sameValue(typedArray[1], 9223372036854775810n, // 2n ** 63n + 2n
+ "ToBigUint64(2n ** 63n + 2n) => 9223372036854775810");
+
+assert.sameValue(typedArray[2], 2n,
+ "ToBigUint64(2n) => 2n");
+
+assert.sameValue(typedArray[3], 0n,
+ "ToBigUint64(0n) => 0n");
+
+assert.sameValue(typedArray[4], 18446744073709551614n, // 2n ** 64n - 2n
+ "ToBigUint64( -2n) => 18446744073709551614n");
+
+assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2n
+ "ToBigUint64( -(2n ** 63n) - 2n) => 9223372036854775806n");
+
+assert.sameValue(typedArray[6], 18446744073709551614n, // 2n ** 64n - 2n
+ "ToBigUint64( -(2n ** 64n) - 2n) => 18446744073709551614n");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js
new file mode 100644
index 0000000000..02cfee433a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/boolean-tobigint.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Behavior for input array of Booleans
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Boolean
+ Result: Return 1n if prim is true and 0n if prim is false.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(2);
+ typedArray.set([false, true])
+
+ assert.sameValue(typedArray[0], 0n, "False converts to BigInt");
+ assert.sameValue(typedArray[1], 1n, "True converts to BigInt");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js
new file mode 100644
index 0000000000..f7bc8ce8d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/null-tobigint.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt on null
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Null
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(1);
+
+ assert.throws(TypeError, function() {
+ typedArray.set([null]);
+ }, "abrupt completion from Null");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js
new file mode 100644
index 0000000000..2047fc4683
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/number-tobigint.js
@@ -0,0 +1,74 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt on Number
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Number
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(1);
+
+ assert.throws(TypeError, function() {
+ typedArray.set([1]);
+ }, "abrupt completion from Number: 1");
+
+ assert.throws(TypeError, function() {
+ typedArray.set([Math.pow(2, 63)]);
+ }, "abrupt completion from Number: 2**63");
+
+ assert.throws(TypeError, function() {
+ typedArray.set([+0]);
+ }, "abrupt completion from Number: +0");
+
+ assert.throws(TypeError, function() {
+ typedArray.set([-0]);
+ }, "abrupt completion from Number: -0");
+
+ assert.throws(TypeError, function() {
+ typedArray.set([Infinity]);
+ }, "abrupt completion from Number: Infinity");
+
+ assert.throws(TypeError, function() {
+ typedArray.set([-Infinity]);
+ }, "abrupt completion from Number: -Infinity");
+
+ assert.throws(TypeError, function() {
+ typedArray.set([NaN]);
+ }, "abrupt completion from Number: NaN");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js
new file mode 100644
index 0000000000..e8c6598330
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-big.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ If typedArray constructor argument is a Big(U)Int, succeed in set
+info: |
+ %TypedArray%.prototype.set( typedArray [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the
+ typedArray argument object. The optional offset value indicates the first
+ element index in this TypedArray where values are written. If omitted, it
+ is assumed to be 0.
+ ...
+ 23. If one of srcType and targetType contains the substring "Big" and the
+ other does not, throw a TypeError exception.
+ ...
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var srcTypedArray;
+var targetTypedArray;
+var testValue = 42n;
+
+testWithBigIntTypedArrayConstructors(function(BTA1) {
+
+ srcTypedArray = new BTA1([testValue]);
+
+ testWithBigIntTypedArrayConstructors(function(BTA2) {
+
+ targetTypedArray = new BTA2(1);
+ targetTypedArray.set(srcTypedArray);
+ assert.sameValue(targetTypedArray[0], testValue,
+ "Setting BigInt TypedArray with BigInt TypedArray should succeed.")
+ });
+});
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js
new file mode 100644
index 0000000000..9250e0d7fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ If typedArray set argument is not a Big(U)Int, and target is "Big", throw
+info: |
+ %TypedArray%.prototype.set( typedArray [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the
+ typedArray argument object. The optional offset value indicates the first
+ element index in this TypedArray where values are written. If omitted, it
+ is assumed to be 0.
+ ...
+ 23. If one of srcType and targetType contains the substring "Big" and the
+ other does not, throw a TypeError exception.
+ ...
+
+includes: [testBigIntTypedArray.js, testTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var bigTypedArray;
+var littleTypedArray;
+
+testWithTypedArrayConstructors(function(TA) {
+
+ littleTypedArray = new TA([1]);
+
+ testWithBigIntTypedArrayConstructors(function(BTA) {
+
+ bigTypedArray = new BTA(1);
+ assert.throws(TypeError, function() {
+ bigTypedArray.set(littleTypedArray);
+ });
+ });
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js
new file mode 100644
index 0000000000..fa8206e569
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt String, when StringToBigInt returns NaN
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: String
+ Result:
+ 1. Let n be StringToBigInt(prim).
+ 2. If n is NaN, throw a SyntaxError exception.
+ 3. Return n.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(1);
+
+ assert.throws(SyntaxError, function() {
+ typedArray.set(["definately not a number"]);
+ }, "StringToBigInt(prim) == NaN");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js
new file mode 100644
index 0000000000..5d6221b1ff
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/string-tobigint.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Behavior for input array of Strings, successful conversion
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: String
+ Result:
+ 1. Let n be StringToBigInt(prim).
+ 2. If n is NaN, throw a SyntaxError exception.
+ 3. Return n.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(2);
+ typedArray.set(['', '1'])
+
+ assert.sameValue(typedArray[0], 0n);
+ assert.sameValue(typedArray[1], 1n);
+
+ assert.throws(SyntaxError, function() {
+ typedArray.set(['1n']);
+ }, "A StringNumericLiteral may not include a BigIntLiteralSuffix.");
+
+ assert.throws(SyntaxError, function() {
+ typedArray.set(["Infinity"]);
+ }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity..");
+
+ assert.throws(SyntaxError, function() {
+ typedArray.set(["1.1"]);
+ }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... decimal points...");
+
+ assert.throws(SyntaxError, function() {
+ typedArray.set(["1e7"]);
+ }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... exponents...");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js
new file mode 100644
index 0000000000..a8bdad37af
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/symbol-tobigint.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt on Symbol
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ ToBigInt ( argument )
+
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Symbol
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, Symbol]
+---*/
+
+var s = Symbol()
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(1)
+
+ assert.throws(TypeError, function() {
+ typedArray.set([s]);
+ }, "abrupt completion from Symbol");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js
new file mode 100644
index 0000000000..2e517ead14
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Throw a RangeError exception if targetOffset < 0
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ 7. If targetOffset < 0, throw a RangeError exception.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(RangeError, function() {
+ sample.set(sample, -1);
+ }, "-1");
+
+ assert.throws(RangeError, function() {
+ sample.set(sample, -1.00001);
+ }, "-1.00001");
+
+ assert.throws(RangeError, function() {
+ sample.set(sample, -Infinity);
+ }, "-Infinity");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js
new file mode 100644
index 0000000000..6ea2c61915
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js
@@ -0,0 +1,95 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ ToInteger(offset) operations
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+ var src = new TA([42n]);
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, "");
+ assert(compareArray(sample, [42n, 2n]), "the empty string");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, "0");
+ assert(compareArray(sample, [42n, 2n]), "'0'");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, false);
+ assert(compareArray(sample, [42n, 2n]), "false");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, 0.1);
+ assert(compareArray(sample, [42n, 2n]), "0.1");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, 0.9);
+ assert(compareArray(sample, [42n, 2n]), "0.9");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, -0.5);
+ assert(compareArray(sample, [42n, 2n]), "-0.5");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, 1.1);
+ assert(compareArray(sample, [1n, 42n]), "1.1");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, NaN);
+ assert(compareArray(sample, [42n, 2n]), "NaN");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, null);
+ assert(compareArray(sample, [42n, 2n]), "null");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, undefined);
+ assert(compareArray(sample, [42n, 2n]), "undefined");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, {});
+ assert(compareArray(sample, [42n, 2n]), "{}");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, []);
+ assert(compareArray(sample, [42n, 2n]), "[]");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, [0]);
+ assert(compareArray(sample, [42n, 2n]), "[0]");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, true);
+ assert(compareArray(sample, [1n, 42n]), "true");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, "1");
+ assert(compareArray(sample, [1n, 42n]), "'1'");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, [1]);
+ assert(compareArray(sample, [1n, 42n]), "[1]");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, { valueOf: function() {return 1;} });
+ assert(compareArray(sample, [1n, 42n]), "valueOf");
+
+ sample = new TA([1n, 2n]);
+ sample.set(src, { toString: function() {return 1;} });
+ assert(compareArray(sample, [1n, 42n]), "toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js
new file mode 100644
index 0000000000..8826a30fea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Return abrupt from ToInteger(Symbol offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.set(sample, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js
new file mode 100644
index 0000000000..ba7bd03aa5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Return abrupt from ToInteger(offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.set(sample, obj1);
+ }, "abrupt from valueOf");
+
+ assert.throws(Test262Error, function() {
+ sample.set(sample, obj2);
+ }, "abrupt from toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js
new file mode 100644
index 0000000000..64b050832e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js
@@ -0,0 +1,107 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and different
+ type.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sab = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT);
+ var otherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ var src = new otherCtor(sab);
+ src[0] = 42n;
+ src[1] = 43n;
+ var sample, result;
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ src = new BigInt64Array([42n, 43n]);
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ var sab1 = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT);
+ src = new BigInt64Array(sab1);
+ src[0] = 42n;
+ src[1] = 43n;
+
+ var sab2;
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js
new file mode 100644
index 0000000000..85c1cd33a2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and different
+ type.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ ...
+ 24. Else, let srcByteIndex be srcByteOffset.
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ ...
+ 28. Else,
+ a. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType).
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ value).
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ var src = new other([42n, 43n]);
+ var sample, result;
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js
new file mode 100644
index 0000000000..25222ac4c7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js
@@ -0,0 +1,107 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and same
+ constructor. srcBuffer values are cached.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample, result;
+
+ var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
+ var src = new TA(sab);
+ src[0] = 42n;
+ src[1] = 43n;
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ src = new TA([42n, 43n]);
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+
+ var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
+ src = new TA(sab1);
+ src[0] = 42n;
+ src[1] = 43n;
+
+ var sab2;
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js
new file mode 100644
index 0000000000..95b210ba3a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and same
+ constructor. srcBuffer values are cached.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ ...
+ 24. Else, let srcByteIndex be srcByteOffset.
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ a. NOTE: If srcType and targetType are the same, the transfer must be
+ performed in a manner that preserves the bit-level encoding of the source
+ data.
+ b. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
+ value).
+ ...
+ 29. Return undefined.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample, result;
+ var src = new TA([42n, 43n]);
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js
new file mode 100644
index 0000000000..64cb878109
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js
@@ -0,0 +1,48 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and same
+ constructor when underlying ArrayBuffer has been resized
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var source = new TA(ab);
+ var target = new TA(ab);
+ var expected = [10, 20, 30, 40];
+
+ source[0] = 10n;
+ source[1] = 20n;
+ source[2] = 30n;
+ source[3] = 40n;
+
+ try {
+ ab.resize(BPE * 5);
+ expected = [10n, 20n, 30n, 40n, 0n];
+ } catch (_) {}
+
+ target.set(source);
+ assert(compareArray(target, expected), 'following grow');
+
+ try {
+ ab.resize(BPE * 3);
+ expected = [10n, 20n, 30n];
+ } catch (_) {}
+
+ target.set(source);
+ assert(compareArray(target, expected), 'following shrink');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js
new file mode 100644
index 0000000000..d3c4b75a69
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js
@@ -0,0 +1,52 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and same
+ constructor. srcBuffer values are cached.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, SharedArrayBuffer, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample, src, result, sab;
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [1n, 2n, 3n, 4n]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 1n, 2n, 4n]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1n;
+ sample[1] = 2n;
+ sample[2] = 3n;
+ sample[3] = 4n;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 1n, 2n]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js
new file mode 100644
index 0000000000..98dba8b03d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and same
+ constructor. srcBuffer values are cached.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength,
+ %ArrayBuffer%).
+ b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not
+ have any observable side-effects.
+ ...
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ a. NOTE: If srcType and targetType are the same, the transfer must be
+ performed in a manner that preserves the bit-level encoding of the source
+ data.
+ b. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
+ value).
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample, src, result;
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [1n, 2n, 3n, 4n]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1n, 1n, 2n, 4n]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1n, 2n, 3n, 4n]);
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1n, 2n, 1n, 2n]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js
new file mode 100644
index 0000000000..23a5f1b52f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses typedArray's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot.
+ ...
+ 22. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 42;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42n, 43n]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(src, "length", desc);
+
+ sample.set(src);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js
new file mode 100644
index 0000000000..0925356525
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses typedArray's internal [[ByteOffset]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 21. Let srcByteOffset be typedArray.[[ByteOffset]].
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "byteOffset", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42n, 43n]);
+ var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ var src2 = new other([42n, 43n]);
+ var src3 = new other(sample.buffer, 0, 2);
+
+ Object.defineProperty(TA.prototype, "byteOffset", desc);
+ Object.defineProperty(src, "byteOffset", desc);
+ Object.defineProperty(src2, "byteOffset", desc);
+ Object.defineProperty(src3, "byteOffset", desc);
+
+ sample.set(src);
+ sample.set(src2);
+ sample.set(src3);
+
+ assert.sameValue(getCalls, 0, "ignores byteOffset properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js
new file mode 100644
index 0000000000..ad6a51c6ca
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ If srcLength + targetOffset > targetLength, throw a RangeError exception.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 10. Let targetLength be the value of target's [[ArrayLength]] internal slot.
+ ...
+ 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot.
+ ...
+ 22. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample, src;
+
+ sample = new TA(2);
+ src = new TA(2);
+ assert.throws(RangeError, function() {
+ sample.set(src, 1);
+ }, "2 + 1 > 2");
+
+ sample = new TA(1);
+ src = new TA(2);
+ assert.throws(RangeError, function() {
+ sample.set(src, 0);
+ }, "2 + 0 > 1");
+
+ sample = new TA(1);
+ src = new TA(0);
+ assert.throws(RangeError, function() {
+ sample.set(src, 2);
+ }, "0 + 2 > 1");
+
+ sample = new TA(2);
+ src = new TA(2);
+ assert.throws(RangeError, function() {
+ sample.set(src, Infinity);
+ }, "2 + Infinity > 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js
new file mode 100644
index 0000000000..9d5a06f9cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Throws a TypeError if srcBuffer is detached on ToInteger(offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal
+ slot.
+ 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var target = new TA();
+ var calledOffset = 0;
+ var obj = {
+ valueOf: function() {
+ $DETACHBUFFER(target.buffer);
+ calledOffset += 1;
+ }
+ };
+
+ assert.throws(TypeError, function() {
+ sample.set(target, obj);
+ });
+
+ assert.sameValue(calledOffset, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js
new file mode 100644
index 0000000000..59b3c42d53
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses target's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ 2. Let target be the this value.
+ ...
+ 10. Let targetLength be the value of target's [[ArrayLength]] internal slot.
+ ...
+ 22. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42n, 43n]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.set(src);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js
new file mode 100644
index 0000000000..eee371cf8c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses target's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ 2. Let target be the this value.
+ ...
+ 16. Let targetByteOffset be target.[[ByteOffset]].
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "byteOffset", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42n, 43n]);
+ var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ var src2 = new other([42n, 43n]);
+ var src3 = new other(sample.buffer, 0, 2);
+
+ Object.defineProperty(TA.prototype, "byteOffset", desc);
+ Object.defineProperty(sample, "byteOffset", desc);
+
+ sample.set(src);
+ sample.set(src2);
+ sample.set(src3);
+
+ assert.sameValue(getCalls, 0, "ignores byteoffset properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js
new file mode 100644
index 0000000000..81abb84936
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js
@@ -0,0 +1,46 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: Error when target TypedArray fails boundary checks
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.set,
+ 'function',
+ 'implements TypedArray.prototype.set'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4});
+ var target = new TA(ab, 0, 4);
+ var source = new TA(new ArrayBuffer(BPE * 4));
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 3);
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reverse operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ target.set(source, 0);
+ throw new Test262Error('The `set` operation completed successfully.');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js
new file mode 100644
index 0000000000..feb05e05f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Throws a TypeError if targetBuffer is detached on ToInteger(offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal
+ slot.
+ 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA(1);
+ var calledOffset = 0;
+ var obj = {
+ valueOf: function() {
+ $DETACHBUFFER(sample.buffer);
+ calledOffset += 1;
+ }
+ };
+
+ assert.throws(TypeError, function() {
+ sample.set(src, obj);
+ });
+
+ assert.sameValue(calledOffset, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js
new file mode 100644
index 0000000000..817a873885
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/BigInt/undefined-tobigint.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Return abrupt on undefined
+info: |
+ %TypedArray%.prototype.set ( array [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the object
+ array. The optional offset value indicates the first element index in this
+ TypedArray where values are written. If omitted, it is assumed to be 0.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. Let value be ? Get(src, Pk).
+ d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array",
+ let value be ? ToBigInt(value).
+ e. Otherwise, let value be ? ToNumber(value).
+ f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumbervalue, true, "Unordered").
+ h. Set k to k + 1.
+ i. Set targetByteIndex to targetByteIndex + targetElementSize.
+ ...
+
+ ToBigInt ( argument )
+ Object, Apply the following steps:
+ 1. Let prim be ? ToPrimitive(argument, hint Number).
+ 2. Return the value that prim corresponds to in Table [BigInt Conversions]
+
+ BigInt Conversions
+ Argument Type: Undefined
+ Result: Throw a TypeError exception.
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(1);
+
+ assert.throws(TypeError, function() {
+ typedArray.set([undefined]);
+ }, "abrupt completion from undefined");
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js
new file mode 100644
index 0000000000..a181191cc9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Throw a RangeError exception if targetOffset < 0
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ 7. If targetOffset < 0, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(4);
+
+ assert.throws(RangeError, function() {
+ sample.set([1], -1);
+ }, "-1");
+
+ assert.throws(RangeError, function() {
+ sample.set([1], -1.00001);
+ }, "-1.00001");
+
+ assert.throws(RangeError, function() {
+ sample.set([1], -Infinity);
+ }, "-Infinity");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js
new file mode 100644
index 0000000000..dbf9ca1d3f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-offset-tointeger.js
@@ -0,0 +1,97 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ ToInteger(offset) operations
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ 7. If targetOffset < 0, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([1, 2]);
+ sample.set([42], "");
+ assert(compareArray(sample, [42, 2]), "the empty string");
+
+ sample = new TA([1, 2]);
+ sample.set([42], "0");
+ assert(compareArray(sample, [42, 2]), "'0'");
+
+ sample = new TA([1, 2]);
+ sample.set([42], false);
+ assert(compareArray(sample, [42, 2]), "false");
+
+ sample = new TA([1, 2]);
+ sample.set([42], 0.1);
+ assert(compareArray(sample, [42, 2]), "0.1");
+
+ sample = new TA([1, 2]);
+ sample.set([42], 0.9);
+ assert(compareArray(sample, [42, 2]), "0.9");
+
+ sample = new TA([1, 2]);
+ sample.set([42], -0.5);
+ assert(compareArray(sample, [42, 2]), "-0.5");
+
+ sample = new TA([1, 2]);
+ sample.set([42], 1.1);
+ assert(compareArray(sample, [1, 42]), "1.1");
+
+ sample = new TA([1, 2]);
+ sample.set([42], NaN);
+ assert(compareArray(sample, [42, 2]), "NaN");
+
+ sample = new TA([1, 2]);
+ sample.set([42], null);
+ assert(compareArray(sample, [42, 2]), "null");
+
+ sample = new TA([1, 2]);
+ sample.set([42], undefined);
+ assert(compareArray(sample, [42, 2]), "undefined");
+
+ sample = new TA([1, 2]);
+ sample.set([42], {});
+ assert(compareArray(sample, [42, 2]), "{}");
+
+ sample = new TA([1, 2]);
+ sample.set([42], []);
+ assert(compareArray(sample, [42, 2]), "[]");
+
+ sample = new TA([1, 2]);
+ sample.set([42], [0]);
+ assert(compareArray(sample, [42, 2]), "[0]");
+
+ sample = new TA([1, 2]);
+ sample.set([42], true);
+ assert(compareArray(sample, [1, 42]), "true");
+
+ sample = new TA([1, 2]);
+ sample.set([42], "1");
+ assert(compareArray(sample, [1, 42]), "'1'");
+
+ sample = new TA([1, 2]);
+ sample.set([42], [1]);
+ assert(compareArray(sample, [1, 42]), "[1]");
+
+ sample = new TA([1, 2]);
+ sample.set([42], { valueOf: function() {return 1;} });
+ assert(compareArray(sample, [1, 42]), "valueOf");
+
+ sample = new TA([1, 2]);
+ sample.set([42], { toString: function() {return 1;} });
+ assert(compareArray(sample, [1, 42]), "toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js
new file mode 100644
index 0000000000..ed577e2012
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Primitive `array` argument is coerced to an object.
+info: |
+ %TypedArray%.prototype.set ( typedArray [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object
+ with a [[TypedArrayName]] internal slot. If it is such an Object,
+ the definition in 22.2.3.23.2 applies.
+ [...]
+ 14. Let src be ? ToObject(array).
+ 15. Let srcLength be ? LengthOfArrayLike(src).
+ [...]
+ 19. Let limit be targetByteIndex + targetElementSize × srcLength.
+ 20. Repeat, while targetByteIndex < limit,
+ a. Let Pk be ! ToString(k).
+ b. Let value be ? Get(src, Pk).
+ [...]
+ d. Otherwise, set value to ? ToNumber(value).
+ [...]
+ f. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, Unordered).
+ [...]
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, Symbol]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta1 = new TA([1, 2, 3, 4, 5]);
+ ta1.set("678", 1);
+ assert.compareArray(ta1, [1, 6, 7, 8, 5], "string");
+
+ var ta2 = new TA([1, 2, 3]);
+ ta2.set(0);
+ assert.compareArray(ta2, [1, 2, 3], "number");
+
+ var ta3 = new TA([1, 2, 3]);
+ ta3.set(true, 2);
+ assert.compareArray(ta3, [1, 2, 3], "boolean");
+
+ var ta4 = new TA([1]);
+ ta4.set(Symbol());
+ assert.compareArray(ta4, [1], "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js
new file mode 100644
index 0000000000..cfbf10dbea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt getting src "length"
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {};
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 3]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js
new file mode 100644
index 0000000000..bec35b327b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from getting src property value
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var obj = {
+ length: 4,
+ "0": 42,
+ "1": 43,
+ "3": 44
+ };
+ Object.defineProperty(obj, "2", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ var sample = new TA([1, 2, 3, 4]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj);
+ });
+
+ assert(
+ compareArray(sample, [42, 43, 3, 4]),
+ "values are set until exception"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js
new file mode 100644
index 0000000000..07c226e5b7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt getting src "length" as symbol
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var obj = {
+ length: Symbol("1")
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 3]);
+
+ assert.throws(TypeError, function() {
+ sample.set(obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js
new file mode 100644
index 0000000000..c046c5c12d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToLength(src "length")
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj1 = {
+ length: {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ }
+};
+
+var obj2 = {
+ length: {
+ toString: function() {
+ throw new Test262Error();
+ }
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 3]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj1);
+ }, "valueOf");
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj2);
+ }, "toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js
new file mode 100644
index 0000000000..ef71d78dd0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToNumber(src property symbol value)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var obj = {
+ length: 4,
+ "0": 42,
+ "1": 43,
+ "2": Symbol("1"),
+ "3": 44
+ };
+
+ var sample = new TA([1, 2, 3, 4]);
+
+ assert.throws(TypeError, function() {
+ sample.set(obj);
+ });
+
+ assert(
+ compareArray(sample, [42, 43, 3, 4]),
+ "values are set until exception"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js
new file mode 100644
index 0000000000..79a87c36b3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToNumber(src property value)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var obj = {
+ length: 4,
+ "0": 42,
+ "1": 43,
+ "2": {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+ },
+ "3": 44
+ };
+
+ var sample = new TA([1, 2, 3, 4]);
+
+ assert.throws(Test262Error, function() {
+ sample.set(obj);
+ });
+
+ assert(
+ compareArray(sample, [42, 43, 3, 4]),
+ "values are set until exception"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js
new file mode 100644
index 0000000000..ae70c2693e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToInteger(Symbol offset)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.set([1], s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js
new file mode 100644
index 0000000000..a2afd09f7e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToInteger(offset)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.set([], obj1);
+ }, "abrupt from valueOf");
+
+ assert.throws(Test262Error, function() {
+ sample.set([], obj2);
+ }, "abrupt from toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js
new file mode 100644
index 0000000000..f479186b51
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Return abrupt from ToObject(array)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 15. Let src be ? ToObject(array).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 3]);
+
+ assert.throws(TypeError, function() {
+ sample.set(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.set(null);
+ }, "null");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js
new file mode 100644
index 0000000000..e74106d4c7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values-in-order.js
@@ -0,0 +1,74 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Get and set each value in order
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(5);
+ var calls = [];
+ var obj = {
+ length: 3
+ };
+ Object.defineProperty(obj, 0, {
+ get: function() {
+ calls.push(0);
+ calls.push(sample.join());
+ return 42;
+ }
+ });
+
+ Object.defineProperty(obj, 1, {
+ get: function() {
+ calls.push(1);
+ calls.push(sample.join());
+ return 43;
+ }
+ });
+
+ Object.defineProperty(obj, 2, {
+ get: function() {
+ calls.push(2);
+ calls.push(sample.join());
+ return 44;
+ }
+ });
+
+ Object.defineProperty(obj, 3, {
+ get: function() {
+ throw new Test262Error("Should not call obj[3]");
+ }
+ });
+
+ sample.set(obj, 1);
+
+ assert(
+ compareArray(sample, [0, 42, 43, 44, 0]),
+ "values are set for src length"
+ );
+
+ assert(
+ compareArray(calls, [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]),
+ "values are set in order"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js
new file mode 100644
index 0000000000..4a5c4acb8a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-set-values.js
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Set values to target and return undefined
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ Let Pk be ! ToString(k).
+ Let kNumber be ? ToNumber(? Get(src, Pk)).
+ If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber).
+ ...
+ 22. Return undefined.
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var src = [42, 43];
+ var srcObj = {
+ length: 2,
+ '0': 7,
+ '1': 17
+ };
+ var sample, result;
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(srcObj, 0);
+ assert(compareArray(sample, [7, 17, 3, 4]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(srcObj, 1);
+ assert(compareArray(sample, [1, 7, 17, 4]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(srcObj, 2);
+ assert(compareArray(sample, [1, 2, 7, 17]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js
new file mode 100644
index 0000000000..fe4bef4fe0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Values conversions on ToNumber(src property value)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [byteConversionValues.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
+ var sample = new TA([initial]);
+
+ sample.set([value]);
+
+ assert.sameValue(sample[0], expected, "["+value+"] => ["+expected +"]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js
new file mode 100644
index 0000000000..135588343b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Type conversions on ToNumber(src property value)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var obj1 = {
+ valueOf: function() {
+ return 42;
+ }
+ };
+
+ var obj2 = {
+ toString: function() {
+ return "42";
+ }
+ };
+
+ var arr = ["1", "", false, true, null, obj1, obj2, [], [1]];
+
+ var sample = new TA(arr.length);
+ var expected = new TA([1, 0, 0, 1, 0, 42, 42, 0, 1]);
+
+ sample.set(arr);
+
+ assert(
+ compareArray(sample, expected),
+ "sample: [" + sample + "], expected: [" + expected + "]"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js
new file mode 100644
index 0000000000..b2440a89db
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Values from src array are not cached
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 21. Repeat, while targetByteIndex < limit
+ a. Let Pk be ! ToString(k).
+ b. Let kNumber be ? ToNumber(? Get(src, Pk)).
+ c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ kNumber).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(5);
+ var obj = {
+ length: 5,
+ '1': 7,
+ '2': 7,
+ '3': 7,
+ '4': 7
+ };
+ Object.defineProperty(obj, 0, {
+ get: function() {
+ obj[1] = 43;
+ obj[2] = 44;
+ obj[3] = 45;
+ obj[4] = 46;
+ return 42;
+ }
+ });
+
+ sample.set(obj);
+
+ assert(compareArray(sample, [42, 43, 44, 45, 46]));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js
new file mode 100644
index 0000000000..8992c3eb34
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Uses target's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 10. Let targetLength be the value of target's [[ArrayLength]] internal slot.
+ ...
+ 17. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.set([42, 43]);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js
new file mode 100644
index 0000000000..e67af3acb5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2022 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Does not throw if target TA is detached mid-iteration
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 2, 3]);
+ var obj = {
+ length: 3,
+ "0": 42
+ };
+ Object.defineProperty(obj, 1, {
+ get: function() {
+ $DETACHBUFFER(sample.buffer);
+ }
+ });
+ let get2Called = false;
+ Object.defineProperty(obj, 2, {
+ get: function() {
+ get2Called = true;
+ return 2;
+ }
+ });
+
+ sample.set(obj);
+
+ assert.sameValue(true, get2Called);
+ assert.sameValue(0, sample.byteLength);
+ assert.sameValue(0, sample.byteOffset);
+ assert.sameValue(0, sample.length);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js
new file mode 100644
index 0000000000..8cf8a6ffb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Throws a TypeError if targetBuffer is detached on ToInteger(offset)
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal
+ slot.
+ 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calledOffset = 0;
+ var obj = {
+ valueOf: function() {
+ $DETACHBUFFER(sample.buffer);
+ calledOffset += 1;
+ }
+ };
+
+ assert.throws(TypeError, function() {
+ sample.set([1], obj);
+ });
+
+ assert.sameValue(calledOffset, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js
new file mode 100644
index 0000000000..aaf0b2ef01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-array-offset
+description: >
+ Throws a TypeError if targetBuffer is detached
+info: |
+ 22.2.3.23.1 %TypedArray%.prototype.set (array [ , offset ] )
+
+ 1. Assert: array is any ECMAScript language value other than an Object with a
+ [[TypedArrayName]] internal slot. If it is such an Object, the definition in
+ 22.2.3.23.2 applies.
+ ...
+ 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal
+ slot.
+ 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ ...
+ 15. Let src be ? ToObject(array).
+ 16. Let srcLength be ? ToLength(? Get(src, "length")).
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var obj = {};
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ $DETACHBUFFER(sample.buffer);
+
+ assert.throws(TypeError, function() {
+ sample.set([1]);
+ }, "regular check");
+
+ assert.throws(TypeError, function() {
+ sample.set(obj);
+ }, "IsDetachedBuffer happens before Get(src.length)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js
new file mode 100644
index 0000000000..7893dca737
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/bit-precision.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set.2
+description: Preservation of bit-level encoding
+info: |
+ [...]
+ 28. Else,
+ a. NOTE: If srcType and targetType are the same, the transfer must be
+ performed in a manner that preserves the bit-level encoding of the
+ source data.
+ b. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
+ value).
+ iii. Set srcByteIndex to srcByteIndex + 1.
+ iv. Set targetByteIndex to targetByteIndex + 1.
+includes: [nans.js, compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+function body(FA) {
+ var source = new FA(NaNs);
+ var target = new FA(NaNs.length);
+ var sourceBytes, targetBytes;
+
+ target.set(source);
+
+ sourceBytes = new Uint8Array(source.buffer);
+ targetBytes = new Uint8Array(target.buffer);
+
+ assert(compareArray(sourceBytes, targetBytes))
+}
+
+testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js
new file mode 100644
index 0000000000..3201477ce0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-func.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.22 %TypedArray%.prototype.set ( overloaded [ , offset ])
+
+ This function is not generic. The this value must be an object with a
+ [[TypedArrayName]] internal slot.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var set = TypedArray.prototype.set;
+
+assert.sameValue(typeof set, 'function');
+
+assert.throws(TypeError, function() {
+ set();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js
new file mode 100644
index 0000000000..9636b4a1de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/invoked-as-method.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.22 %TypedArray%.prototype.set ( overloaded [ , offset ])
+
+ This function is not generic. The this value must be an object with a
+ [[TypedArrayName]] internal slot.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.set, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.set();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js
new file mode 100644
index 0000000000..83ece00244
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set
+description: >
+ %TypedArray%.prototype.set.length is 1.
+info: |
+ %TypedArray%.prototype.set ( overloaded [ , offset ])
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.set.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.set, "length");
+verifyNotWritable(TypedArray.prototype.set, "length");
+verifyConfigurable(TypedArray.prototype.set, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js
new file mode 100644
index 0000000000..cdaf0d8382
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set
+description: >
+ %TypedArray%.prototype.set.name is "set".
+info: |
+ %TypedArray%.prototype.set ( overloaded [ , offset ])
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.set.name, "set");
+
+verifyNotEnumerable(TypedArray.prototype.set, "name");
+verifyNotWritable(TypedArray.prototype.set, "name");
+verifyConfigurable(TypedArray.prototype.set, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js
new file mode 100644
index 0000000000..818ea73dbd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.set does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.set),
+ false,
+ 'isConstructor(TypedArray.prototype.set) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.set([0], 0);
+}, '`let u8 = new Uint8Array(1); new u8.set([0], 0)` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js
new file mode 100644
index 0000000000..6c78673324
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set
+description: >
+ "set" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'set');
+verifyWritable(TypedArrayPrototype, 'set');
+verifyConfigurable(TypedArrayPrototype, 'set');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/shell.js
new file mode 100644
index 0000000000..b8ead56aef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/shell.js
@@ -0,0 +1,66 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
+
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js
new file mode 100644
index 0000000000..bd388c9953
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/src-typedarray-big-throws.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ If typedArray set argument is a Big(U)Int, and target not "Big", throw
+info: |
+ %TypedArray%.prototype.set( typedArray [ , offset ] )
+ Sets multiple values in this TypedArray, reading the values from the
+ typedArray argument object. The optional offset value indicates the first
+ element index in this TypedArray where values are written. If omitted, it
+ is assumed to be 0.
+ ...
+ 23. If one of srcType and targetType contains the substring "Big" and the
+ other does not, throw a TypeError exception.
+ ...
+
+includes: [testBigIntTypedArray.js, testTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var bigTypedArray;
+var littleTypedArray;
+
+testWithBigIntTypedArrayConstructors(function(BTA) {
+
+ bigTypedArray = new BTA([1n]);
+
+ testWithTypedArrayConstructors(function(TA) {
+
+ littleTypedArray = new TA(1);
+ assert.throws(TypeError, function() {
+ littleTypedArray.set(bigTypedArray);
+ });
+ });
+
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js
new file mode 100644
index 0000000000..d8b62e11a2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-object.js
@@ -0,0 +1,77 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-overloaded-offset
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.23 %TypedArray%.prototype.set
+
+ ...
+ 2. Let target be the this value.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var set = TypedArray.prototype.set;
+
+assert.throws(TypeError, function() {
+ set.call(undefined, []);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ set.call(null, []);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ set.call(undefined, new Int8Array());
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ set.call(null, new Int8Array());
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ set.call(42, []);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ set.call("1", []);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ set.call(true, []);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ set.call(false, []);
+}, "this is false");
+
+var s1 = Symbol("s");
+assert.throws(TypeError, function() {
+ set.call(s1, []);
+}, "this is a Symbol");
+
+assert.throws(TypeError, function() {
+ set.call(42, new Int8Array(1));
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ set.call("1", new Int8Array(1));
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ set.call(true, new Int8Array(1));
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ set.call(false, new Int8Array(1));
+}, "this is false");
+
+var s2 = Symbol("s");
+assert.throws(TypeError, function() {
+ set.call(s2, new Int8Array(1));
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..fdac8e08cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-overloaded-offset
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.23 %TypedArray%.prototype.set
+
+ ...
+ 2. Let target be the this value.
+ 3. If Type(target) is not Object, throw a TypeError exception.
+ 4. If target does not have a [[TypedArrayName]] internal slot, throw a
+ TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var set = TypedArray.prototype.set;
+
+assert.throws(TypeError, function() {
+ set.call({}, []);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ set.call([], []);
+}, "this is an Array");
+
+var ab1 = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ set.call(ab1, []);
+}, "this is an ArrayBuffer instance");
+
+var dv1 = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ set.call(dv1, []);
+}, "this is a DataView instance");
+
+assert.throws(TypeError, function() {
+ set.call({}, new Int8Array());
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ set.call([], new Int8Array());
+}, "this is an Array");
+
+var ab2 = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ set.call(ab2, new Int8Array());
+}, "this is an ArrayBuffer instance");
+
+var dv2 = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ set.call(dv2, new Int8Array());
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js
new file mode 100644
index 0000000000..26a9ef1064
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Throw a RangeError exception if targetOffset < 0
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ 7. If targetOffset < 0, throw a RangeError exception.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(RangeError, function() {
+ sample.set(sample, -1);
+ }, "-1");
+
+ assert.throws(RangeError, function() {
+ sample.set(sample, -1.00001);
+ }, "-1.00001");
+
+ assert.throws(RangeError, function() {
+ sample.set(sample, -Infinity);
+ }, "-Infinity");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js
new file mode 100644
index 0000000000..e4c73580bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js
@@ -0,0 +1,95 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ ToInteger(offset) operations
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+ var src = new TA([42]);
+
+ sample = new TA([1, 2]);
+ sample.set(src, "");
+ assert(compareArray(sample, [42, 2]), "the empty string");
+
+ sample = new TA([1, 2]);
+ sample.set(src, "0");
+ assert(compareArray(sample, [42, 2]), "'0'");
+
+ sample = new TA([1, 2]);
+ sample.set(src, false);
+ assert(compareArray(sample, [42, 2]), "false");
+
+ sample = new TA([1, 2]);
+ sample.set(src, 0.1);
+ assert(compareArray(sample, [42, 2]), "0.1");
+
+ sample = new TA([1, 2]);
+ sample.set(src, 0.9);
+ assert(compareArray(sample, [42, 2]), "0.9");
+
+ sample = new TA([1, 2]);
+ sample.set(src, -0.5);
+ assert(compareArray(sample, [42, 2]), "-0.5");
+
+ sample = new TA([1, 2]);
+ sample.set(src, 1.1);
+ assert(compareArray(sample, [1, 42]), "1.1");
+
+ sample = new TA([1, 2]);
+ sample.set(src, NaN);
+ assert(compareArray(sample, [42, 2]), "NaN");
+
+ sample = new TA([1, 2]);
+ sample.set(src, null);
+ assert(compareArray(sample, [42, 2]), "null");
+
+ sample = new TA([1, 2]);
+ sample.set(src, undefined);
+ assert(compareArray(sample, [42, 2]), "undefined");
+
+ sample = new TA([1, 2]);
+ sample.set(src, {});
+ assert(compareArray(sample, [42, 2]), "{}");
+
+ sample = new TA([1, 2]);
+ sample.set(src, []);
+ assert(compareArray(sample, [42, 2]), "[]");
+
+ sample = new TA([1, 2]);
+ sample.set(src, [0]);
+ assert(compareArray(sample, [42, 2]), "[0]");
+
+ sample = new TA([1, 2]);
+ sample.set(src, true);
+ assert(compareArray(sample, [1, 42]), "true");
+
+ sample = new TA([1, 2]);
+ sample.set(src, "1");
+ assert(compareArray(sample, [1, 42]), "'1'");
+
+ sample = new TA([1, 2]);
+ sample.set(src, [1]);
+ assert(compareArray(sample, [1, 42]), "[1]");
+
+ sample = new TA([1, 2]);
+ sample.set(src, { valueOf: function() {return 1;} });
+ assert(compareArray(sample, [1, 42]), "valueOf");
+
+ sample = new TA([1, 2]);
+ sample.set(src, { toString: function() {return 1;} });
+ assert(compareArray(sample, [1, 42]), "toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js
new file mode 100644
index 0000000000..5672695847
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Return abrupt from ToInteger(Symbol offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.set(sample, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js
new file mode 100644
index 0000000000..a5f8f15186
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Return abrupt from ToInteger(offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var obj1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.set(sample, obj1);
+ }, "abrupt from valueOf");
+
+ assert.throws(Test262Error, function() {
+ sample.set(sample, obj2);
+ }, "abrupt from toString");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js
new file mode 100644
index 0000000000..5de73d9b18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js
@@ -0,0 +1,54 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set converted values from different buffer of different types and different type instances
+includes: [byteConversionValues.js, testTypedArray.js]
+features: [SharedArrayBuffer]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
+ if (TA === Float64Array || TA === Float32Array || TA === Uint8ClampedArray) {
+ return;
+ }
+ if (TA === Int32Array) {
+ return;
+ }
+
+ var sab, src, target;
+
+ sab = new SharedArrayBuffer(4);
+ src = new Int32Array(sab);
+ src[0] = value;
+ target = new TA([initial]);
+
+ target.set(src);
+
+ assert.sameValue(target[0], expected, "src is SAB-backed");
+
+ sab = new SharedArrayBuffer(4);
+ src = new Int32Array([value]);
+ target = new TA(sab);
+ target[0] = initial;
+
+ target.set(src);
+
+ assert.sameValue(target[0], expected, "target is SAB-backed");
+
+ var sab1 = new SharedArrayBuffer(4);
+ var sab2 = new SharedArrayBuffer(4);
+ src = new Int32Array(sab1);
+ src[0] = value;
+ target = new TA(sab2);
+ target[0] = initial;
+
+ target.set(src);
+
+ assert.sameValue(target[0], expected, "src and target are SAB-backed");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js
new file mode 100644
index 0000000000..8b6f0655ea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set converted values from different buffer and different type instances
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ ...
+ 24. Else, let srcByteIndex be srcByteOffset.
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ ...
+ 28. Else,
+ a. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType).
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ value).
+includes: [byteConversionValues.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
+ if (TA === Float64Array) {
+ return;
+ }
+ var src = new Float64Array([value]);
+ var target = new TA([initial]);
+
+ target.set(src);
+
+ assert.sameValue(target[0], expected);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js
new file mode 100644
index 0000000000..3e289e32ae
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js
@@ -0,0 +1,110 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and different
+ type.
+includes: [testTypedArray.js, compareArray.js]
+features: [SharedArrayBuffer, TypedArray]
+---*/
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(TA) {
+ var other = Int32Array;
+ var sab = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT);
+ var src = new other(sab);
+ src[0] = 42;
+ src[1] = 43;
+ var sample, result;
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+
+ src = new other([42, 43]);
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ var sab1 = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT);
+ src = new other(sab1);
+ src[0] = 42;
+ src[1] = 43;
+
+ var sab2;
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+}, int_views);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js
new file mode 100644
index 0000000000..75dca6862e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and different
+ type.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ ...
+ 24. Else, let srcByteIndex be srcByteOffset.
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ ...
+ 28. Else,
+ a. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType).
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ value).
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var other = TA === Float32Array ? Float64Array : Float32Array;
+ var src = new other([42, 43]);
+ var sample, result;
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js
new file mode 100644
index 0000000000..c7e109ba8d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js
@@ -0,0 +1,110 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and same
+ constructor. srcBuffer values are cached.
+includes: [testTypedArray.js, compareArray.js]
+features: [SharedArrayBuffer, TypedArray]
+---*/
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, result;
+
+ var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
+ var src = new TA(sab);
+ src[0] = 42;
+ src[1] = 43;
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+
+ src = new TA([42, 43]);
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+
+ var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
+ src = new TA(sab1);
+ src[0] = 42;
+ src[1] = 43;
+
+ var sab2;
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+}, int_views);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js
new file mode 100644
index 0000000000..1990f48b7d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and same
+ constructor. srcBuffer values are cached.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ ...
+ 24. Else, let srcByteIndex be srcByteOffset.
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ a. NOTE: If srcType and targetType are the same, the transfer must be
+ performed in a manner that preserves the bit-level encoding of the source
+ data.
+ b. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
+ value).
+ ...
+ 29. Return undefined.
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, result;
+ var src = new TA([42, 43]);
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js
new file mode 100644
index 0000000000..bd07bc9d42
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and different
+ constructor.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength,
+ %ArrayBuffer%).
+ b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not
+ have any observable side-effects.
+ ...
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ ...
+ 28. Else,
+ a. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType).
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType,
+ value).
+ ...
+ 29. Return undefined.
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var expected = {
+ Float64Array: [1.0000002464512363, 42, 1.875, 4, 5, 6, 7, 8],
+ Float32Array: [0, 42, 512.0001220703125, 4, 5, 6, 7, 8],
+ Int32Array: [1109917696, 42, 0, 4, 5, 6, 7, 8],
+ Int16Array: [0, 42, 0, 4, 5, 6, 7, 8],
+ Int8Array: [0, 42, 0, 66, 5, 6, 7, 8],
+ Uint32Array: [1109917696, 42, 0, 4, 5, 6, 7, 8],
+ Uint16Array: [0, 42, 0, 4, 5, 6, 7, 8],
+ Uint8Array: [0, 42, 0, 66, 5, 6, 7, 8],
+ Uint8ClampedArray: [0, 42, 0, 66, 5, 6, 7, 8]
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var other = TA === Float32Array ? Float64Array : Float32Array;
+
+ var sample = new TA([1, 2, 3, 4, 5, 6, 7, 8]);
+ var src = new other(sample.buffer, 0, 2);
+
+ // Reflect changes on sample object
+ src[0] = 42;
+
+ var result = sample.set(src, 1);
+
+ assert(compareArray(sample, expected[TA.name]), sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js
new file mode 100644
index 0000000000..7cd1411226
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js
@@ -0,0 +1,48 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and same
+ constructor when underlying ArrayBuffer has been resized
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var source = new TA(ab);
+ var target = new TA(ab);
+ var expected = [10, 20, 30, 40];
+
+ source[0] = 10;
+ source[1] = 20;
+ source[2] = 30;
+ source[3] = 40;
+
+ try {
+ ab.resize(BPE * 5);
+ expected = [10, 20, 30, 40, 0];
+ } catch (_) {}
+
+ target.set(source);
+ assert(compareArray(target, expected), 'following grow');
+
+ try {
+ ab.resize(BPE * 3);
+ expected = [10, 20, 30];
+ } catch (_) {}
+
+ target.set(source);
+ assert(compareArray(target, expected), 'following shrink');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js
new file mode 100644
index 0000000000..40cf0eecb5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js
@@ -0,0 +1,54 @@
+// |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and same
+ constructor. srcBuffer values are cached.
+includes: [testTypedArray.js, compareArray.js]
+features: [SharedArrayBuffer, TypedArray]
+---*/
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, src, result, sab;
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 1, 2]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+}, int_views);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js
new file mode 100644
index 0000000000..25a20358b0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and same
+ constructor. srcBuffer values are cached.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 23. If SameValue(srcBuffer, targetBuffer) is true, then
+ a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength,
+ %ArrayBuffer%).
+ b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not
+ have any observable side-effects.
+ ...
+ ...
+ 27. If SameValue(srcType, targetType) is true, then,
+ a. NOTE: If srcType and targetType are the same, the transfer must be
+ performed in a manner that preserves the bit-level encoding of the source
+ data.
+ b. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
+ value).
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, src, result;
+
+ sample = new TA([1, 2, 3, 4]);
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 1, 2]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js
new file mode 100644
index 0000000000..29e8a8ca3a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses typedArray's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot.
+ ...
+ 22. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 42;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42, 43]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(src, "length", desc);
+
+ sample.set(src);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js
new file mode 100644
index 0000000000..0d9d251568
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses typedArray's internal [[ByteOffset]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 21. Let srcByteOffset be typedArray.[[ByteOffset]].
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "byteOffset", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42, 43]);
+ var differentTA = TA === Uint8Array ? Int8Array : Uint8Array;
+ var src2 = new differentTA([42, 43]);
+ var src3 = new differentTA(sample.buffer, 0, 2);
+
+ Object.defineProperty(TA.prototype, "byteOffset", desc);
+ Object.defineProperty(src, "byteOffset", desc);
+ Object.defineProperty(src2, "byteOffset", desc);
+ Object.defineProperty(src3, "byteOffset", desc);
+
+ sample.set(src);
+ sample.set(src2);
+ sample.set(src3);
+
+ assert.sameValue(getCalls, 0, "ignores byteOffset properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js
new file mode 100644
index 0000000000..4a4af2c71d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ If srcLength + targetOffset > targetLength, throw a RangeError exception.
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 10. Let targetLength be the value of target's [[ArrayLength]] internal slot.
+ ...
+ 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot.
+ ...
+ 22. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, src;
+
+ sample = new TA(2);
+ src = new TA(2);
+ assert.throws(RangeError, function() {
+ sample.set(src, 1);
+ }, "2 + 1 > 2");
+
+ sample = new TA(1);
+ src = new TA(2);
+ assert.throws(RangeError, function() {
+ sample.set(src, 0);
+ }, "2 + 0 > 1");
+
+ sample = new TA(1);
+ src = new TA(0);
+ assert.throws(RangeError, function() {
+ sample.set(src, 2);
+ }, "0 + 2 > 1");
+
+ sample = new TA(2);
+ src = new TA(2);
+ assert.throws(RangeError, function() {
+ sample.set(src, Infinity);
+ }, "2 + Infinity > 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js
new file mode 100644
index 0000000000..a43d522c01
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Throws a TypeError if srcBuffer is detached on ToInteger(offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal
+ slot.
+ 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ var target = new TA();
+ var calledOffset = 0;
+ var obj = {
+ valueOf: function() {
+ $DETACHBUFFER(target.buffer);
+ calledOffset += 1;
+ }
+ };
+
+ assert.throws(TypeError, function() {
+ sample.set(target, obj);
+ });
+
+ assert.sameValue(calledOffset, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js
new file mode 100644
index 0000000000..ae3ef5b834
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses target's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ 2. Let target be the this value.
+ ...
+ 10. Let targetLength be the value of target's [[ArrayLength]] internal slot.
+ ...
+ 22. If srcLength + targetOffset > targetLength, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42, 43]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.set(src);
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js
new file mode 100644
index 0000000000..9e852856ec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Uses target's internal [[ArrayLength]]
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ 2. Let target be the this value.
+ ...
+ 16. Let targetByteOffset be target.[[ByteOffset]].
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "byteOffset", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA([42, 43]);
+ var differentTA = TA === Uint8Array ? Int8Array : Uint8Array;
+ var src2 = new differentTA([42, 43]);
+ var src3 = new differentTA(sample.buffer, 0, 2);
+
+ Object.defineProperty(TA.prototype, "byteOffset", desc);
+ Object.defineProperty(sample, "byteOffset", desc);
+
+ sample.set(src);
+ sample.set(src2);
+ sample.set(src3);
+
+ assert.sameValue(getCalls, 0, "ignores byteoffset properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js
new file mode 100644
index 0000000000..ad541dd74f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js
@@ -0,0 +1,46 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: Error when target TypedArray fails boundary checks
+includes: [testTypedArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.set,
+ 'function',
+ 'implements TypedArray.prototype.set'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4});
+ var target = new TA(ab, 0, 4);
+ var source = new TA(new ArrayBuffer(BPE * 4));
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 3);
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the reverse operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ target.set(source, 0);
+ throw new Test262Error('The `set` operation completed successfully.');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js
new file mode 100644
index 0000000000..521772dfff
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Throws a TypeError if targetBuffer is detached on ToInteger(offset)
+info: |
+ 22.2.3.23.2 %TypedArray%.prototype.set(typedArray [ , offset ] )
+
+ 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not,
+ the definition in 22.2.3.23.1 applies.
+ ...
+ 6. Let targetOffset be ? ToInteger(offset).
+ ...
+ 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal
+ slot.
+ 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var src = new TA(1);
+ var calledOffset = 0;
+ var obj = {
+ valueOf: function() {
+ $DETACHBUFFER(sample.buffer);
+ calledOffset += 1;
+ }
+ };
+
+ assert.throws(TypeError, function() {
+ sample.set(src, obj);
+ });
+
+ assert.sameValue(calledOffset, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/arraylength-internal.js
new file mode 100644
index 0000000000..36be94c8a3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/arraylength-internal.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Use internal ArrayLength instead of getting a length property
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 3. Let len be the value of O's [[ArrayLength]] internal slot.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ var result = sample.slice();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(result[0], 42n);
+ assert.sameValue(result[1], 43n);
+ assert.sameValue(result.hasOwnProperty(2), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js
new file mode 100644
index 0000000000..9bb42ed75b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor (other targetType)
+info: |
+ %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+
+ TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ Let result be ? TypedArrayCreate(constructor, argumentList).
+
+ TypedArrayCreate ( constructor, argumentList )
+
+ Let newTypedArray be ? Construct(constructor, argumentList).
+ Perform ? ValidateTypedArray(newTypedArray).
+
+ ValidateTypedArray ( O )
+ The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
+
+ Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
+ Assert: O has a [[ViewedArrayBuffer]] internal slot.
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ var sample = new TA(1);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ return new other(count);
+ };
+
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js
new file mode 100644
index 0000000000..79ab4f121a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor.
+info: |
+ %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+
+ TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ Let result be ? TypedArrayCreate(constructor, argumentList).
+
+ TypedArrayCreate ( constructor, argumentList )
+
+ Let newTypedArray be ? Construct(constructor, argumentList).
+ Perform ? ValidateTypedArray(newTypedArray).
+
+ ValidateTypedArray ( O )
+ The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
+
+ Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
+ Assert: O has a [[ViewedArrayBuffer]] internal slot.
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample = new TA(1);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ return new TA(count);
+ };
+
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js
new file mode 100644
index 0000000000..91ae52dbe1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during Get custom constructor.
+info: |
+ %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+
+ TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ Let result be ? TypedArrayCreate(constructor, argumentList).
+
+ TypedArrayCreate ( constructor, argumentList )
+
+ Let newTypedArray be ? Construct(constructor, argumentList).
+ Perform ? ValidateTypedArray(newTypedArray).
+
+ ValidateTypedArray ( O )
+ The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
+
+ Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
+ Assert: O has a [[ViewedArrayBuffer]] internal slot.
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample = new TA(1);
+
+ Object.defineProperty(sample, "constructor", {
+ get() {
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ }
+ });
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..61bf6aae07
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError if buffer of object created by custom constructor is detached.
+info: |
+ %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+
+ TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ Let result be ? TypedArrayCreate(constructor, argumentList).
+
+ TypedArrayCreate ( constructor, argumentList )
+
+ Let newTypedArray be ? Construct(constructor, argumentList).
+ Perform ? ValidateTypedArray(newTypedArray).
+
+ ValidateTypedArray ( O )
+ The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
+
+ Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
+ Assert: O has a [[ViewedArrayBuffer]] internal slot.
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample = new TA(1);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ let other = new TA(count);
+ counter++;
+ $DETACHBUFFER(other.buffer);
+ return other;
+ };
+
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js
new file mode 100644
index 0000000000..662fb476a4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Does not throw a TypeError if buffer is detached on custom constructor and
+ count <= 0. Using other targetType.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+ If count > 0, then
+ ...
+ Return A
+
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample, result, Other, other;
+ let ctor = {};
+ ctor[Symbol.species] = function(count) {
+ counter++;
+ Other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+ $DETACHBUFFER(sample.buffer);
+ other = new Other(count);
+ return other;
+ };
+
+ sample = new TA(0);
+ sample.constructor = ctor;
+ result = sample.slice();
+ assert.sameValue(result.length, 0, 'The value of result.length is 0');
+ assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`');
+ assert.sameValue(result.constructor, Other, 'The value of result.constructor is expected to equal the value of Other');
+ assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other');
+ assert.sameValue(counter, 1, 'The value of `counter` is 1');
+
+ sample = new TA(4);
+ sample.constructor = ctor;
+ sample.slice(1, 1); // count = 0;
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js
new file mode 100644
index 0000000000..3d322aedb8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Does not throw a TypeError if buffer is detached on custom constructor and
+ count <= 0. Using same targetType.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+ If count > 0, then
+ ...
+ Return A
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample, result, other;
+ let ctor = {};
+ ctor[Symbol.species] = function(count) {
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ other = new TA(count);
+ return other;
+ };
+
+ sample = new TA(0);
+ sample.constructor = ctor;
+ result = sample.slice();
+ assert.sameValue(result.length, 0, 'The value of result.length is 0');
+ assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`');
+ assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other');
+ assert.sameValue(counter, 1, 'The value of `counter` is 1');
+
+ sample = new TA(4);
+ sample.constructor = ctor;
+ result = sample.slice(1, 1); // count = 0;
+ assert.sameValue(result.length, 0, 'The value of result.length is 0');
+ assert.notSameValue(
+ result.buffer,
+ sample.buffer,
+ 'The value of result.buffer is expected to not equal the value of `sample.buffer`'
+ );
+ assert.sameValue(result.constructor, TA, 'The value of result.constructor is expected to equal the value of TA');
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..0836f833e9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.slice(obj, obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/infinity.js
new file mode 100644
index 0000000000..b0d3248970
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/infinity.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Infinity values on start and end
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(
+ compareArray(sample.slice(-Infinity), [40n, 41n, 42n, 43n]),
+ "start == -Infinity"
+ );
+ assert(
+ compareArray(sample.slice(Infinity), []),
+ "start == Infinity"
+ );
+ assert(
+ compareArray(sample.slice(0, -Infinity), []),
+ "end == -Infinity"
+ );
+ assert(
+ compareArray(sample.slice(0, Infinity), [40n, 41n, 42n, 43n]),
+ "end == Infinity"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/minus-zero.js
new file mode 100644
index 0000000000..75c7af3cef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/minus-zero.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: -0 values on start and end
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(
+ compareArray(sample.slice(-0), [40n, 41n, 42n, 43n]),
+ "start == -0"
+ );
+ assert(
+ compareArray(sample.slice(-0, 4), [40n, 41n, 42n, 43n]),
+ "start == -0, end == length"
+ );
+ assert(
+ compareArray(sample.slice(0, -0), []),
+ "start == 0, end == -0"
+ );
+ assert(
+ compareArray(sample.slice(-0, -0), []),
+ "start == -0, end == -0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js
new file mode 100644
index 0000000000..9624a71553
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Result does not import own properties
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice( start , end )
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([41n, 42n, 43n, 44n]);
+ sample.foo = 42;
+
+ var result = sample.slice();
+ assert.sameValue(
+ result.hasOwnProperty("foo"),
+ false,
+ "does not import own property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-different-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-different-length.js
new file mode 100644
index 0000000000..734ff140d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-different-length.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: slice may return a new instance with a smaller length
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ function testRes(result, expected, msg) {
+ assert(compareArray(result, expected), msg + ", result: [" + result + "]");
+ }
+
+ testRes(sample.slice(1), [41n, 42n, 43n], "begin == 1");
+ testRes(sample.slice(2), [42n, 43n], "begin == 2");
+ testRes(sample.slice(3), [43n], "begin == 3");
+
+ testRes(sample.slice(1, 4), [41n, 42n, 43n], "begin == 1, end == length");
+ testRes(sample.slice(2, 4), [42n, 43n], "begin == 2, end == length");
+ testRes(sample.slice(3, 4), [43n], "begin == 3, end == length");
+
+ testRes(sample.slice(0, 1), [40n], "begin == 0, end == 1");
+ testRes(sample.slice(0, 2), [40n, 41n], "begin == 0, end == 2");
+ testRes(sample.slice(0, 3), [40n, 41n, 42n], "begin == 0, end == 3");
+
+ testRes(sample.slice(-1), [43n], "begin == -1");
+ testRes(sample.slice(-2), [42n, 43n], "begin == -2");
+ testRes(sample.slice(-3), [41n, 42n, 43n], "begin == -3");
+
+ testRes(sample.slice(-1, 4), [43n], "begin == -1, end == length");
+ testRes(sample.slice(-2, 4), [42n, 43n], "begin == -2, end == length");
+ testRes(sample.slice(-3, 4), [41n, 42n, 43n], "begin == -3, end == length");
+
+ testRes(sample.slice(0, -1), [40n, 41n, 42n], "begin == 0, end == -1");
+ testRes(sample.slice(0, -2), [40n, 41n], "begin == 0, end == -2");
+ testRes(sample.slice(0, -3), [40n], "begin == 0, end == -3");
+
+ testRes(sample.slice(-0, -1), [40n, 41n, 42n], "begin == -0, end == -1");
+ testRes(sample.slice(-0, -2), [40n, 41n], "begin == -0, end == -2");
+ testRes(sample.slice(-0, -3), [40n], "begin == -0, end == -3");
+
+ testRes(sample.slice(-2, -1), [42n], "length == 4, begin == -2, end == -1");
+ testRes(sample.slice(1, -1), [41n, 42n], "length == 4, begin == 1, end == -1");
+ testRes(sample.slice(1, -2), [41n], "length == 4, begin == 1, end == -2");
+ testRes(sample.slice(2, -1), [42n], "length == 4, begin == 2, end == -1");
+
+ testRes(sample.slice(-1, 5), [43n], "begin == -1, end > length");
+ testRes(sample.slice(-2, 4), [42n, 43n], "begin == -2, end > length");
+ testRes(sample.slice(-3, 4), [41n, 42n, 43n], "begin == -3, end > length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js
new file mode 100644
index 0000000000..33b6407af3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: slice may return a new empty instance
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 0, msg);
+ assert.sameValue(
+ result.hasOwnProperty(0),
+ false,
+ msg + " & result.hasOwnProperty(0) === false"
+ );
+ }
+
+ testRes(sample.slice(4), "begin == length");
+ testRes(sample.slice(5), "begin > length");
+
+ testRes(sample.slice(4, 4), "begin == length, end == length");
+ testRes(sample.slice(5, 4), "begin > length, end == length");
+
+ testRes(sample.slice(4, 5), "begin == length, end > length");
+ testRes(sample.slice(5, 5), "begin > length, end > length");
+
+ testRes(sample.slice(0, 0), "begin == 0, end == 0");
+ testRes(sample.slice(-0, -0), "begin == -0, end == -0");
+ testRes(sample.slice(1, 0), "begin > 0, end == 0");
+ testRes(sample.slice(-1, 0), "being < 0, end == 0");
+
+ testRes(sample.slice(2, 1), "begin > 0, begin < length, begin > end, end > 0");
+ testRes(sample.slice(2, 2), "begin > 0, begin < length, begin == end");
+
+ testRes(sample.slice(2, -2), "begin > 0, begin < length, end == -2");
+
+ testRes(sample.slice(-1, -1), "length = 4, begin == -1, end == -1");
+ testRes(sample.slice(-1, -2), "length = 4, begin == -1, end == -2");
+ testRes(sample.slice(-2, -2), "length = 4, begin == -2, end == -2");
+
+ testRes(sample.slice(0, -4), "begin == 0, end == -length");
+ testRes(sample.slice(-4, -4), "begin == -length, end == -length");
+ testRes(sample.slice(-5, -4), "begin < -length, end == -length");
+
+ testRes(sample.slice(0, -5), "begin == 0, end < -length");
+ testRes(sample.slice(-4, -5), "begin == -length, end < -length");
+ testRes(sample.slice(-5, -5), "begin < -length, end < -length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-same-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-same-length.js
new file mode 100644
index 0000000000..ba42543f08
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/results-with-same-length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: slice may return a new instance with the same length
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 4, msg);
+ assert.sameValue(result[0], 40n, msg + " & result[0] === 40");
+ assert.sameValue(result[1], 41n, msg + " & result[1] === 41");
+ assert.sameValue(result[2], 42n, msg + " & result[2] === 42");
+ assert.sameValue(result[3], 43n, msg + " & result[3] === 43");
+ }
+
+ testRes(sample.slice(0), "begin == 0");
+ testRes(sample.slice(-4), "begin == -srcLength");
+ testRes(sample.slice(-5), "begin < -srcLength");
+
+ testRes(sample.slice(0, 4), "begin == 0, end == srcLength");
+ testRes(sample.slice(-4, 4), "begin == -srcLength, end == srcLength");
+ testRes(sample.slice(-5, 4), "begin < -srcLength, end == srcLength");
+
+ testRes(sample.slice(0, 5), "begin == 0, end > srcLength");
+ testRes(sample.slice(-4, 5), "begin == -srcLength, end > srcLength");
+ testRes(sample.slice(-5, 5), "begin < -srcLength, end > srcLength");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js
new file mode 100644
index 0000000000..248d77ca7c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(end), end is symbol
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.slice(0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js
new file mode 100644
index 0000000000..2f2464e217
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(end)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.slice(0, o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice(0, o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js
new file mode 100644
index 0000000000..250acaeb77
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(start), start is symbol
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 4. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.slice(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js
new file mode 100644
index 0000000000..c3a16ededd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(start)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 4. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.slice(o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice(o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..fc66f5270d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.slice,
+ 'function',
+ 'implements TypedArray.prototype.slice'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.slice(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.slice(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the slice operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.slice(0);
+ throw new Test262Error('slice completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js
new file mode 100644
index 0000000000..d8f5e282b0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Perform regular set if target's uses a different element type
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ 10. Let srcName be the String value of O's [[TypedArrayName]] internal slot.
+ 11. Let srcType be the String value of the Element Type value in Table 50 for
+ srcName.
+ 12. Let targetName be the String value of A's [[TypedArrayName]] internal
+ slot.
+ 13. Let targetType be the String value of the Element Type value in Table 50
+ for targetName.
+ 14. If SameValue(srcType, targetType) is false, then
+ a. Let n be 0.
+ b. Repeat, while k < final
+ i. Let Pk be ! ToString(k).
+ ii. Let kValue be ? Get(O, Pk).
+ iii. Perform ? Set(A, ! ToString(n), kValue, true).
+ iv. Increase k by 1.
+ v. Increase n by 1.
+ ...
+ 16. Return A
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+var arr = [42n, 43n, 44n];
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(arr);
+ var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = other;
+
+ var result = sample.slice();
+
+ assert(compareArray(result, arr), "values are set");
+ assert.notSameValue(result.buffer, sample.buffer, "creates a new buffer");
+ assert.sameValue(result.constructor, other, "used the custom ctor");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..54f18f7e15
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..4d21693aff
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.slice();
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..23f4362f5c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..ca47be61b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.slice();
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..c7ac9ebbbc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..1473ac6565
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(count);
+ };
+
+ sample.slice(1);
+
+ assert.sameValue(result.length, 1, "called with 1 arguments");
+ assert.sameValue(result[0], 2, "[0] is the new length count");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 0000000000..b04158435c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws a TypeError if new typedArray's length < count
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA();
+ };
+
+ assert.throws(TypeError, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 0000000000..cc0710c91b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Does not throw a TypeError if new typedArray's length >= count
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var customCount, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA(customCount);
+ };
+
+ customCount = 2;
+ result = sample.slice();
+ assert.sameValue(result.length, customCount, "length == count");
+
+ customCount = 5;
+ result = sample.slice();
+ assert.sameValue(result.length, customCount, "length > count");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..6958ed7c40
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Custom @@species constructor may return a totally different TypedArray
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n]);
+ var other = new BigInt64Array([1n, 0n, 1n]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.slice(0, 0);
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..e7ba84ff89
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var ctor = function() {};
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = ctor;
+
+ assert.throws(TypeError, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..4f0c14121e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var calls = 0;
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ calls++;
+ return new TA(count);
+ };
+
+ result = sample.slice(1);
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert(compareArray(result, [41n, 42n]), "expected object");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..79915087cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..1d1a56e0fb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.slice();
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.slice();
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js
new file mode 100644
index 0000000000..91cc5e1409
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.slice();
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-end.js
new file mode 100644
index 0000000000..9bcdadc845
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-end.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: ToInteger(end)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice( start , end )
+
+ ...
+ 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(compareArray(sample.slice(0, false), []), "false");
+ assert(compareArray(sample.slice(0, true), [40n]), "true");
+
+ assert(compareArray(sample.slice(0, NaN), []), "NaN");
+ assert(compareArray(sample.slice(0, null), []), "null");
+ assert(compareArray(sample.slice(0, undefined), [40n, 41n, 42n, 43n]), "undefined");
+
+ assert(compareArray(sample.slice(0, 0.6), []), "0.6");
+ assert(compareArray(sample.slice(0, 1.1), [40n]), "1.1");
+ assert(compareArray(sample.slice(0, 1.5), [40n]), "1.5");
+ assert(compareArray(sample.slice(0, -0.6), []), "-0.6");
+ assert(compareArray(sample.slice(0, -1.1), [40n, 41n, 42n]), "-1.1");
+ assert(compareArray(sample.slice(0, -1.5), [40n, 41n, 42n]), "-1.5");
+
+ assert(compareArray(sample.slice(0, "3"), [40n, 41n, 42n]), "string");
+ assert(
+ compareArray(
+ sample.slice(0, obj),
+ [40n, 41n]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-start.js
new file mode 100644
index 0000000000..fe474a8bcb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/BigInt/tointeger-start.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: ToInteger(begin)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 4. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(compareArray(sample.slice(false), [40n, 41n, 42n, 43n]), "false");
+ assert(compareArray(sample.slice(true), [41n, 42n, 43n]), "true");
+
+ assert(compareArray(sample.slice(NaN), [40n, 41n, 42n, 43n]), "NaN");
+ assert(compareArray(sample.slice(null), [40n, 41n, 42n, 43n]), "null");
+ assert(compareArray(sample.slice(undefined), [40n, 41n, 42n, 43n]), "undefined");
+
+ assert(compareArray(sample.slice(1.1), [41n, 42n, 43n]), "1.1");
+ assert(compareArray(sample.slice(1.5), [41n, 42n, 43n]), "1.5");
+ assert(compareArray(sample.slice(0.6), [40n, 41n, 42n, 43n]), "0.6");
+
+ assert(compareArray(sample.slice(-1.5), [43n]), "-1.5");
+ assert(compareArray(sample.slice(-1.1), [43n]), "-1.1");
+ assert(compareArray(sample.slice(-0.6), [40n, 41n, 42n, 43n]), "-0.6");
+
+ assert(compareArray(sample.slice("3"), [43n]), "string");
+ assert(
+ compareArray(
+ sample.slice(obj),
+ [42n, 43n]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js
new file mode 100644
index 0000000000..6a7431fdd4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/arraylength-internal.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Use internal ArrayLength instead of getting a length property
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 3. Let len be the value of O's [[ArrayLength]] internal slot.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ var result = sample.slice();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(result[0], 42);
+ assert.sameValue(result[1], 43);
+ assert.sameValue(result.hasOwnProperty(2), false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js
new file mode 100644
index 0000000000..1b4348e330
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/bit-precision.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Preservation of bit-level encoding
+info: |
+ [...]
+ 15. Else if count > 0, then
+ [...]
+ e. NOTE: If srcType and targetType are the same, the transfer must be
+ performed in a manner that preserves the bit-level encoding of the
+ source data.
+ f. Let srcByteOffet be the value of O's [[ByteOffset]] internal slot.
+ g. Let targetByteIndex be A's [[ByteOffset]] internal slot.
+ h. Let srcByteIndex be (k × elementSize) + srcByteOffet.
+ i. Let limit be targetByteIndex + count × elementSize.
+ j. Repeat, while targetByteIndex < limit
+ i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8").
+ ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8",
+ value).
+ iii. Increase srcByteIndex by 1.
+ iv. Increase targetByteIndex by 1.
+includes: [nans.js, compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+function body(FloatArray) {
+ var subject = new FloatArray(NaNs);
+ var sliced, subjectBytes, slicedBytes;
+
+ sliced = subject.slice();
+
+ subjectBytes = new Uint8Array(subject.buffer);
+ slicedBytes = new Uint8Array(sliced.buffer);
+
+ assert(compareArray(subjectBytes, slicedBytes));
+}
+
+testWithTypedArrayConstructors(body, [Float32Array, Float64Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js
new file mode 100644
index 0000000000..98e67832dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. Using other
+ targetType
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+ If count > 0, then
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ var sample = new TA(1);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ var other = TA === Int8Array ? Int16Array : Int8Array;
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ return new other(count);
+ };
+
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js
new file mode 100644
index 0000000000..cff4bdfe80
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached on Get custom constructor.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+ If count > 0, then
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample = new TA(1);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ return new TA(count);
+ };
+
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js
new file mode 100644
index 0000000000..def685a2d6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-get-ctor.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+ If count > 0, then
+ If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample = new TA(1);
+
+ Object.defineProperty(sample, "constructor", {
+ get() {
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ }
+ });
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..bc4ddecd6e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError if buffer of object created by custom constructor is detached.
+info: |
+ %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+
+ TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ Let result be ? TypedArrayCreate(constructor, argumentList).
+
+ TypedArrayCreate ( constructor, argumentList )
+
+ Let newTypedArray be ? Construct(constructor, argumentList).
+ Perform ? ValidateTypedArray(newTypedArray).
+
+ ValidateTypedArray ( O )
+ The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
+
+ Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
+ Assert: O has a [[ViewedArrayBuffer]] internal slot.
+ Let buffer be O.[[ViewedArrayBuffer]].
+ If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample = new TA(1);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ let other = new TA(count);
+ counter++;
+ $DETACHBUFFER(other.buffer);
+ return other;
+ };
+
+ assert.throws(TypeError, function() {
+ counter++;
+ sample.slice();
+ }, '`sample.slice()` throws TypeError');
+
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js
new file mode 100644
index 0000000000..df223edad8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Does not throw a TypeError if buffer is detached on custom constructor and
+ count <= 0. Using other targetType.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+ If count > 0, then
+ ...
+ Return A
+
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample, result, Other, other;
+ let ctor = {};
+ ctor[Symbol.species] = function(count) {
+ counter++;
+ Other = TA === Int16Array ? Int8Array : Int16Array;
+ $DETACHBUFFER(sample.buffer);
+ other = new Other(count);
+ return other;
+ };
+
+ sample = new TA(0);
+ sample.constructor = ctor;
+ result = sample.slice();
+ assert.sameValue(result.length, 0, 'The value of result.length is 0');
+ assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`');
+ assert.sameValue(result.constructor, Other, 'The value of result.constructor is expected to equal the value of Other');
+ assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other');
+ assert.sameValue(counter, 1, 'The value of `counter` is 1');
+
+ sample = new TA(4);
+ sample.constructor = ctor;
+ sample.slice(1, 1); // count = 0;
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js
new file mode 100644
index 0000000000..d6e018010a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Does not throw a TypeError if buffer is detached on custom constructor and
+ count <= 0. Using other targetType.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ Let A be ? TypedArraySpeciesCreate(O, « count »).
+ If count > 0, then
+ ...
+ Return A
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ let counter = 0;
+ let sample, result, other;
+ let ctor = {};
+ ctor[Symbol.species] = function(count) {
+ counter++;
+ $DETACHBUFFER(sample.buffer);
+ other = new TA(count);
+ return other;
+ };
+
+ sample = new TA(0);
+ sample.constructor = ctor;
+ result = sample.slice();
+ assert.sameValue(result.length, 0, 'The value of result.length is 0');
+ assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`');
+ assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other');
+ assert.sameValue(counter, 1, 'The value of `counter` is 1');
+
+ sample = new TA(4);
+ sample.constructor = ctor;
+ sample.slice(1, 1); // count = 0;
+ assert.sameValue(counter, 2, 'The value of `counter` is 2');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js
new file mode 100644
index 0000000000..f89105dfce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/detached-buffer.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.slice(obj, obj);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js
new file mode 100644
index 0000000000..4d4e53a76f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/infinity.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Infinity values on start and end
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(
+ compareArray(sample.slice(-Infinity), [40, 41, 42, 43]),
+ "start == -Infinity"
+ );
+ assert(
+ compareArray(sample.slice(Infinity), []),
+ "start == Infinity"
+ );
+ assert(
+ compareArray(sample.slice(0, -Infinity), []),
+ "end == -Infinity"
+ );
+ assert(
+ compareArray(sample.slice(0, Infinity), [40, 41, 42, 43]),
+ "end == Infinity"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js
new file mode 100644
index 0000000000..c41db512d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.23 %TypedArray%.prototype.slice ( start, end )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var slice = TypedArray.prototype.slice;
+
+assert.sameValue(typeof slice, 'function');
+
+assert.throws(TypeError, function() {
+ slice();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js
new file mode 100644
index 0000000000..abbf41b1bb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.23 %TypedArray%.prototype.slice ( start, end )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.slice, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.slice();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js
new file mode 100644
index 0000000000..b4dc6292c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ %TypedArray%.prototype.slice.length is 2.
+info: |
+ %TypedArray%.prototype.slice ( start, end )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.slice.length, 2);
+
+verifyNotEnumerable(TypedArray.prototype.slice, "length");
+verifyNotWritable(TypedArray.prototype.slice, "length");
+verifyConfigurable(TypedArray.prototype.slice, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js
new file mode 100644
index 0000000000..cec3ea1260
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/minus-zero.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: -0 values on start and end
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(
+ compareArray(sample.slice(-0), [40, 41, 42, 43]),
+ "start == -0"
+ );
+ assert(
+ compareArray(sample.slice(-0, 4), [40, 41, 42, 43]),
+ "start == -0, end == length"
+ );
+ assert(
+ compareArray(sample.slice(0, -0), []),
+ "start == 0, end == -0"
+ );
+ assert(
+ compareArray(sample.slice(-0, -0), []),
+ "start == -0, end == -0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js
new file mode 100644
index 0000000000..0065064c4f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ %TypedArray%.prototype.slice.name is "slice".
+info: |
+ %TypedArray%.prototype.slice ( start, end )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.slice.name, "slice");
+
+verifyNotEnumerable(TypedArray.prototype.slice, "name");
+verifyNotWritable(TypedArray.prototype.slice, "name");
+verifyConfigurable(TypedArray.prototype.slice, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js
new file mode 100644
index 0000000000..c22277eea3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.slice does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.slice),
+ false,
+ 'isConstructor(TypedArray.prototype.slice) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.slice();
+}, '`let u8 = new Uint8Array(1); new u8.slice()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js
new file mode 100644
index 0000000000..7866448d95
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ "slice" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'slice');
+verifyWritable(TypedArrayPrototype, 'slice');
+verifyConfigurable(TypedArrayPrototype, 'slice');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js
new file mode 100644
index 0000000000..ca5360e87e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Result does not import own properties
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice( start , end )
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([41, 42, 43, 44]);
+ sample.foo = 42;
+
+ var result = sample.slice();
+ assert.sameValue(
+ result.hasOwnProperty("foo"),
+ false,
+ "does not import own property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js
new file mode 100644
index 0000000000..21507d93fd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-different-length.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: slice may return a new instance with a smaller length
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ function testRes(result, expected, msg) {
+ assert(compareArray(result, expected), msg + ", result: [" + result + "]");
+ }
+
+ testRes(sample.slice(1), [41, 42, 43], "begin == 1");
+ testRes(sample.slice(2), [42, 43], "begin == 2");
+ testRes(sample.slice(3), [43], "begin == 3");
+
+ testRes(sample.slice(1, 4), [41, 42, 43], "begin == 1, end == length");
+ testRes(sample.slice(2, 4), [42, 43], "begin == 2, end == length");
+ testRes(sample.slice(3, 4), [43], "begin == 3, end == length");
+
+ testRes(sample.slice(0, 1), [40], "begin == 0, end == 1");
+ testRes(sample.slice(0, 2), [40, 41], "begin == 0, end == 2");
+ testRes(sample.slice(0, 3), [40, 41, 42], "begin == 0, end == 3");
+
+ testRes(sample.slice(-1), [43], "begin == -1");
+ testRes(sample.slice(-2), [42, 43], "begin == -2");
+ testRes(sample.slice(-3), [41, 42, 43], "begin == -3");
+
+ testRes(sample.slice(-1, 4), [43], "begin == -1, end == length");
+ testRes(sample.slice(-2, 4), [42, 43], "begin == -2, end == length");
+ testRes(sample.slice(-3, 4), [41, 42, 43], "begin == -3, end == length");
+
+ testRes(sample.slice(0, -1), [40, 41, 42], "begin == 0, end == -1");
+ testRes(sample.slice(0, -2), [40, 41], "begin == 0, end == -2");
+ testRes(sample.slice(0, -3), [40], "begin == 0, end == -3");
+
+ testRes(sample.slice(-0, -1), [40, 41, 42], "begin == -0, end == -1");
+ testRes(sample.slice(-0, -2), [40, 41], "begin == -0, end == -2");
+ testRes(sample.slice(-0, -3), [40], "begin == -0, end == -3");
+
+ testRes(sample.slice(-2, -1), [42], "length == 4, begin == -2, end == -1");
+ testRes(sample.slice(1, -1), [41, 42], "length == 4, begin == 1, end == -1");
+ testRes(sample.slice(1, -2), [41], "length == 4, begin == 1, end == -2");
+ testRes(sample.slice(2, -1), [42], "length == 4, begin == 2, end == -1");
+
+ testRes(sample.slice(-1, 5), [43], "begin == -1, end > length");
+ testRes(sample.slice(-2, 4), [42, 43], "begin == -2, end > length");
+ testRes(sample.slice(-3, 4), [41, 42, 43], "begin == -3, end > length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js
new file mode 100644
index 0000000000..2b0610a11e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-empty-length.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: slice may return a new empty instance
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 0, msg);
+ assert.sameValue(
+ result.hasOwnProperty(0),
+ false,
+ msg + " & result.hasOwnProperty(0) === false"
+ );
+ }
+
+ testRes(sample.slice(4), "begin == length");
+ testRes(sample.slice(5), "begin > length");
+
+ testRes(sample.slice(4, 4), "begin == length, end == length");
+ testRes(sample.slice(5, 4), "begin > length, end == length");
+
+ testRes(sample.slice(4, 5), "begin == length, end > length");
+ testRes(sample.slice(5, 5), "begin > length, end > length");
+
+ testRes(sample.slice(0, 0), "begin == 0, end == 0");
+ testRes(sample.slice(-0, -0), "begin == -0, end == -0");
+ testRes(sample.slice(1, 0), "begin > 0, end == 0");
+ testRes(sample.slice(-1, 0), "being < 0, end == 0");
+
+ testRes(sample.slice(2, 1), "begin > 0, begin < length, begin > end, end > 0");
+ testRes(sample.slice(2, 2), "begin > 0, begin < length, begin == end");
+
+ testRes(sample.slice(2, -2), "begin > 0, begin < length, end == -2");
+
+ testRes(sample.slice(-1, -1), "length = 4, begin == -1, end == -1");
+ testRes(sample.slice(-1, -2), "length = 4, begin == -1, end == -2");
+ testRes(sample.slice(-2, -2), "length = 4, begin == -2, end == -2");
+
+ testRes(sample.slice(0, -4), "begin == 0, end == -length");
+ testRes(sample.slice(-4, -4), "begin == -length, end == -length");
+ testRes(sample.slice(-5, -4), "begin < -length, end == -length");
+
+ testRes(sample.slice(0, -5), "begin == 0, end < -length");
+ testRes(sample.slice(-4, -5), "begin == -length, end < -length");
+ testRes(sample.slice(-5, -5), "begin < -length, end < -length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js
new file mode 100644
index 0000000000..2d9cb4ac26
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/results-with-same-length.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: slice may return a new instance with the same length
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 4, msg);
+ assert.sameValue(result[0], 40, msg + " & result[0] === 40");
+ assert.sameValue(result[1], 41, msg + " & result[1] === 41");
+ assert.sameValue(result[2], 42, msg + " & result[2] === 42");
+ assert.sameValue(result[3], 43, msg + " & result[3] === 43");
+ }
+
+ testRes(sample.slice(0), "begin == 0");
+ testRes(sample.slice(-4), "begin == -srcLength");
+ testRes(sample.slice(-5), "begin < -srcLength");
+
+ testRes(sample.slice(0, 4), "begin == 0, end == srcLength");
+ testRes(sample.slice(-4, 4), "begin == -srcLength, end == srcLength");
+ testRes(sample.slice(-5, 4), "begin < -srcLength, end == srcLength");
+
+ testRes(sample.slice(0, 5), "begin == 0, end > srcLength");
+ testRes(sample.slice(-4, 5), "begin == -srcLength, end > srcLength");
+ testRes(sample.slice(-5, 5), "begin < -srcLength, end > srcLength");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js
new file mode 100644
index 0000000000..2d73a65949
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(end), end is symbol
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.slice(0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js
new file mode 100644
index 0000000000..a0c21bf198
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-end.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(end)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.slice(0, o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice(0, o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js
new file mode 100644
index 0000000000..5e87198742
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(start), start is symbol
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 4. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.slice(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js
new file mode 100644
index 0000000000..5c9aa7c2d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-start.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from ToInteger(start)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 4. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.slice(o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice(o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..f2a0fa7b94
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.slice,
+ 'function',
+ 'implements TypedArray.prototype.slice'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.slice(0);
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.slice(0);
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the slice operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.slice(0);
+ throw new Test262Error('slice completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js
new file mode 100644
index 0000000000..f9ad9584bd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Perform regular set if target's uses a different element type
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ 10. Let srcName be the String value of O's [[TypedArrayName]] internal slot.
+ 11. Let srcType be the String value of the Element Type value in Table 50 for
+ srcName.
+ 12. Let targetName be the String value of A's [[TypedArrayName]] internal
+ slot.
+ 13. Let targetType be the String value of the Element Type value in Table 50
+ for targetName.
+ 14. If SameValue(srcType, targetType) is false, then
+ a. Let n be 0.
+ b. Repeat, while k < final
+ i. Let Pk be ! ToString(k).
+ ii. Let kValue be ? Get(O, Pk).
+ iii. Perform ? Set(A, ! ToString(n), kValue, true).
+ iv. Increase k by 1.
+ v. Increase n by 1.
+ ...
+ 16. Return A
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+var arr = [42, 43, 44];
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(arr);
+ var other = TA === Int8Array ? Uint8Array : Int8Array;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = other;
+
+ var result = sample.slice();
+
+ assert(compareArray(result, arr), "values are set");
+ assert.notSameValue(result.buffer, sample.buffer, "creates a new buffer");
+ assert.sameValue(result.constructor, other, "used the custom ctor");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..dcf690fb8f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..66551be445
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.slice();
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..6bb0dec7be
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,65 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..91abb251a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.slice();
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..c5e87d9908
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..ec10f87cec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(count);
+ };
+
+ sample.slice(1);
+
+ assert.sameValue(result.length, 1, "called with 1 arguments");
+ assert.sameValue(result[0], 2, "[0] is the new length count");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js
new file mode 100644
index 0000000000..c8544e8c00
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws a TypeError if new typedArray's length < count
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA();
+ };
+
+ assert.throws(TypeError, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js
new file mode 100644
index 0000000000..8b8f45205c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Does not throw a TypeError if new typedArray's length >= count
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ ...
+ 3. If argumentList is a List of a single Number, then
+ a. If the value of newTypedArray's [[ArrayLength]] internal slot <
+ argumentList[0], throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var customCount, result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return new TA(customCount);
+ };
+
+ customCount = 2;
+ result = sample.slice();
+ assert.sameValue(result.length, customCount, "length == count");
+
+ customCount = 5;
+ result = sample.slice();
+ assert.sameValue(result.length, customCount, "length > count");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..fb5bf37410
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Custom @@species constructor may return a totally different TypedArray
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40]);
+ var other = new Int8Array([1, 0, 1]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.slice(0, 0);
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [1, 0, 1]), "the returned object is preserved");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..840a42a507
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var ctor = function() {};
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = ctor;
+
+ assert.throws(TypeError, function() {
+ sample.slice();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..653a5aa24a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+ var calls = 0;
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(count) {
+ calls++;
+ return new TA(count);
+ };
+
+ result = sample.slice(1);
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert(compareArray(result, [41, 42]), "expected object");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..c7a8bba242
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.slice();
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..b50e582639
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.slice();
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.slice();
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js
new file mode 100644
index 0000000000..0fd855cefd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/speciesctor-get-species.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
+ ...
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.slice();
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js
new file mode 100644
index 0000000000..f47390fd8a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-object.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var slice = TypedArray.prototype.slice;
+
+assert.throws(TypeError, function() {
+ slice.call(undefined, 0, 0);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ slice.call(null, 0, 0);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ slice.call(42, 0, 0);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ slice.call("1", 0, 0);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ slice.call(true, 0, 0);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ slice.call(false, 0, 0);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ slice.call(s, 0, 0);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..8844744c09
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var slice = TypedArray.prototype.slice;
+
+assert.throws(TypeError, function() {
+ slice.call({}, 0, 0);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ slice.call([], 0, 0);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ slice.call(ab, 0, 0);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ slice.call(dv, 0, 0);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js
new file mode 100644
index 0000000000..ef3e1975d8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-end.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: ToInteger(end)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice( start , end )
+
+ ...
+ 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ?
+ ToInteger(end).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(compareArray(sample.slice(0, false), []), "false");
+ assert(compareArray(sample.slice(0, true), [40]), "true");
+
+ assert(compareArray(sample.slice(0, NaN), []), "NaN");
+ assert(compareArray(sample.slice(0, null), []), "null");
+ assert(compareArray(sample.slice(0, undefined), [40, 41, 42, 43]), "undefined");
+
+ assert(compareArray(sample.slice(0, 0.6), []), "0.6");
+ assert(compareArray(sample.slice(0, 1.1), [40]), "1.1");
+ assert(compareArray(sample.slice(0, 1.5), [40]), "1.5");
+ assert(compareArray(sample.slice(0, -0.6), []), "-0.6");
+ assert(compareArray(sample.slice(0, -1.1), [40, 41, 42]), "-1.1");
+ assert(compareArray(sample.slice(0, -1.5), [40, 41, 42]), "-1.5");
+
+ assert(compareArray(sample.slice(0, "3"), [40, 41, 42]), "string");
+ assert(
+ compareArray(
+ sample.slice(0, obj),
+ [40, 41]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js
new file mode 100644
index 0000000000..3ebf4087aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/slice/tointeger-start.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.slice
+description: ToInteger(begin)
+info: |
+ 22.2.3.24 %TypedArray%.prototype.slice ( start, end )
+
+ ...
+ 4. Let relativeStart be ? ToInteger(start).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(compareArray(sample.slice(false), [40, 41, 42, 43]), "false");
+ assert(compareArray(sample.slice(true), [41, 42, 43]), "true");
+
+ assert(compareArray(sample.slice(NaN), [40, 41, 42, 43]), "NaN");
+ assert(compareArray(sample.slice(null), [40, 41, 42, 43]), "null");
+ assert(compareArray(sample.slice(undefined), [40, 41, 42, 43]), "undefined");
+
+ assert(compareArray(sample.slice(1.1), [41, 42, 43]), "1.1");
+ assert(compareArray(sample.slice(1.5), [41, 42, 43]), "1.5");
+ assert(compareArray(sample.slice(0.6), [40, 41, 42, 43]), "0.6");
+
+ assert(compareArray(sample.slice(-1.5), [43]), "-1.5");
+ assert(compareArray(sample.slice(-1.1), [43]), "-1.1");
+ assert(compareArray(sample.slice(-0.6), [40, 41, 42, 43]), "-0.6");
+
+ assert(compareArray(sample.slice("3"), [43]), "string");
+ assert(
+ compareArray(
+ sample.slice(obj),
+ [42, 43]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..56fd8d933c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.some(function() {
+ results.push(arguments);
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..072ab7652f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ var results = [];
+
+ sample.some(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42n, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43n, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44n, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..d635b54ae2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.some(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return false;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..1284e54378
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.7 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([7n, 8n]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.some(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - key");
+ assert.sameValue(results[1][1], 1, "results[1][1] - key");
+
+ assert.sameValue(results[0][0], 7n, "results[0][0] - value");
+ assert.sameValue(results[1][0], 8n, "results[1][0] - value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..3480775715
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Throws a TypeError if callbackfn is not callable
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.some();
+ }, "no args");
+
+ assert.throws(TypeError, function() {
+ sample.some(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.some(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.some("abc");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.some(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.some(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.some(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.some(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.some({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.some(sample);
+ }, "same typedArray instance");
+
+ assert.throws(TypeError, function() {
+ sample.some(Symbol("1"));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..d1295d2e0d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().some(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..af120f4266
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+
+ sample.some(function() {
+ return 0;
+ });
+
+ assert.sameValue(sample[0], 40n, "[0] == 40");
+ assert.sameValue(sample[1], 41n, "[1] == 41");
+ assert.sameValue(sample[2], 42n, "[2] == 42");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..c47bb27697
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Returns abrupt from callbackfn
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.some(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..5a43c760f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Reflect.set, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+ var newVal = 0n;
+
+ sample.some(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1n,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7n),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-this.js
new file mode 100644
index 0000000000..1cadb33cd5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/callbackfn-this.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.some(function() {
+ results1.push(this);
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.some(function() {
+ results2.push(this);
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..4ad0d25690
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.some(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..ce99b23118
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.some(function() {
+ calls++;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..193e8a2901
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.some,
+ 'function',
+ 'implements TypedArray.prototype.some'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.some(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.some(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the some operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.some(() => {});
+ throw new Test262Error('some completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js
new file mode 100644
index 0000000000..c9e1ae5199
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Returns false if every callbackfn calls returns a coerced false.
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.some(function() {
+ called++;
+ return val;
+ });
+ assert.sameValue(called, 42, "callbackfn called for each index property");
+ assert.sameValue(result, false, "result is false - " + val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js
new file mode 100644
index 0000000000..68c451481d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Returns true if any callbackfn returns a coerced true.
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ iii. If testResult is true, return true.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+ [
+ true,
+ 1,
+ "test262",
+ s,
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.some(function() {
+ called++;
+ if (called == 1) {
+ return false;
+ }
+ return val;
+ });
+ assert.sameValue(called, 2, "callbackfn called for each index property");
+
+ var msg = "result is true - " + (val === s ? "symbol" : val);
+ assert.sameValue(result, true, msg);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js
new file mode 100644
index 0000000000..38e4c0eade
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/BigInt/values-are-not-cached.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n]);
+
+ sample.some(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42n;
+ }
+
+ assert.sameValue(
+ v, 42n, "method does not cache values before callbackfn calls"
+ );
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..d33d176b86
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ thisArg does not affect callbackfn arguments
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+ var thisArg = ["test262", 0, "ecma262", 0];
+
+ sample.some(function() {
+ results.push(arguments);
+ }, thisArg);
+
+ assert.sameValue(results.length, 3, "results.length");
+ assert.sameValue(thisArg.length, 4, "thisArg.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..ee882504fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ callbackfn arguments
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ var results = [];
+
+ sample.some(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 3, "results.length");
+
+ assert.sameValue(results[0].length, 3, "results[0].length");
+ assert.sameValue(results[0][0], 42, "results[0][0] - kValue");
+ assert.sameValue(results[0][1], 0, "results[0][1] - k");
+ assert.sameValue(results[0][2], sample, "results[0][2] - this");
+
+ assert.sameValue(results[1].length, 3, "results[1].length");
+ assert.sameValue(results[1][0], 43, "results[1][0] - kValue");
+ assert.sameValue(results[1][1], 1, "results[1][1] - k");
+ assert.sameValue(results[1][2], sample, "results[1][2] - this");
+
+ assert.sameValue(results[2].length, 3, "results[2].length");
+ assert.sameValue(results[2][0], 44, "results[2][0] - kValue");
+ assert.sameValue(results[2][1], 2, "results[2][1] - k");
+ assert.sameValue(results[2][2], sample, "results[2][2] - this");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js
new file mode 100644
index 0000000000..101a1b8f27
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-detachbuffer.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Instance buffer can be detached during loop
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var loops = 0;
+ var sample = new TA(2);
+
+ sample.some(function() {
+ if (loops === 0) {
+ $DETACHBUFFER(sample.buffer);
+ }
+ loops++;
+ return false;
+ });
+
+ assert.sameValue(loops, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js
new file mode 100644
index 0000000000..2b72c24ac2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Does not interact over non-integer properties
+info: |
+ 22.2.3.7 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([7, 8]);
+
+ var results = [];
+
+ sample.foo = 42;
+ sample[Symbol("1")] = 43;
+
+ sample.some(function() {
+ results.push(arguments);
+ });
+
+ assert.sameValue(results.length, 2, "results.length");
+
+ assert.sameValue(results[0][1], 0, "results[0][1] - key");
+ assert.sameValue(results[1][1], 1, "results[1][1] - key");
+
+ assert.sameValue(results[0][0], 7, "results[0][0] - value");
+ assert.sameValue(results[1][0], 8, "results[1][0] - value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js
new file mode 100644
index 0000000000..550476faf9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-callable-throws.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Throws a TypeError if callbackfn is not callable
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ assert.throws(TypeError, function() {
+ sample.some();
+ }, "no args");
+
+ assert.throws(TypeError, function() {
+ sample.some(null);
+ }, "null");
+
+ assert.throws(TypeError, function() {
+ sample.some(undefined);
+ }, "undefined");
+
+ assert.throws(TypeError, function() {
+ sample.some("abc");
+ }, "string");
+
+ assert.throws(TypeError, function() {
+ sample.some(1);
+ }, "number");
+
+ assert.throws(TypeError, function() {
+ sample.some(NaN);
+ }, "NaN");
+
+ assert.throws(TypeError, function() {
+ sample.some(false);
+ }, "false");
+
+ assert.throws(TypeError, function() {
+ sample.some(true);
+ }, "true");
+
+ assert.throws(TypeError, function() {
+ sample.some({});
+ }, "{}");
+
+ assert.throws(TypeError, function() {
+ sample.some(sample);
+ }, "same typedArray instance");
+
+ assert.throws(TypeError, function() {
+ sample.some(Symbol("1"));
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js
new file mode 100644
index 0000000000..912e8bb1de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ callbackfn is not called on empty instances
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var called = 0;
+
+ new TA().some(function() {
+ called++;
+ });
+
+ assert.sameValue(called, 0);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js
new file mode 100644
index 0000000000..71389fb57a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-resize.js
@@ -0,0 +1,76 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Instance buffer can be resized during iteration
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, resizable-arraybuffer]
+---*/
+
+// If the host chooses to throw as allowed by the specification, the observed
+// behavior will be identical to the case where `ArrayBuffer.prototype.resize`
+// has not been implemented. The following assertion prevents this test from
+// passing in runtimes which have not implemented the method.
+assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function');
+
+testWithTypedArrayConstructors(function(TA) {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4});
+ var sample = new TA(buffer);
+ var finalElement, expectedElements, expectedIndices, expectedArrays;
+ var elements, indices, arrays, result;
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.some(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(2 * BPE);
+ finalElement = undefined;
+ expectedElements = [0, 0];
+ expectedIndices = [0, 1];
+ expectedArrays = [sample, sample];
+ } catch (_) {
+ finalElement = 0;
+ expectedElements = [0, 0, 0];
+ expectedIndices = [0, 1, 2];
+ expectedArrays = [sample, sample, sample];
+ }
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)');
+ assert.compareArray(indices, [0, 1, 2], 'indices (shrink)');
+ assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)');
+ assert.sameValue(result, false, 'result (shrink)');
+
+ elements = [];
+ indices = [];
+ arrays = [];
+ result = sample.some(function(element, index, array) {
+ if (elements.length === 0) {
+ try {
+ buffer.resize(4 * BPE);
+ } catch (_) {}
+ }
+
+ elements.push(element);
+ indices.push(index);
+ arrays.push(array);
+ return false;
+ });
+
+ assert.compareArray(elements, expectedElements, 'elements (grow)');
+ assert.compareArray(indices, expectedIndices, 'indices (grow)');
+ assert.compareArray(arrays, expectedArrays, 'arrays (grow)');
+ assert.sameValue(result, false, 'result (grow)');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js
new file mode 100644
index 0000000000..3b63658139
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ The callbackfn return does not change the instance
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+
+ sample.some(function() {
+ return 0;
+ });
+
+ assert.sameValue(sample[0], 40, "[0] == 40");
+ assert.sameValue(sample[1], 41, "[1] == 41");
+ assert.sameValue(sample[2], 42, "[2] == 42");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..5aea9d38df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-returns-abrupt.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Returns abrupt from callbackfn
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ assert.throws(Test262Error, function() {
+ sample.some(function() {
+ throw new Test262Error();
+ });
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js
new file mode 100644
index 0000000000..74935314b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Integer indexed values changed during iteration
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [Reflect.set, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+ var newVal = 0;
+
+ sample.some(function(val, i) {
+ if (i > 0) {
+ assert.sameValue(
+ sample[i - 1], newVal - 1,
+ "get the changed value during the loop"
+ );
+ assert.sameValue(
+ Reflect.set(sample, 0, 7),
+ true,
+ "re-set a value for sample[0]"
+ );
+ }
+ assert.sameValue(
+ Reflect.set(sample, i, newVal),
+ true,
+ "set value during iteration"
+ );
+
+ newVal++;
+ });
+
+ assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7");
+ assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1");
+ assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js
new file mode 100644
index 0000000000..fa1d572adb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/callbackfn-this.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ callbackfn `this` value
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ ...
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expected = (function() { return this; })();
+var thisArg = {};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(3);
+
+ var results1 = [];
+
+ sample.some(function() {
+ results1.push(this);
+ });
+
+ assert.sameValue(results1.length, 3, "results1");
+ assert.sameValue(results1[0], expected, "without thisArg - [0]");
+ assert.sameValue(results1[1], expected, "without thisArg - [1]");
+ assert.sameValue(results1[2], expected, "without thisArg - [2]");
+
+ var results2 = [];
+
+ sample.some(function() {
+ results2.push(this);
+ }, thisArg);
+
+ assert.sameValue(results2.length, 3, "results2");
+ assert.sameValue(results2[0], thisArg, "using thisArg - [0]");
+ assert.sameValue(results2[1], thisArg, "using thisArg - [1]");
+ assert.sameValue(results2[2], thisArg, "using thisArg - [2]");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js
new file mode 100644
index 0000000000..45765bd6d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var callbackfn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.some(callbackfn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..28f970779f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ 1. Let O be ? ToObject(this value).
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43]);
+ var calls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.some(function() {
+ calls++;
+ });
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert.sameValue(calls, 2, "iterations are not affected by custom length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js
new file mode 100644
index 0000000000..9041ac22aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-func.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.24 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var some = TypedArray.prototype.some;
+
+assert.sameValue(typeof some, 'function');
+
+assert.throws(TypeError, function() {
+ some();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js
new file mode 100644
index 0000000000..ae1b089198
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/invoked-as-method.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.24 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.some, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.some();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js
new file mode 100644
index 0000000000..c610a9f8a8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ %TypedArray%.prototype.some.length is 1.
+info: |
+ %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.some.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.some, "length");
+verifyNotWritable(TypedArray.prototype.some, "length");
+verifyConfigurable(TypedArray.prototype.some, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js
new file mode 100644
index 0000000000..93e47d5de1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ %TypedArray%.prototype.some.name is "some".
+info: |
+ %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.some.name, "some");
+
+verifyNotEnumerable(TypedArray.prototype.some, "name");
+verifyNotWritable(TypedArray.prototype.some, "name");
+verifyConfigurable(TypedArray.prototype.some, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js
new file mode 100644
index 0000000000..99efaa7776
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.some does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.some),
+ false,
+ 'isConstructor(TypedArray.prototype.some) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.some(() => {});
+}, '`let u8 = new Uint8Array(1); new u8.some(() => {})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js
new file mode 100644
index 0000000000..41d68a78bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ "some" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'some');
+verifyWritable(TypedArrayPrototype, 'some');
+verifyConfigurable(TypedArrayPrototype, 'some');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..39a555e728
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.some,
+ 'function',
+ 'implements TypedArray.prototype.some'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.some(() => {});
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.some(() => {});
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the some operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.some(() => {});
+ throw new Test262Error('some completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js
new file mode 100644
index 0000000000..1cd998f2b5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Returns false if every callbackfn calls returns a coerced false.
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 7. Return true.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+
+ [
+ false,
+ "",
+ 0,
+ -0,
+ NaN,
+ undefined,
+ null
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.some(function() {
+ called++;
+ return val;
+ });
+ assert.sameValue(called, 42, "callbackfn called for each index property");
+ assert.sameValue(result, false, "result is false - " + val);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js
new file mode 100644
index 0000000000..7a8c8100b2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js
@@ -0,0 +1,61 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Returns true if any callbackfn returns a coerced true.
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ...
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ iii. If testResult is true, return true.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(42);
+ [
+ true,
+ 1,
+ "test262",
+ s,
+ {},
+ [],
+ -1,
+ Infinity,
+ -Infinity,
+ 0.1,
+ -0.1
+ ].forEach(function(val) {
+ var called = 0;
+ var result = sample.some(function() {
+ called++;
+ if (called == 1) {
+ return false;
+ }
+ return val;
+ });
+ assert.sameValue(called, 2, "callbackfn called for each index property");
+
+ var msg = "result is true - " + (val === s ? "symbol" : val);
+ assert.sameValue(result, true, msg);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js
new file mode 100644
index 0000000000..408ac5ff28
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var some = TypedArray.prototype.some;
+var callbackfn = function() {};
+
+assert.throws(TypeError, function() {
+ some.call(undefined, callbackfn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ some.call(null, callbackfn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ some.call(42, callbackfn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ some.call("1", callbackfn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ some.call(true, callbackfn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ some.call(false, callbackfn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ some.call(s, callbackfn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..08b3c3b6ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var some = TypedArray.prototype.some;
+var callbackfn = function () {};
+
+assert.throws(TypeError, function() {
+ some.call({}, callbackfn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ some.call([], callbackfn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ some.call(ab, callbackfn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ some.call(dv, callbackfn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js b/js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js
new file mode 100644
index 0000000000..068ba9f1a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/some/values-are-not-cached.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.some
+description: >
+ Integer indexed values are not cached before iteration
+info: |
+ 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] )
+
+ %TypedArray%.prototype.some is a distinct function that implements the same
+ algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this
+ object's [[ArrayLength]] internal slot is accessed in place of performing a
+ [[Get]] of "length".
+
+ 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] )
+
+ ...
+ 6. Repeat, while k < len
+ ..
+ c. If kPresent is true, then
+ i. Let kValue be ? Get(O, Pk).
+ ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44]);
+
+ sample.some(function(v, i) {
+ if (i < sample.length - 1) {
+ sample[i+1] = 42;
+ }
+
+ assert.sameValue(
+ v, 42, "method does not cache values before callbackfn calls"
+ );
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/arraylength-internal.js
new file mode 100644
index 0000000000..9f22698cee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/arraylength-internal.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Use internal ArrayLength instead of getting a length property
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ ...
+ 3. Let len be the value of obj's [[ArrayLength]] internal slot.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 42n, 42n]);
+ getCalls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ var result = sample.sort();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert(
+ compareArray(result, sample),
+ "result is not affected by custom length"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js
new file mode 100644
index 0000000000..87b67132b2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Returns abrupt from comparefn
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+ 2. If the argument comparefn is not undefined, then
+ a. Let v be ? Call(comparefn, undefined, « x, y »).
+ ...
+ ...
+
+ 22.1.3.25 Array.prototype.sort (comparefn)
+
+ The following steps are taken:
+
+ - If an abrupt completion is returned from any of these operations, it is
+ immediately returned as the value of this function.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n, 45n, 46n]);
+ var calls = 0;
+
+ var comparefn = function() {
+ calls += 1;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.sort(comparefn);
+ });
+
+ assert.sameValue(calls, 1, "immediately returned");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js
new file mode 100644
index 0000000000..e1133bb3fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-calls.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: comparefn is called if not undefined
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+ 2. If the argument comparefn is not undefined, then
+ a. Let v be ? Call(comparefn, undefined, « x, y »).
+ ...
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var expectedThis = (function() {
+ return this;
+})();
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 42n, 42n, 42n, 42n]);
+ var calls = [];
+
+ var comparefn = function() {
+ calls.push([this, arguments]);
+ };
+
+ sample.sort(comparefn);
+
+ assert(calls.length > 0, "calls comparefn");
+ calls.forEach(function(args) {
+ assert.sameValue(args[0], expectedThis, "comparefn is called no specific this");
+ assert.sameValue(args[1].length, 2, "comparefn is always called with 2 args");
+ assert.sameValue(args[1][0], 42n, "x is a listed value");
+ assert.sameValue(args[1][0], 42n, "y is a listed value");
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js
new file mode 100644
index 0000000000..ed3575fba8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: >
+ Treats explicit undefined comparefn the same as implicit undefined comparefn
+info: |
+ %TypedArray%.prototype.sort ( comparefn )
+
+ 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
+ ...
+includes: [compareArray.js, testBigIntTypedArray.js]
+features: [TypedArray, BigInt]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ let sample = new TA([42n, 44n, 46n, 43n, 45n]);
+ let explicit = sample.sort(undefined);
+ let implicit = sample.sort();
+
+ assert.compareArray(explicit, [42n, 43n, 44n, 45n, 46n], 'The value of `explicit` is [42n, 43n, 44n, 45n, 46n]');
+ assert.compareArray(implicit, [42n, 43n, 44n, 45n, 46n], 'The value of `implicit` is [42n, 43n, 44n, 45n, 46n]');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js
new file mode 100644
index 0000000000..2c96e3099d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2017 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: throws on a non-undefined non-function
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ Upon entry, the following steps are performed to initialize evaluation
+ of the sort function. These steps are used instead of the entry steps
+ in 22.1.3.25:
+
+ ...
+ 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception.
+ ...
+
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n, 44n, 45n, 46n]);
+
+ assert.throws(TypeError, function() {
+ sample.sort(null);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(true);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(false);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort('');
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(/a/g);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(42);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort([]);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort({});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..5f21eb1dda
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/detached-buffer.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ 1. Let obj be the this value.
+ 2. Let buffer be ? ValidateTypedArray(obj).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var comparefn = function() {
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.sort(comparefn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..dee08240ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.sort,
+ 'function',
+ 'implements TypedArray.prototype.sort'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.sort();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.sort();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the sort operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.sort();
+ throw new Test262Error('sort completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js
new file mode 100644
index 0000000000..813b6d3659
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/return-same-instance.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Returns the same instance
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([2n, 1n]);
+ var result = sample.sort();
+
+ assert.sameValue(sample, result, "without comparefn");
+
+ result = sample.sort(function() { return 0; });
+ assert.sameValue(sample, result, "with comparefn");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js
new file mode 100644
index 0000000000..e610ad58a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: TypedArrays sort does not cast values to String
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+ 2. If the argument comparefn is not undefined, then
+ a. Let v be ? Call(comparefn, undefined, « x, y »).
+ ...
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var toStringCalled = false;
+BigInt.prototype.toString = function() {
+ toStringCalled = true;
+}
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([20n, 100n, 3n]);
+ var result = sample.sort();
+ assert.sameValue(toStringCalled, false, "BigInt.prototype.toString will not be called");
+ assert(compareArray(result, [3n, 20n, 100n]));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js
new file mode 100644
index 0000000000..a56f0c442a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/BigInt/sorted-values.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Sort values to numeric ascending order
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([4n, 3n, 2n, 1n]).sort();
+ assert(compareArray(sample, [1n, 2n, 3n, 4n]), "descending values");
+
+ sample = new TA([3n, 4n, 1n, 2n]).sort();
+ assert(compareArray(sample, [1n, 2n, 3n, 4n]), "mixed numbers");
+
+ sample = new TA([3n, 4n, 3n, 1n, 0n, 1n, 2n]).sort();
+ assert(compareArray(sample, [0n, 1n, 1n, 2n, 3n, 3n, 4n]), "repeating numbers");
+});
+
+var sample = new BigInt64Array([-4n, 3n, 4n, -3n, 2n, -2n, 1n, 0n]).sort();
+assert(compareArray(sample, [-4n, -3n, -2n, 0n, 1n, 2n, 3n, 4n]), "negative values");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js
new file mode 100644
index 0000000000..b11284fb67
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/arraylength-internal.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Use internal ArrayLength instead of getting a length property
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ ...
+ 3. Let len be the value of obj's [[ArrayLength]] internal slot.
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 42, 42]);
+ getCalls = 0;
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ var result = sample.sort();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+ assert(
+ compareArray(result, sample),
+ "result is not affected by custom length"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js
new file mode 100644
index 0000000000..4ec5160af3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-call-throws.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Returns abrupt from comparefn
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+ 2. If the argument comparefn is not undefined, then
+ a. Let v be ? Call(comparefn, undefined, « x, y »).
+ ...
+ ...
+
+ 22.1.3.25 Array.prototype.sort (comparefn)
+
+ The following steps are taken:
+
+ - If an abrupt completion is returned from any of these operations, it is
+ immediately returned as the value of this function.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44, 45, 46]);
+ var calls = 0;
+
+ var comparefn = function() {
+ calls += 1;
+ throw new Test262Error();
+ };
+
+ assert.throws(Test262Error, function() {
+ sample.sort(comparefn);
+ });
+
+ assert.sameValue(calls, 1, "immediately returned");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js
new file mode 100644
index 0000000000..53c60777d9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-calls.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: comparefn is called if not undefined
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+ 2. If the argument comparefn is not undefined, then
+ a. Let v be ? Call(comparefn, undefined, « x, y »).
+ ...
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var expectedThis = (function() {
+ return this;
+})();
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 42, 42, 42, 42]);
+ var calls = [];
+
+ var comparefn = function() {
+ calls.push([this, arguments]);
+ };
+
+ sample.sort(comparefn);
+
+ assert(calls.length > 0, "calls comparefn");
+ calls.forEach(function(args) {
+ assert.sameValue(args[0], expectedThis, "comparefn is called no specific this");
+ assert.sameValue(args[1].length, 2, "comparefn is always called with 2 args");
+ assert.sameValue(args[1][0], 42, "x is a listed value");
+ assert.sameValue(args[1][0], 42, "y is a listed value");
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js
new file mode 100644
index 0000000000..f63e734f2d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-is-undefined.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: >
+ Treats explicit undefined comparefn the same as implicit undefined comparefn
+info: |
+ %TypedArray%.prototype.sort ( comparefn )
+
+ 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
+ ...
+includes: [compareArray.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ let sample = new TA([42, 44, 46, 43, 45]);
+ let explicit = sample.sort(undefined);
+ let implicit = sample.sort();
+
+ assert.compareArray(explicit, [42, 43, 44, 45, 46], 'The value of `explicit` is [42, 43, 44, 45, 46]');
+ assert.compareArray(implicit, [42, 43, 44, 45, 46], 'The value of `implicit` is [42, 43, 44, 45, 46]');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js
new file mode 100644
index 0000000000..8bbdd3bce0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2017 Jordan Harband. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: throws on a non-undefined non-function
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ Upon entry, the following steps are performed to initialize evaluation
+ of the sort function. These steps are used instead of the entry steps
+ in 22.1.3.25:
+
+ ...
+ 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception.
+ ...
+
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([42, 43, 44, 45, 46]);
+
+ assert.throws(TypeError, function() {
+ sample.sort(null);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(true);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(false);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort('');
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(/a/g);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort(42);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort([]);
+ });
+
+ assert.throws(TypeError, function() {
+ sample.sort({});
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js
new file mode 100644
index 0000000000..cb25eab0dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/detached-buffer.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ 1. Let obj be the this value.
+ 2. Let buffer be ? ValidateTypedArray(obj).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var comparefn = function() {
+ throw new Test262Error();
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.sort(comparefn);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js
new file mode 100644
index 0000000000..582fe56c42
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-func.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.25 %TypedArray%.prototype.sort ( comparefn )
+
+ ...
+ This function is not generic. The this value must be an object with a
+ [[TypedArrayName]] internal slot.
+ ...
+
+ 1. Let obj be the this value as the argument.
+ 2. Let buffer be ValidateTypedArray(obj).
+ 3. ReturnIfAbrupt(buffer).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var sort = TypedArray.prototype.sort;
+
+assert.sameValue(typeof sort, 'function');
+
+assert.throws(TypeError, function() {
+ sort();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js
new file mode 100644
index 0000000000..50f84f46dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/invoked-as-method.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.25 %TypedArray%.prototype.sort ( comparefn )
+
+ ...
+ This function is not generic. The this value must be an object with a
+ [[TypedArrayName]] internal slot.
+ ...
+
+ 1. Let obj be the this value as the argument.
+ 2. Let buffer be ValidateTypedArray(obj).
+ 3. ReturnIfAbrupt(buffer).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.sort, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.sort();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js
new file mode 100644
index 0000000000..bb8480eaa4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: >
+ %TypedArray%.prototype.sort.length is 1.
+info: |
+ %TypedArray%.prototype.sort ( comparefn )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.sort.length, 1);
+
+verifyNotEnumerable(TypedArray.prototype.sort, "length");
+verifyNotWritable(TypedArray.prototype.sort, "length");
+verifyConfigurable(TypedArray.prototype.sort, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js
new file mode 100644
index 0000000000..347586ddce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: >
+ %TypedArray%.prototype.sort.name is "sort".
+info: |
+ %TypedArray%.prototype.sort ( comparefn )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.sort.name, "sort");
+
+verifyNotEnumerable(TypedArray.prototype.sort, "name");
+verifyNotWritable(TypedArray.prototype.sort, "name");
+verifyConfigurable(TypedArray.prototype.sort, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js
new file mode 100644
index 0000000000..4814d4a7df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.sort does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.sort),
+ false,
+ 'isConstructor(TypedArray.prototype.sort) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.sort();
+}, '`let u8 = new Uint8Array(1); new u8.sort()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js
new file mode 100644
index 0000000000..8d0d2d273b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: >
+ "sort" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'sort');
+verifyWritable(TypedArrayPrototype, 'sort');
+verifyConfigurable(TypedArrayPrototype, 'sort');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..aa4f91883b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.sort,
+ 'function',
+ 'implements TypedArray.prototype.sort'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.sort();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.sort();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the sort operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.sort();
+ throw new Test262Error('sort completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js
new file mode 100644
index 0000000000..ad1283c0f5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/return-same-instance.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Returns the same instance
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([2, 1]);
+ var result = sample.sort();
+
+ assert.sameValue(sample, result, "without comparefn");
+
+ result = sample.sort(function() { return 0; });
+ assert.sameValue(sample, result, "with comparefn");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js
new file mode 100644
index 0000000000..dcc99bc87c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2018 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: The result of compareFn is immediately passed through ToNumber
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ ...
+ 2. If comparefn is not undefined, then
+ a. Let v be ? ToNumber(? Call(comparefn, undefined, « x, y »)).
+ b. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var ta = new TA(4);
+ var ab = ta.buffer;
+
+ var called = false;
+ ta.sort(function(a, b) {
+ // Detaching the buffer does not cause sort to throw.
+ $DETACHBUFFER(ab);
+ return {
+ [Symbol.toPrimitive]() { called = true; }
+ };
+ });
+
+ assert.sameValue(true, called);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js
new file mode 100644
index 0000000000..82c8d16ad2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: TypedArrays sort does not cast values to String
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+ 2. If the argument comparefn is not undefined, then
+ a. Let v be ? Call(comparefn, undefined, « x, y »).
+ ...
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var toStringCalled = false;
+Number.prototype.toString = function() {
+ toStringCalled = true;
+}
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([20, 100, 3]);
+ var result = sample.sort();
+ assert.sameValue(toStringCalled, false, "Number.prototype.toString will not be called");
+ assert(compareArray(result, [3, 20, 100]), "Default sorting by value");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js
new file mode 100644
index 0000000000..f2928c9e1a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values-nan.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Sort values to numeric ascending order
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+
+ NOTE: Because NaN always compares greater than any other value, NaN property
+ values always sort to the end of the result when comparefn is not provided.
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([2, NaN, NaN, 0, 1]).sort();
+ assert.sameValue(sample[0], 0, "#1 [0]");
+ assert.sameValue(sample[1], 1, "#1 [1]");
+ assert.sameValue(sample[2], 2, "#1 [2]");
+ assert.sameValue(sample[3], NaN, "#1 [3]");
+ assert.sameValue(sample[4], NaN, "#1 [4]");
+
+ sample = new TA([3, NaN, NaN, Infinity, 0, -Infinity, 2]).sort();
+ assert.sameValue(sample[0], -Infinity, "#2 [0]");
+ assert.sameValue(sample[1], 0, "#2 [1]");
+ assert.sameValue(sample[2], 2, "#2 [2]");
+ assert.sameValue(sample[3], 3, "#2 [3]");
+ assert.sameValue(sample[4], Infinity, "#2 [4]");
+ assert.sameValue(sample[5], NaN, "#2 [5]");
+ assert.sameValue(sample[6], NaN, "#2 [6]");
+}, [Float64Array, Float32Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js
new file mode 100644
index 0000000000..2d411d2a2d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/sorted-values.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Sort values to numeric ascending order
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ When the TypedArray SortCompare abstract operation is called with two
+ arguments x and y, the following steps are taken:
+
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([4, 3, 2, 1]).sort();
+ assert(compareArray(sample, [1, 2, 3, 4]), "descending values");
+
+ sample = new TA([3, 4, 1, 2]).sort();
+ assert(compareArray(sample, [1, 2, 3, 4]), "mixed numbers");
+
+ sample = new TA([3, 4, 3, 1, 0, 1, 2]).sort();
+ assert(compareArray(sample, [0, 1, 1, 2, 3, 3, 4]), "repeating numbers");
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 0, -0, 2]).sort();
+ assert(compareArray(sample, [-0, 0, 1, 2]), "0s");
+}, floatArrayConstructors);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([1, 0, -0, 2]).sort();
+ assert(compareArray(sample, [0, 0, 1, 2]), "0s");
+}, intArrayConstructors);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort();
+ assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values");
+}, [Float64Array, Float32Array, Int8Array, Int16Array, Int32Array]);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample;
+
+ sample = new TA([0.5, 0, 1.5, 1]).sort();
+ assert(compareArray(sample, [0, 0.5, 1, 1.5]), "non integers");
+
+ sample = new TA([0.5, 0, 1.5, -0.5, -1, -1.5, 1]).sort();
+ assert(compareArray(sample, [-1.5, -1, -0.5, 0, 0.5, 1, 1.5]), "non integers + negatives");
+
+ sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort();
+ assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities");
+
+}, [Float64Array, Float32Array]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js
new file mode 100644
index 0000000000..3a904f9f02
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/stability.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2019 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Stability of %TypedArray%.prototype.sort.
+info: |
+ https://github.com/tc39/ecma262/pull/1433
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+// Treat 0..3, 4..7, etc. as equal.
+const compare = (a, b) => (a / 4 | 0) - (b / 4 | 0);
+
+testWithTypedArrayConstructors((TA) => {
+ // Create an array of the form `[0, 1, …, 126, 127]`.
+ const array = Array.from({ length: 128 }, (_, i) => i);
+
+ const typedArray1 = new TA(array);
+ assert(compareArray(
+ typedArray1.sort(compare),
+ array
+ ), 'pre-sorted');
+
+ // Reverse `array` in-place so it becomes `[127, 126, …, 1, 0]`.
+ array.reverse();
+
+ const typedArray2 = new TA(array);
+ assert(compareArray(
+ typedArray2.sort(compare),
+ [
+ 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8,
+ 15, 14, 13, 12, 19, 18, 17, 16, 23, 22, 21, 20,
+ 27, 26, 25, 24, 31, 30, 29, 28, 35, 34, 33, 32,
+ 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44,
+ 51, 50, 49, 48, 55, 54, 53, 52, 59, 58, 57, 56,
+ 63, 62, 61, 60, 67, 66, 65, 64, 71, 70, 69, 68,
+ 75, 74, 73, 72, 79, 78, 77, 76, 83, 82, 81, 80,
+ 87, 86, 85, 84, 91, 90, 89, 88, 95, 94, 93, 92,
+ 99, 98, 97, 96, 103, 102, 101, 100, 107, 106, 105, 104,
+ 111, 110, 109, 108, 115, 114, 113, 112, 119, 118, 117, 116,
+ 123, 122, 121, 120, 127, 126, 125, 124,
+ ]
+ ), 'not presorted');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js
new file mode 100644
index 0000000000..0331551ca8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-object.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ 1. Let obj be the this value as the argument.
+ 2. Let buffer be ? ValidateTypedArray(obj).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var sort = TypedArray.prototype.sort;
+var comparefn = function() {};
+
+assert.throws(TypeError, function() {
+ sort.call(undefined, comparefn);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ sort.call(null, comparefn);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ sort.call(42, comparefn);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ sort.call("1", comparefn);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ sort.call(true, comparefn);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ sort.call(false, comparefn);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ sort.call(s, comparefn);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..8dfac62ce6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.sort
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.26 %TypedArray%.prototype.sort ( comparefn )
+
+ 1. Let obj be the this value as the argument.
+ 2. Let buffer be ? ValidateTypedArray(obj).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var sort = TypedArray.prototype.sort;
+var comparefn = function() {};
+
+assert.throws(TypeError, function() {
+ sort.call({}, comparefn);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ sort.call([], comparefn);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ sort.call(ab, comparefn);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ sort.call(dv, comparefn);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..524f6858e2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/detached-buffer.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Throws a TypeError creating a new instance with a detached buffer
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be
+ ? ToInteger(end).
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ ...
+
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+var begin, end;
+
+var o1 = {
+ valueOf: function() {
+ begin = true;
+ return 0;
+ }
+};
+
+var o2 = {
+ valueOf: function() {
+ end = true;
+ return 2;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ begin = false;
+ end = false;
+
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.subarray(o1, o2);
+ });
+
+ assert(begin, "observable ToInteger(begin)");
+ assert(end, "observable ToInteger(end)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/infinity.js
new file mode 100644
index 0000000000..cb1838bc27
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/infinity.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Infinity values on begin and end
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(
+ compareArray(sample.subarray(-Infinity), [40n, 41n, 42n, 43n]),
+ "begin == -Infinity"
+ );
+ assert(
+ compareArray(sample.subarray(Infinity), []),
+ "being == Infinity"
+ );
+ assert(
+ compareArray(sample.subarray(0, -Infinity), []),
+ "end == -Infinity"
+ );
+ assert(
+ compareArray(sample.subarray(0, Infinity), [40n, 41n, 42n, 43n]),
+ "end == Infinity"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/minus-zero.js
new file mode 100644
index 0000000000..efdf9cca16
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/minus-zero.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: -0 values on begin and end
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(
+ compareArray(sample.subarray(-0), [40n, 41n, 42n, 43n]),
+ "begin == -0"
+ );
+ assert(
+ compareArray(sample.subarray(-0, 4), [40n, 41n, 42n, 43n]),
+ "being == -0, end == length"
+ );
+ assert(
+ compareArray(sample.subarray(0, -0), []),
+ "being == 0, end == -0"
+ );
+ assert(
+ compareArray(sample.subarray(-0, -0), []),
+ "being == -0, end == -0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js
new file mode 100644
index 0000000000..9be1b784d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray result does not import own property
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([41n, 42n, 43n, 44n]);
+ var result;
+
+ sample.foo = 42;
+
+ result = sample.subarray(0);
+ assert.sameValue(
+ result.hasOwnProperty("foo"),
+ false,
+ "does not import own property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js
new file mode 100644
index 0000000000..4cefa6fd29
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Returns a new instance from the same constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var result = sample.subarray(1);
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "prototype"
+ );
+ assert.sameValue(result.constructor, sample.constructor, "constructor");
+ assert(result instanceof TA, "instanceof");
+
+ assert(
+ compareArray(sample, [40n, 41n, 42n, 43n]),
+ "original sample remains the same"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js
new file mode 100644
index 0000000000..3b8ea3c331
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Returns a new instance sharing the same buffer
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var buffer = sample.buffer;
+ var result = sample.subarray(1);
+
+ assert.notSameValue(result, sample, "returns a new instance");
+ assert.sameValue(result.buffer, sample.buffer, "shared buffer");
+ assert.sameValue(sample.buffer, buffer, "original buffer is preserved");
+
+ sample[1] = 100n;
+ assert(
+ compareArray(result, [100n, 42n, 43n]),
+ "changes on the original sample values affect the new instance"
+ );
+
+ result[1] = 111n;
+ assert(
+ compareArray(sample, [40n, 100n, 111n, 43n]),
+ "changes on the new instance values affect the original sample"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js
new file mode 100644
index 0000000000..f4153da597
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray may return a new instance with a smaller length
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ function testRes(result, expected, msg) {
+ assert(compareArray(result, expected), msg + ", result: [" + result + "]");
+ }
+
+ testRes(sample.subarray(1), [41n, 42n, 43n], "begin == 1");
+ testRes(sample.subarray(2), [42n, 43n], "begin == 2");
+ testRes(sample.subarray(3), [43n], "begin == 3");
+
+ testRes(sample.subarray(1, 4), [41n, 42n, 43n], "begin == 1, end == length");
+ testRes(sample.subarray(2, 4), [42n, 43n], "begin == 2, end == length");
+ testRes(sample.subarray(3, 4), [43n], "begin == 3, end == length");
+
+ testRes(sample.subarray(0, 1), [40n], "begin == 0, end == 1");
+ testRes(sample.subarray(0, 2), [40n, 41n], "begin == 0, end == 2");
+ testRes(sample.subarray(0, 3), [40n, 41n, 42n], "begin == 0, end == 3");
+
+ testRes(sample.subarray(-1), [43n], "begin == -1");
+ testRes(sample.subarray(-2), [42n, 43n], "begin == -2");
+ testRes(sample.subarray(-3), [41n, 42n, 43n], "begin == -3");
+
+ testRes(sample.subarray(-1, 4), [43n], "begin == -1, end == length");
+ testRes(sample.subarray(-2, 4), [42n, 43n], "begin == -2, end == length");
+ testRes(sample.subarray(-3, 4), [41n, 42n, 43n], "begin == -3, end == length");
+
+ testRes(sample.subarray(0, -1), [40n, 41n, 42n], "begin == 0, end == -1");
+ testRes(sample.subarray(0, -2), [40n, 41n], "begin == 0, end == -2");
+ testRes(sample.subarray(0, -3), [40n], "begin == 0, end == -3");
+
+ testRes(sample.subarray(-0, -1), [40n, 41n, 42n], "begin == -0, end == -1");
+ testRes(sample.subarray(-0, -2), [40n, 41n], "begin == -0, end == -2");
+ testRes(sample.subarray(-0, -3), [40n], "begin == -0, end == -3");
+
+ testRes(sample.subarray(-2, -1), [42n], "length == 4, begin == -2, end == -1");
+ testRes(sample.subarray(1, -1), [41n, 42n], "length == 4, begin == 1, end == -1");
+ testRes(sample.subarray(1, -2), [41n], "length == 4, begin == 1, end == -2");
+ testRes(sample.subarray(2, -1), [42n], "length == 4, begin == 2, end == -1");
+
+ testRes(sample.subarray(-1, 5), [43n], "begin == -1, end > length");
+ testRes(sample.subarray(-2, 4), [42n, 43n], "begin == -2, end > length");
+ testRes(sample.subarray(-3, 4), [41n, 42n, 43n], "begin == -3, end > length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js
new file mode 100644
index 0000000000..33a3728bf9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray may return a new empty instance
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 0, msg);
+ assert.sameValue(
+ result.hasOwnProperty(0),
+ false,
+ msg + " & result.hasOwnProperty(0) === false"
+ );
+ }
+
+ testRes(sample.subarray(4), "begin == length");
+ testRes(sample.subarray(5), "begin > length");
+
+ testRes(sample.subarray(4, 4), "begin == length, end == length");
+ testRes(sample.subarray(5, 4), "begin > length, end == length");
+
+ testRes(sample.subarray(4, 4), "begin == length, end > length");
+ testRes(sample.subarray(5, 4), "begin > length, end > length");
+
+ testRes(sample.subarray(0, 0), "begin == 0, end == 0");
+ testRes(sample.subarray(-0, -0), "begin == -0, end == -0");
+ testRes(sample.subarray(1, 0), "begin > 0, end == 0");
+ testRes(sample.subarray(-1, 0), "being < 0, end == 0");
+
+ testRes(sample.subarray(2, 1), "begin > 0, begin < length, begin > end, end > 0");
+ testRes(sample.subarray(2, 2), "begin > 0, begin < length, begin == end");
+
+ testRes(sample.subarray(2, -2), "begin > 0, begin < length, end == -2");
+
+ testRes(sample.subarray(-1, -1), "length = 4, begin == -1, end == -1");
+ testRes(sample.subarray(-1, -2), "length = 4, begin == -1, end == -2");
+ testRes(sample.subarray(-2, -2), "length = 4, begin == -2, end == -2");
+
+ testRes(sample.subarray(0, -4), "begin == 0, end == -length");
+ testRes(sample.subarray(-4, -4), "begin == -length, end == -length");
+ testRes(sample.subarray(-5, -4), "begin < -length, end == -length");
+
+ testRes(sample.subarray(0, -5), "begin == 0, end < -length");
+ testRes(sample.subarray(-4, -5), "begin == -length, end < -length");
+ testRes(sample.subarray(-5, -5), "begin < -length, end < -length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js
new file mode 100644
index 0000000000..a74e0c3be6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray may return a new instance with the same length
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 4, msg);
+ assert.sameValue(result[0], 40n, msg + " & result[0] === 40");
+ assert.sameValue(result[1], 41n, msg + " & result[1] === 41");
+ assert.sameValue(result[2], 42n, msg + " & result[2] === 42");
+ assert.sameValue(result[3], 43n, msg + " & result[3] === 43");
+ }
+
+ testRes(sample.subarray(0), "begin == 0");
+ testRes(sample.subarray(-4), "begin == -srcLength");
+ testRes(sample.subarray(-5), "begin < -srcLength");
+
+ testRes(sample.subarray(0, 4), "begin == 0, end == srcLength");
+ testRes(sample.subarray(-4, 4), "begin == -srcLength, end == srcLength");
+ testRes(sample.subarray(-5, 4), "begin < -srcLength, end == srcLength");
+
+ testRes(sample.subarray(0, 5), "begin == 0, end > srcLength");
+ testRes(sample.subarray(-4, 5), "begin == -srcLength, end > srcLength");
+ testRes(sample.subarray(-5, 5), "begin < -srcLength, end > srcLength");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js
new file mode 100644
index 0000000000..83233be119
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(begin), begin is symbol
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.subarray(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js
new file mode 100644
index 0000000000..0b5d84df83
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(begin)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js
new file mode 100644
index 0000000000..c68e1fbcb6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(end), end is symbol
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd
+ be ? ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.subarray(0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js
new file mode 100644
index 0000000000..02ba53cd48
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(end)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd
+ be ? ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0, o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0, o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..fadaf446a4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..68d4865a46
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.subarray(0);
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..07fec8bb54
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..3b1687fd77
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.subarray(0);
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..94a903d30e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..5afae1123e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var expectedOffset = TA.BYTES_PER_ELEMENT;
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(buffer, offset, length) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(buffer, offset, length);
+ };
+
+ sample.subarray(1);
+
+ assert.sameValue(result.length, 3, "called with 3 arguments");
+ assert.sameValue(result[0], sample.buffer, "[0] is sample.buffer");
+ assert.sameValue(result[1], expectedOffset, "[1] is the byte offset pos");
+ assert.sameValue(result[2], 2, "[2] is expected length");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..5ac5a191ce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Custom @@species constructor may return a totally different TypedArray
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n]);
+ var other = new BigInt64Array([1n, 0n, 1n]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.subarray(0, 0);
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..4350b76916
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var ctor = function() {};
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = ctor;
+
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..22f9502ae5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n]);
+ var calls = 0;
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(buffer, offset, length) {
+ calls++;
+ return new TA(buffer, offset, length);
+ };
+
+ result = sample.subarray(1);
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert(compareArray(result, [41n, 42n]), "expected subarray");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..d568d39110
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..e22fea84ad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.subarray(0);
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.subarray(0);
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js
new file mode 100644
index 0000000000..358a88f259
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.species, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.subarray(0);
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js
new file mode 100644
index 0000000000..4fcce8b780
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: ToInteger(begin)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(compareArray(sample.subarray(false), [40n, 41n, 42n, 43n]), "false");
+ assert(compareArray(sample.subarray(true), [41n, 42n, 43n]), "true");
+
+ assert(compareArray(sample.subarray(NaN), [40n, 41n, 42n, 43n]), "NaN");
+ assert(compareArray(sample.subarray(null), [40n, 41n, 42n, 43n]), "null");
+ assert(compareArray(sample.subarray(undefined), [40n, 41n, 42n, 43n]), "undefined");
+
+ assert(compareArray(sample.subarray(1.1), [41n, 42n, 43n]), "1.1");
+ assert(compareArray(sample.subarray(1.5), [41n, 42n, 43n]), "1.5");
+ assert(compareArray(sample.subarray(0.6), [40n, 41n, 42n, 43n]), "0.6");
+
+ assert(compareArray(sample.subarray(-1.5), [43n]), "-1.5");
+ assert(compareArray(sample.subarray(-1.1), [43n]), "-1.1");
+ assert(compareArray(sample.subarray(-0.6), [40n, 41n, 42n, 43n]), "-0.6");
+
+ assert(compareArray(sample.subarray("3"), [43n]), "string");
+ assert(
+ compareArray(
+ sample.subarray(obj),
+ [42n, 43n]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-end.js
new file mode 100644
index 0000000000..2e3a74b14a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/BigInt/tointeger-end.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: ToInteger(end)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be
+ ? ToInteger(end).
+ ...
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([40n, 41n, 42n, 43n]);
+
+ assert(compareArray(sample.subarray(0, false), []), "false");
+ assert(compareArray(sample.subarray(0, true), [40n]), "true");
+
+ assert(compareArray(sample.subarray(0, NaN), []), "NaN");
+ assert(compareArray(sample.subarray(0, null), []), "null");
+ assert(compareArray(sample.subarray(0, undefined), [40n, 41n, 42n, 43n]), "undefined");
+
+ assert(compareArray(sample.subarray(0, 0.6), []), "0.6");
+ assert(compareArray(sample.subarray(0, 1.1), [40n]), "1.1");
+ assert(compareArray(sample.subarray(0, 1.5), [40n]), "1.5");
+ assert(compareArray(sample.subarray(0, -0.6), []), "-0.6");
+ assert(compareArray(sample.subarray(0, -1.1), [40n, 41n, 42n]), "-1.1");
+ assert(compareArray(sample.subarray(0, -1.5), [40n, 41n, 42n]), "-1.5");
+
+ assert(compareArray(sample.subarray(0, "3"), [40n, 41n, 42n]), "string");
+ assert(
+ compareArray(
+ sample.subarray(0, obj),
+ [40n, 41n]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js
new file mode 100644
index 0000000000..c65f6efff6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/detached-buffer.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Throws a TypeError creating a new instance with a detached buffer
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be
+ ? ToInteger(end).
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ ...
+
+ 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
+
+ ...
+ 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+var begin, end;
+
+var o1 = {
+ valueOf: function() {
+ begin = true;
+ return 0;
+ }
+};
+
+var o2 = {
+ valueOf: function() {
+ end = true;
+ return 2;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ begin = false;
+ end = false;
+
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.subarray(o1, o2);
+ });
+
+ assert(begin, "observable ToInteger(begin)");
+ assert(end, "observable ToInteger(end)");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js
new file mode 100644
index 0000000000..283689ecea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/infinity.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Infinity values on begin and end
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(
+ compareArray(sample.subarray(-Infinity), [40, 41, 42, 43]),
+ "begin == -Infinity"
+ );
+ assert(
+ compareArray(sample.subarray(Infinity), []),
+ "being == Infinity"
+ );
+ assert(
+ compareArray(sample.subarray(0, -Infinity), []),
+ "end == -Infinity"
+ );
+ assert(
+ compareArray(sample.subarray(0, Infinity), [40, 41, 42, 43]),
+ "end == Infinity"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js
new file mode 100644
index 0000000000..7bd0688838
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-func.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.26 %TypedArray%.prototype.subarray( [ begin [ , end ] ] )
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var subarray = TypedArray.prototype.subarray;
+
+assert.sameValue(typeof subarray, 'function');
+
+assert.throws(TypeError, function() {
+ subarray();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js
new file mode 100644
index 0000000000..c5c39eb9e3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/invoked-as-method.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.26 %TypedArray%.prototype.subarray( [ begin [ , end ] ] )
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.subarray, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.subarray();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js
new file mode 100644
index 0000000000..7c29e2ff6b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ %TypedArray%.prototype.subarray.length is 2.
+info: |
+ %TypedArray%.prototype.subarray( [ begin [ , end ] ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.subarray.length, 2);
+
+verifyNotEnumerable(TypedArray.prototype.subarray, "length");
+verifyNotWritable(TypedArray.prototype.subarray, "length");
+verifyConfigurable(TypedArray.prototype.subarray, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js
new file mode 100644
index 0000000000..8c77ef6dd2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/minus-zero.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: -0 values on begin and end
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(
+ compareArray(sample.subarray(-0), [40, 41, 42, 43]),
+ "begin == -0"
+ );
+ assert(
+ compareArray(sample.subarray(-0, 4), [40, 41, 42, 43]),
+ "being == -0, end == length"
+ );
+ assert(
+ compareArray(sample.subarray(0, -0), []),
+ "being == 0, end == -0"
+ );
+ assert(
+ compareArray(sample.subarray(-0, -0), []),
+ "being == -0, end == -0"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js
new file mode 100644
index 0000000000..890fd6c7ce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ %TypedArray%.prototype.subarray.name is "subarray".
+info: |
+ %TypedArray%.prototype.subarray( [ begin [ , end ] ] )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.subarray.name, "subarray");
+
+verifyNotEnumerable(TypedArray.prototype.subarray, "name");
+verifyNotWritable(TypedArray.prototype.subarray, "name");
+verifyConfigurable(TypedArray.prototype.subarray, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js
new file mode 100644
index 0000000000..1714a12b2a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.subarray does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.subarray),
+ false,
+ 'isConstructor(TypedArray.prototype.subarray) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.subarray();
+}, '`let u8 = new Uint8Array(1); new u8.subarray()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js
new file mode 100644
index 0000000000..e21769abed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ "subarray" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'subarray');
+verifyWritable(TypedArrayPrototype, 'subarray');
+verifyConfigurable(TypedArrayPrototype, 'subarray');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js
new file mode 100644
index 0000000000..6bd16f4c9b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray result does not import own property
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([41, 42, 43, 44]);
+ var result;
+
+ sample.foo = 42;
+
+ result = sample.subarray(0);
+ assert.sameValue(
+ result.hasOwnProperty("foo"),
+ false,
+ "does not import own property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js
new file mode 100644
index 0000000000..48d9a3b490
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Returns a new instance from the same constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var result = sample.subarray(1);
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "prototype"
+ );
+ assert.sameValue(result.constructor, sample.constructor, "constructor");
+ assert(result instanceof TA, "instanceof");
+
+ assert(
+ compareArray(sample, [40, 41, 42, 43]),
+ "original sample remains the same"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js
new file mode 100644
index 0000000000..223703aaa4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Returns a new instance sharing the same buffer
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var buffer = sample.buffer;
+ var result = sample.subarray(1);
+
+ assert.notSameValue(result, sample, "returns a new instance");
+ assert.sameValue(result.buffer, sample.buffer, "shared buffer");
+ assert.sameValue(sample.buffer, buffer, "original buffer is preserved");
+
+ sample[1] = 100;
+ assert(
+ compareArray(result, [100, 42, 43]),
+ "changes on the original sample values affect the new instance"
+ );
+
+ result[1] = 111;
+ assert(
+ compareArray(sample, [40, 100, 111, 43]),
+ "changes on the new instance values affect the original sample"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js
new file mode 100644
index 0000000000..3445ae36be
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-different-length.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray may return a new instance with a smaller length
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ function testRes(result, expected, msg) {
+ assert(compareArray(result, expected), msg + ", result: [" + result + "]");
+ }
+
+ testRes(sample.subarray(1), [41, 42, 43], "begin == 1");
+ testRes(sample.subarray(2), [42, 43], "begin == 2");
+ testRes(sample.subarray(3), [43], "begin == 3");
+
+ testRes(sample.subarray(1, 4), [41, 42, 43], "begin == 1, end == length");
+ testRes(sample.subarray(2, 4), [42, 43], "begin == 2, end == length");
+ testRes(sample.subarray(3, 4), [43], "begin == 3, end == length");
+
+ testRes(sample.subarray(0, 1), [40], "begin == 0, end == 1");
+ testRes(sample.subarray(0, 2), [40, 41], "begin == 0, end == 2");
+ testRes(sample.subarray(0, 3), [40, 41, 42], "begin == 0, end == 3");
+
+ testRes(sample.subarray(-1), [43], "begin == -1");
+ testRes(sample.subarray(-2), [42, 43], "begin == -2");
+ testRes(sample.subarray(-3), [41, 42, 43], "begin == -3");
+
+ testRes(sample.subarray(-1, 4), [43], "begin == -1, end == length");
+ testRes(sample.subarray(-2, 4), [42, 43], "begin == -2, end == length");
+ testRes(sample.subarray(-3, 4), [41, 42, 43], "begin == -3, end == length");
+
+ testRes(sample.subarray(0, -1), [40, 41, 42], "begin == 0, end == -1");
+ testRes(sample.subarray(0, -2), [40, 41], "begin == 0, end == -2");
+ testRes(sample.subarray(0, -3), [40], "begin == 0, end == -3");
+
+ testRes(sample.subarray(-0, -1), [40, 41, 42], "begin == -0, end == -1");
+ testRes(sample.subarray(-0, -2), [40, 41], "begin == -0, end == -2");
+ testRes(sample.subarray(-0, -3), [40], "begin == -0, end == -3");
+
+ testRes(sample.subarray(-2, -1), [42], "length == 4, begin == -2, end == -1");
+ testRes(sample.subarray(1, -1), [41, 42], "length == 4, begin == 1, end == -1");
+ testRes(sample.subarray(1, -2), [41], "length == 4, begin == 1, end == -2");
+ testRes(sample.subarray(2, -1), [42], "length == 4, begin == 2, end == -1");
+
+ testRes(sample.subarray(-1, 5), [43], "begin == -1, end > length");
+ testRes(sample.subarray(-2, 4), [42, 43], "begin == -2, end > length");
+ testRes(sample.subarray(-3, 4), [41, 42, 43], "begin == -3, end > length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js
new file mode 100644
index 0000000000..204effe618
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-empty-length.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray may return a new empty instance
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 0, msg);
+ assert.sameValue(
+ result.hasOwnProperty(0),
+ false,
+ msg + " & result.hasOwnProperty(0) === false"
+ );
+ }
+
+ testRes(sample.subarray(4), "begin == length");
+ testRes(sample.subarray(5), "begin > length");
+
+ testRes(sample.subarray(4, 4), "begin == length, end == length");
+ testRes(sample.subarray(5, 4), "begin > length, end == length");
+
+ testRes(sample.subarray(4, 4), "begin == length, end > length");
+ testRes(sample.subarray(5, 4), "begin > length, end > length");
+
+ testRes(sample.subarray(0, 0), "begin == 0, end == 0");
+ testRes(sample.subarray(-0, -0), "begin == -0, end == -0");
+ testRes(sample.subarray(1, 0), "begin > 0, end == 0");
+ testRes(sample.subarray(-1, 0), "being < 0, end == 0");
+
+ testRes(sample.subarray(2, 1), "begin > 0, begin < length, begin > end, end > 0");
+ testRes(sample.subarray(2, 2), "begin > 0, begin < length, begin == end");
+
+ testRes(sample.subarray(2, -2), "begin > 0, begin < length, end == -2");
+
+ testRes(sample.subarray(-1, -1), "length = 4, begin == -1, end == -1");
+ testRes(sample.subarray(-1, -2), "length = 4, begin == -1, end == -2");
+ testRes(sample.subarray(-2, -2), "length = 4, begin == -2, end == -2");
+
+ testRes(sample.subarray(0, -4), "begin == 0, end == -length");
+ testRes(sample.subarray(-4, -4), "begin == -length, end == -length");
+ testRes(sample.subarray(-5, -4), "begin < -length, end == -length");
+
+ testRes(sample.subarray(0, -5), "begin == 0, end < -length");
+ testRes(sample.subarray(-4, -5), "begin == -length, end < -length");
+ testRes(sample.subarray(-5, -5), "begin < -length, end < -length");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js
new file mode 100644
index 0000000000..614ad244ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/results-with-same-length.js
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Subarray may return a new instance with the same length
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ function testRes(result, msg) {
+ assert.sameValue(result.length, 4, msg);
+ assert.sameValue(result[0], 40, msg + " & result[0] === 40");
+ assert.sameValue(result[1], 41, msg + " & result[1] === 41");
+ assert.sameValue(result[2], 42, msg + " & result[2] === 42");
+ assert.sameValue(result[3], 43, msg + " & result[3] === 43");
+ }
+
+ testRes(sample.subarray(0), "begin == 0");
+ testRes(sample.subarray(-4), "begin == -srcLength");
+ testRes(sample.subarray(-5), "begin < -srcLength");
+
+ testRes(sample.subarray(0, 4), "begin == 0, end == srcLength");
+ testRes(sample.subarray(-4, 4), "begin == -srcLength, end == srcLength");
+ testRes(sample.subarray(-5, 4), "begin < -srcLength, end == srcLength");
+
+ testRes(sample.subarray(0, 5), "begin == 0, end > srcLength");
+ testRes(sample.subarray(-4, 5), "begin == -srcLength, end > srcLength");
+ testRes(sample.subarray(-5, 5), "begin < -srcLength, end > srcLength");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js
new file mode 100644
index 0000000000..650627c289
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(begin), begin is symbol
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.subarray(s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js
new file mode 100644
index 0000000000..9f8f28630b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-begin.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(begin)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js
new file mode 100644
index 0000000000..0e64f4ed39
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(end), end is symbol
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd
+ be ? ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var s = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(TypeError, function() {
+ sample.subarray(0, s);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js
new file mode 100644
index 0000000000..3ab6a1c68c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/return-abrupt-from-end.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from ToInteger(end)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd
+ be ? ToInteger(end).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var o1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var o2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0, o1);
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0, o2);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js
new file mode 100644
index 0000000000..c141c84747
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Return abrupt from SpeciesConstructor's get Constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js
new file mode 100644
index 0000000000..b09d8759c5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: get inherited constructor on SpeciesConstructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(TA.prototype, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.subarray(0);
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ undefined,
+ "used defaultCtor but still checks the inherited .constructor"
+ );
+
+ calls = 6;
+ result.constructor;
+ assert.sameValue(
+ calls,
+ 7,
+ "result.constructor triggers the inherited accessor property"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js
new file mode 100644
index 0000000000..7b96f3041c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Throws if O.constructor returns a non-Object and non-undefined value
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ 4. If Type(C) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ sample.constructor = 42;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "42");
+
+ sample.constructor = "1";
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "string");
+
+ sample.constructor = null;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "null");
+
+ sample.constructor = NaN;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "NaN");
+
+ sample.constructor = false;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "false");
+
+ sample.constructor = Symbol("1");
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "symbol");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js
new file mode 100644
index 0000000000..a14d069528
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-ctor.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: get constructor on SpeciesConstructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ 3. If C is undefined, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+ var calls = 0;
+ var result;
+
+ Object.defineProperty(sample, "constructor", {
+ get: function() {
+ calls++;
+ }
+ });
+
+ result = sample.subarray(0);
+
+ assert.sameValue(calls, 1, "called custom ctor get accessor once");
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "use defaultCtor on an undefined return - getPrototypeOf check"
+ );
+ assert.sameValue(
+ result.constructor,
+ TA,
+ "use defaultCtor on an undefined return - .constructor check"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js
new file mode 100644
index 0000000000..7e40dbe686
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Returns abrupt from get @@species on found constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ throw new Test262Error();
+ }
+ });
+
+ assert.throws(Test262Error, function() {
+ sample.subarray(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js
new file mode 100644
index 0000000000..1590a0c45b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js
@@ -0,0 +1,63 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Verify arguments on custom @@species construct call
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+ var expectedOffset = TA.BYTES_PER_ELEMENT;
+ var result, ctorThis;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(buffer, offset, length) {
+ result = arguments;
+ ctorThis = this;
+ return new TA(buffer, offset, length);
+ };
+
+ sample.subarray(1);
+
+ assert.sameValue(result.length, 3, "called with 3 arguments");
+ assert.sameValue(result[0], sample.buffer, "[0] is sample.buffer");
+ assert.sameValue(result[1], expectedOffset, "[1] is the byte offset pos");
+ assert.sameValue(result[2], 2, "[2] is expected length");
+
+ assert(
+ ctorThis instanceof sample.constructor[Symbol.species],
+ "`this` value in the @@species fn is an instance of the function itself"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js
new file mode 100644
index 0000000000..f86ed913db
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Custom @@species constructor may return a totally different TypedArray
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40]);
+ var other = new Int8Array([1, 0, 1]);
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function() {
+ return other;
+ };
+
+ result = sample.subarray(0, 0);
+
+ assert.sameValue(result, other, "returned another typedarray");
+ assert(compareArray(result, [1, 0, 1]), "the returned object is preserved");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js
new file mode 100644
index 0000000000..5e3d0d7be7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Custom @@species constructor throws if it does not return a compatible object
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var ctor = function() {};
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = ctor;
+
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js
new file mode 100644
index 0000000000..46e69712ee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Use custom @@species constructor if available
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ 4. Return ? TypedArrayCreate(constructor, argumentList).
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+ 7. If IsConstructor(S) is true, return S.
+ ...
+
+ 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
+
+ 1. Let newTypedArray be ? Construct(constructor, argumentList).
+ 2. Perform ? ValidateTypedArray(newTypedArray).
+ 3. If argumentList is a List of a single Number, then
+ ...
+ 4. Return newTypedArray.
+includes: [testTypedArray.js, compareArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42]);
+ var calls = 0;
+ var result;
+
+ sample.constructor = {};
+ sample.constructor[Symbol.species] = function(buffer, offset, length) {
+ calls++;
+ return new TA(buffer, offset, length);
+ };
+
+ result = sample.subarray(1);
+
+ assert.sameValue(calls, 1, "ctor called once");
+ assert(compareArray(result, [41, 42]), "expected subarray");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js
new file mode 100644
index 0000000000..01411d313c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js
@@ -0,0 +1,67 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Throws if returned @@species is not a constructor, null or undefined.
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ 7. If IsConstructor(S) is true, return S.
+ 8. Throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+
+ sample.constructor = {};
+
+ sample.constructor[Symbol.species] = 0;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "0");
+
+ sample.constructor[Symbol.species] = "string";
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "string");
+
+ sample.constructor[Symbol.species] = {};
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "{}");
+
+ sample.constructor[Symbol.species] = NaN;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "NaN");
+
+ sample.constructor[Symbol.species] = false;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "false");
+
+ sample.constructor[Symbol.species] = true;
+ assert.throws(TypeError, function() {
+ sample.subarray(0);
+ }, "true");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js
new file mode 100644
index 0000000000..cb21cd8f3c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Use defaultConstructor if @@species is either undefined or null
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ ...
+ 5. Let S be ? Get(C, @@species).
+ 6. If S is either undefined or null, return defaultConstructor.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var result;
+
+ sample.constructor = {};
+
+ result = sample.subarray(0);
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "undefined @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "undefined @@species - ctor check");
+
+ sample.constructor[Symbol.species] = null;
+ result = sample.subarray(0);
+
+ assert.sameValue(
+ Object.getPrototypeOf(result),
+ Object.getPrototypeOf(sample),
+ "null @@species - prototype check "
+ );
+ assert.sameValue(result.constructor, TA, "null @@species - ctor check");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js
new file mode 100644
index 0000000000..26bae75f03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/speciesctor-get-species.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ get @@species from found constructor
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
+
+ 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
+
+ ...
+ 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
+ ...
+
+ 7.3.20 SpeciesConstructor ( O, defaultConstructor )
+
+ 1. Assert: Type(O) is Object.
+ 2. Let C be ? Get(O, "constructor").
+ ...
+ 5. Let S be ? Get(C, @@species).
+ ...
+includes: [testTypedArray.js]
+features: [Symbol.species, TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(2);
+ var calls = 0;
+
+ sample.constructor = {};
+
+ Object.defineProperty(sample.constructor, Symbol.species, {
+ get: function() {
+ calls++;
+ }
+ });
+
+ sample.subarray(0);
+
+ assert.sameValue(calls, 1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js
new file mode 100644
index 0000000000..e8aca60f7b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-object.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var subarray = TypedArray.prototype.subarray;
+
+assert.throws(TypeError, function() {
+ subarray.call(undefined, 0, 0);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ subarray.call(null, 0, 0);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ subarray.call(42, 0, 0);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ subarray.call("1", 0, 0);
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ subarray.call(true, 0, 0);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ subarray.call(false, 0, 0);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ subarray.call(s, 0, 0);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..da35e935f1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.9 %TypedArray%.prototype.subarray( begin , end )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var subarray = TypedArray.prototype.subarray;
+
+assert.throws(TypeError, function() {
+ subarray.call({}, 0, 0);
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ subarray.call([], 0, 0);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ subarray.call(ab, 0, 0);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ subarray.call(dv, 0, 0);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js
new file mode 100644
index 0000000000..de48a3d1a6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-begin.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: ToInteger(begin)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 7. Let relativeBegin be ? ToInteger(begin).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(compareArray(sample.subarray(false), [40, 41, 42, 43]), "false");
+ assert(compareArray(sample.subarray(true), [41, 42, 43]), "true");
+
+ assert(compareArray(sample.subarray(NaN), [40, 41, 42, 43]), "NaN");
+ assert(compareArray(sample.subarray(null), [40, 41, 42, 43]), "null");
+ assert(compareArray(sample.subarray(undefined), [40, 41, 42, 43]), "undefined");
+
+ assert(compareArray(sample.subarray(1.1), [41, 42, 43]), "1.1");
+ assert(compareArray(sample.subarray(1.5), [41, 42, 43]), "1.5");
+ assert(compareArray(sample.subarray(0.6), [40, 41, 42, 43]), "0.6");
+
+ assert(compareArray(sample.subarray(-1.5), [43]), "-1.5");
+ assert(compareArray(sample.subarray(-1.1), [43]), "-1.1");
+ assert(compareArray(sample.subarray(-0.6), [40, 41, 42, 43]), "-0.6");
+
+ assert(compareArray(sample.subarray("3"), [43]), "string");
+ assert(
+ compareArray(
+ sample.subarray(obj),
+ [42, 43]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js
new file mode 100644
index 0000000000..a45c5258da
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/subarray/tointeger-end.js
@@ -0,0 +1,50 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.subarray
+description: ToInteger(end)
+info: |
+ 22.2.3.27 %TypedArray%.prototype.subarray( begin , end )
+
+ ...
+ 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be
+ ? ToInteger(end).
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA([40, 41, 42, 43]);
+
+ assert(compareArray(sample.subarray(0, false), []), "false");
+ assert(compareArray(sample.subarray(0, true), [40]), "true");
+
+ assert(compareArray(sample.subarray(0, NaN), []), "NaN");
+ assert(compareArray(sample.subarray(0, null), []), "null");
+ assert(compareArray(sample.subarray(0, undefined), [40, 41, 42, 43]), "undefined");
+
+ assert(compareArray(sample.subarray(0, 0.6), []), "0.6");
+ assert(compareArray(sample.subarray(0, 1.1), [40]), "1.1");
+ assert(compareArray(sample.subarray(0, 1.5), [40]), "1.5");
+ assert(compareArray(sample.subarray(0, -0.6), []), "-0.6");
+ assert(compareArray(sample.subarray(0, -1.1), [40, 41, 42]), "-1.1");
+ assert(compareArray(sample.subarray(0, -1.5), [40, 41, 42]), "-1.5");
+
+ assert(compareArray(sample.subarray(0, "3"), [40, 41, 42]), "string");
+ assert(
+ compareArray(
+ sample.subarray(0, obj),
+ [40, 41]
+ ),
+ "object"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js
new file mode 100644
index 0000000000..233c0f4966
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Calls toLocaleString from each property's value
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js, compareArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+var calls;
+
+BigInt.prototype.toLocaleString = function() {
+ calls.push(this);
+ return "hacks" + calls.length;
+};
+
+var expected = ["hacks1", "hacks2"].join(separator);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 0n]);
+ calls = [];
+ assert.sameValue(sample.toLocaleString(), expected, "returns expected value");
+ assert(
+ compareArray(new TA(calls), sample),
+ "toLocaleString called for each item"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js
new file mode 100644
index 0000000000..9848015a02
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Calls toString from each property's value return from toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+var calls;
+
+BigInt.prototype.toLocaleString = function() {
+ return {
+ toString: function() {
+ calls++;
+ return "hacks" + calls;
+ },
+ valueOf: function() {
+ throw new Test262Error("should not call valueOf if toString is present");
+ }
+ };
+};
+
+var arr = [42n, 0n];
+var expected = ["hacks1", "hacks2"].join(separator);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(arr);
+ calls = 0;
+ assert.sameValue(sample.toLocaleString(), expected, "returns expected value");
+ assert.sameValue(calls, 2, "toString called once for each item");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js
new file mode 100644
index 0000000000..11e362dcf1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Calls valueOf from each property's value return from toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+var calls;
+
+BigInt.prototype.toLocaleString = function() {
+ return {
+ toString: undefined,
+ valueOf: function() {
+ calls++;
+ return "hacks" + calls;
+ }
+ };
+};
+
+var expected = ["hacks1", "hacks2"].join(separator);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 0n]);
+ calls = 0;
+ assert.sameValue(sample.toLocaleString(), expected, "returns expected value");
+ assert.sameValue(calls, 2, "valueOf called once for each item");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..9cb0bd490d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.toLocaleString();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js
new file mode 100644
index 0000000000..f1ef22bbb7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns an empty string if called on an empty instance
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 4. If len is zero, return the empty String.
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.toLocaleString(), "");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..2a0b386eb4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ 1. Let array be ? ToObject(this value).
+ 2.Let len be ? ToLength(? Get(array, "length")).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 43n]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.toLocaleString();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js
new file mode 100644
index 0000000000..f9d23d808b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns abrupt from firstElement's toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 4. If len is zero, return the empty String.
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var calls;
+
+BigInt.prototype.toLocaleString = function() {
+ calls++;
+ throw new Test262Error();
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ calls = 0;
+ var sample = new TA([42n, 0n]);
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 1, "abrupt from first element");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js
new file mode 100644
index 0000000000..2fe9aaa9e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from firstElement's toLocaleString => toString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var calls = 0;
+
+BigInt.prototype.toLocaleString = function() {
+ return {
+ toString: function() {
+ calls++;
+ throw new Test262Error();
+ }
+ };
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 0n]);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 1, "toString called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js
new file mode 100644
index 0000000000..aa8f6b3cc1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from firstElement's toLocaleString => valueOf
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var calls = 0;
+
+BigInt.prototype.toLocaleString = function() {
+ return {
+ toString: undefined,
+ valueOf: function() {
+ calls++;
+ throw new Test262Error();
+ }
+ };
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 0n]);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 1, "toString called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js
new file mode 100644
index 0000000000..9e5fbfee54
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns abrupt from a nextElement's toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var calls = 0;
+
+BigInt.prototype.toLocaleString = function() {
+ calls++;
+ if (calls > 1) {
+ throw new Test262Error();
+ }
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ calls = 0;
+ var sample = new TA([42n, 0n]);
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 2, "abrupt from a next element");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js
new file mode 100644
index 0000000000..e95855d738
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from nextElement's toLocaleString => valueOf
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var calls = 0;
+
+BigInt.prototype.toLocaleString = function() {
+ return {
+ toString: function() {
+ calls++;
+ if (calls > 1) {
+ throw new Test262Error();
+ }
+ }
+ };
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 0n]);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 2, "abrupt from a nextElement");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js
new file mode 100644
index 0000000000..e59ced5e31
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from nextElement's toLocaleString => valueOf
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var calls = 0;
+
+BigInt.prototype.toLocaleString = function() {
+ return {
+ toString: undefined,
+ valueOf: function() {
+ calls++;
+ if (calls > 1) {
+ throw new Test262Error();
+ }
+ }
+ };
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 0n]);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 2, "abrupt from a nextElement");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..bbd84a46a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.toLocaleString,
+ 'function',
+ 'implements TypedArray.prototype.toLocaleString'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.toLocaleString();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.toLocaleString();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the toLocaleString operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.toLocaleString();
+ throw new Test262Error('toLocaleString completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-result.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-result.js
new file mode 100644
index 0000000000..42add1d7e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/return-result.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns a string
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([42n, 0n, 43n]);
+ var expected =
+ sample[0].toLocaleString().toString() +
+ separator +
+ sample[1].toLocaleString().toString() +
+ separator +
+ sample[2].toLocaleString().toString();
+ assert.sameValue(sample.toLocaleString(), expected);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js
new file mode 100644
index 0000000000..7cbb2cb39a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Calls toLocaleString from each property's value
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+var calls;
+
+Number.prototype.toLocaleString = function() {
+ calls.push(this);
+ return "hacks" + calls.length;
+};
+
+var arr = [42, 0];
+var expected = ["hacks1", "hacks2"].join(separator);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(arr);
+ calls = [];
+ assert.sameValue(sample.toLocaleString(), expected, "returns expected value");
+ assert(
+ compareArray(new TA(calls), sample),
+ "toLocaleString called for each item"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js
new file mode 100644
index 0000000000..585035169e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Calls toString from each property's value return from toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+var calls;
+
+Number.prototype.toLocaleString = function() {
+ return {
+ toString: function() {
+ calls++;
+ return "hacks" + calls;
+ },
+ valueOf: function() {
+ throw new Test262Error("should not call valueOf if toString is present");
+ }
+ };
+};
+
+var arr = [42, 0];
+var expected = ["hacks1", "hacks2"].join(separator);
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA(arr);
+ calls = 0;
+ assert.sameValue(sample.toLocaleString(), expected, "returns expected value");
+ assert.sameValue(calls, 2, "toString called once for each item");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js
new file mode 100644
index 0000000000..379470d105
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Calls valueOf from each property's value return from toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+var calls;
+
+Number.prototype.toLocaleString = function() {
+ return {
+ toString: undefined,
+ valueOf: function() {
+ calls++;
+ return "hacks" + calls;
+ }
+ };
+};
+
+var arr = [42, 0];
+var expected = ["hacks1", "hacks2"].join(separator);
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA(arr);
+ calls = 0;
+ assert.sameValue(sample.toLocaleString(), expected, "returns expected value");
+ assert.sameValue(calls, 2, "valueOf called once for each item");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js
new file mode 100644
index 0000000000..df5d1a5a8c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/detached-buffer.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.toLocaleString();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js
new file mode 100644
index 0000000000..fb9690e4eb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns an empty string if called on an empty instance
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 4. If len is zero, return the empty String.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA();
+ assert.sameValue(sample.toLocaleString(), "");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js
new file mode 100644
index 0000000000..910b72a391
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Get "length" uses internal ArrayLength
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ 1. Let array be ? ToObject(this value).
+ 2.Let len be ? ToLength(? Get(array, "length")).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(TypedArray.prototype, "length", desc);
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA([42, 43]);
+
+ Object.defineProperty(TA.prototype, "length", desc);
+ Object.defineProperty(sample, "length", desc);
+
+ sample.toLocaleString();
+
+ assert.sameValue(getCalls, 0, "ignores length properties");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js
new file mode 100644
index 0000000000..50b138d41b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-func.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.27 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ ...
+
+ This function is not generic. ValidateTypedArray is applied to the this
+ value prior to evaluating the algorithm. If its result is an abrupt
+ completion that exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var toLocaleString = TypedArray.prototype.toLocaleString;
+
+assert.sameValue(typeof toLocaleString, 'function');
+
+assert.throws(TypeError, function() {
+ toLocaleString();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js
new file mode 100644
index 0000000000..da9ce62df8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/invoked-as-method.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.27 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ ...
+
+ This function is not generic. ValidateTypedArray is applied to the this
+ value prior to evaluating the algorithm. If its result is an abrupt
+ completion that exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.toLocaleString, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.toLocaleString();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js
new file mode 100644
index 0000000000..fcd30d3ec8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ %TypedArray%.prototype.toLocaleString.length is 0.
+info: |
+ %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.toLocaleString.length, 0);
+
+verifyNotEnumerable(TypedArray.prototype.toLocaleString, "length");
+verifyNotWritable(TypedArray.prototype.toLocaleString, "length");
+verifyConfigurable(TypedArray.prototype.toLocaleString, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js
new file mode 100644
index 0000000000..b793dd388b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ %TypedArray%.prototype.toLocaleString.name is "toLocaleString".
+info: |
+ %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.toLocaleString.name, "toLocaleString");
+
+verifyNotEnumerable(TypedArray.prototype.toLocaleString, "name");
+verifyNotWritable(TypedArray.prototype.toLocaleString, "name");
+verifyConfigurable(TypedArray.prototype.toLocaleString, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js
new file mode 100644
index 0000000000..3366ceacde
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.toLocaleString does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.toLocaleString),
+ false,
+ 'isConstructor(TypedArray.prototype.toLocaleString) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.toLocaleString();
+}, '`let u8 = new Uint8Array(1); new u8.toLocaleString()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js
new file mode 100644
index 0000000000..e4d7516476
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ "toLocaleString" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'toLocaleString');
+verifyWritable(TypedArrayPrototype, 'toLocaleString');
+verifyConfigurable(TypedArrayPrototype, 'toLocaleString');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js
new file mode 100644
index 0000000000..9114df1a13
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js
@@ -0,0 +1,45 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns abrupt from firstElement's toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 4. If len is zero, return the empty String.
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var calls;
+
+Number.prototype.toLocaleString = function() {
+ calls++;
+ throw new Test262Error();
+};
+
+var arr = [42, 0];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ calls = 0;
+ var sample = new TA(arr);
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 1, "abrupt from first element");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js
new file mode 100644
index 0000000000..05095bd645
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from firstElement's toLocaleString => toString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var calls = 0;
+
+Number.prototype.toLocaleString = function() {
+ return {
+ toString: function() {
+ calls++;
+ throw new Test262Error();
+ }
+ };
+};
+
+var arr = [42, 0];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA(arr);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 1, "toString called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js
new file mode 100644
index 0000000000..690e9c32e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from firstElement's toLocaleString => valueOf
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var calls = 0;
+
+Number.prototype.toLocaleString = function() {
+ return {
+ toString: undefined,
+ valueOf: function() {
+ calls++;
+ throw new Test262Error();
+ }
+ };
+};
+
+var arr = [42, 0];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA(arr);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 1, "toString called once");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js
new file mode 100644
index 0000000000..f46d410a13
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns abrupt from a nextElement's toLocaleString
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var calls = 0;
+
+Number.prototype.toLocaleString = function() {
+ calls++;
+ if (calls > 1) {
+ throw new Test262Error();
+ }
+};
+
+var arr = [42, 0];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ calls = 0;
+ var sample = new TA(arr);
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 2, "abrupt from a next element");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js
new file mode 100644
index 0000000000..7b3f2d68ba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from nextElement's toLocaleString => valueOf
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var calls = 0;
+
+Number.prototype.toLocaleString = function() {
+ return {
+ toString: function() {
+ calls++;
+ if (calls > 1) {
+ throw new Test262Error();
+ }
+ }
+ };
+};
+
+var arr = [42, 0];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA(arr);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 2, "abrupt from a nextElement");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js
new file mode 100644
index 0000000000..acc8eca436
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Return abrupt from nextElement's toLocaleString => valueOf
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var calls = 0;
+
+Number.prototype.toLocaleString = function() {
+ return {
+ toString: undefined,
+ valueOf: function() {
+ calls++;
+ if (calls > 1) {
+ throw new Test262Error();
+ }
+ }
+ };
+};
+
+var arr = [42, 0];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA(arr);
+ calls = 0;
+ assert.throws(Test262Error, function() {
+ sample.toLocaleString();
+ });
+ assert.sameValue(calls, 2, "abrupt from a nextElement");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..04a4238da7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.toLocaleString,
+ 'function',
+ 'implements TypedArray.prototype.toLocaleString'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.toLocaleString();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.toLocaleString();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the toLocaleString operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.toLocaleString();
+ throw new Test262Error('toLocaleString completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js
new file mode 100644
index 0000000000..60cd013f90
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/return-result.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Returns a string
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ %TypedArray%.prototype.toLocaleString is a distinct function that implements
+ the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27
+ except that the this object's [[ArrayLength]] internal slot is accessed in
+ place of performing a [[Get]] of "length".
+
+ 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )
+
+ ...
+ 5. Let firstElement be ? Get(array, "0").
+ 6. If firstElement is undefined or null, then
+ a. Let R be the empty String.
+ 7. Else,
+ a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")).
+ 8. Let k be 1.
+ 9.Repeat, while k < len
+ a. Let S be a String value produced by concatenating R and separator.
+ b. Let nextElement be ? Get(array, ! ToString(k)).
+ c. If nextElement is undefined or null, then
+ i. Let R be the empty String.
+ d. Else,
+ i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")).
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var separator = ["", ""].toLocaleString();
+
+var arr = [42, 0, 43];
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA(arr);
+ var expected =
+ sample[0].toLocaleString().toString() +
+ separator +
+ sample[1].toLocaleString().toString() +
+ separator +
+ sample[2].toLocaleString().toString();
+ assert.sameValue(sample.toLocaleString(), expected);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js
new file mode 100644
index 0000000000..2c471f761e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var toLocaleString = TypedArray.prototype.toLocaleString;
+
+assert.throws(TypeError, function() {
+ toLocaleString.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ toLocaleString.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ toLocaleString.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ toLocaleString.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ toLocaleString.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ toLocaleString.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ toLocaleString.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..b3c33fc0c2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tolocalestring
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ])
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var toLocaleString = TypedArray.prototype.toLocaleString;
+
+assert.throws(TypeError, function() {
+ toLocaleString.call({});
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ toLocaleString.call([]);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ toLocaleString.call(ab);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ toLocaleString.call(dv);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js
new file mode 100644
index 0000000000..361cadfe58
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/ignores-species.js
@@ -0,0 +1,44 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toReversed
+description: >
+ %TypedArray%.prototype.toReversed ignores @@species
+info: |
+ %TypedArray%.prototype.toReversed ( )
+
+ ...
+ 4. Let A be ? TypedArrayCreateSameType(O, « 𝔽(length) »).
+ ...
+
+ TypedArrayCreateSameType ( exemplar, argumentList )
+ ...
+ 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]].
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA();
+ ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array;
+ assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype);
+
+ ta = new TA();
+ ta.constructor = {
+ [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array,
+ };
+ assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype);
+
+ ta = new TA();
+ Object.defineProperty(ta, "constructor", {
+ get() {
+ throw new Test262Error("Should not get .constructor");
+ }
+ });
+ ta.toReversed();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js
new file mode 100644
index 0000000000..1e74812171
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/immutable.js
@@ -0,0 +1,21 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toReversed
+description: >
+ %TypedArray%.prototype.toReversed does not mutate its this value
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([0, 1, 2]);
+ ta.toReversed();
+
+ assert.compareArray(ta, [0, 1, 2]);
+ assert.notSameValue(ta.toReversed(), ta);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js
new file mode 100644
index 0000000000..b4c6f56470
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/length-property-ignored.js
@@ -0,0 +1,53 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toReversed
+description: >
+ %TypedArray%.prototype.toReversed does not read a "length" property
+info: |
+ %TypedArray%.prototype.toReversed ( )
+
+ ...
+ 3. Let length be O.[[ArrayLength]].
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([0, 1, 2]);
+ Object.defineProperty(ta, "length", { value: 2 })
+ var res = ta.toReversed();
+ assert.compareArray(res, [2, 1, 0]);
+ assert.sameValue(res.length, 3);
+
+ ta = new TA([0, 1, 2]);
+ Object.defineProperty(ta, "length", { value: 5 });
+ res = ta.toReversed();
+ assert.compareArray(res, [2, 1, 0]);
+ assert.sameValue(res.length, 3);
+});
+
+function setLength(length) {
+ Object.defineProperty(TypedArray.prototype, "length", {
+ get: () => length,
+ });
+}
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([0, 1, 2]);
+
+ setLength(2);
+ var res = ta.toReversed();
+ setLength(3);
+ assert.compareArray(res, [2, 1, 0]);
+
+ setLength(5);
+ res = ta.toReversed();
+ setLength(3);
+ assert.compareArray(res, [2, 1, 0]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js
new file mode 100644
index 0000000000..96d6407c1a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/length.js
@@ -0,0 +1,33 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toReversed
+description: >
+ The "length" property of %TypedArray%.prototype.toReversed
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, has a length property
+ whose value is an integer. Unless otherwise specified, this value is equal to
+ the largest number of named arguments shown in the subclause headings for the
+ function description. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are shown using the form «...name») are not
+ included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in function object
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+verifyProperty(TypedArray.prototype.toReversed, "length", {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js
new file mode 100644
index 0000000000..8d5c00e098
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/name.js
@@ -0,0 +1,31 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toReversed
+description: >
+ %TypedArray%.prototype.toReversed.name is "toReversed".
+info: |
+ %TypedArray%.prototype.toReversed ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+verifyProperty(TypedArray.prototype.toReversed, "name", {
+ value: "toReversed",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js
new file mode 100644
index 0000000000..acd093a292
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/property-descriptor.js
@@ -0,0 +1,28 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toReversed
+description: >
+ "toReversed" property of %TypedArray%.prototype
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+assert.sameValue(typeof TypedArray.prototype.toReversed, "function", "typeof");
+
+verifyProperty(TypedArray.prototype, "toReversed", {
+ value: TypedArray.prototype.toReversed,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/metadata/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js
new file mode 100644
index 0000000000..7eeb9e651c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/not-a-constructor.js
@@ -0,0 +1,36 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ %TypedArray%.prototype.toReversed does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy, Reflect.construct]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.toReversed),
+ false,
+ 'isConstructor(TypedArray.prototype.toReversed) must return false'
+);
+
+assert.throws(TypeError, () => {
+ new TypedArray.prototype.toReversed();
+}, '`new TypedArray.prototype.toReversed()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js
new file mode 100644
index 0000000000..cb15ea1240
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toReversed/this-value-invalid.js
@@ -0,0 +1,47 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toReversed
+description: >
+ %TypedArray%.prototype.toReversed throws if the receiver is not a valid TypedArray
+info: |
+ %TypedArray%.prototype.toReversed ( )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+var invalidValues = {
+ 'null': null,
+ 'undefined': undefined,
+ 'true': true,
+ '"abc"': "abc",
+ '12': 12,
+ 'Symbol()': Symbol(),
+ '[1, 2, 3]': [1, 2, 3],
+ '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 },
+ 'Uint8Array.prototype': Uint8Array.prototype,
+ '1n': 1n,
+};
+
+Object.entries(invalidValues).forEach(value => {
+ assert.throws(TypeError, () => {
+ TypedArray.prototype.toReversed.call(value[1]);
+ }, `${value[0]} is not a valid TypedArray`);
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ let buffer = new ArrayBuffer(8);
+ let sample = new TA(buffer, 0, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, () => {
+ sample.toReversed();
+ }, `array has a detached buffer`);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js
new file mode 100644
index 0000000000..9435129797
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-not-a-function.js
@@ -0,0 +1,30 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ %TypedArray%.prototype.toSorted verifies that the comparator is callable before reading the length.
+info: |
+ %TypedArray%.prototype.toSorted ( comparefn )
+
+ 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
+ 2. ...
+ 3. Let len be ? LengthOfArrayLike(O).
+includes: [testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+var invalidComparators = [null, true, false, "", /a/g, 42, 42n, [], {}, Symbol()];
+
+testWithTypedArrayConstructors(TA => {
+ const ta = new TA([1]);
+ for (var i = 0; i < invalidComparators.length; i++) {
+ assert.throws(TypeError, function() {
+ ta.toSorted(invalidComparators[i]);
+ }, String(invalidComparators[i]));
+ }
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js
new file mode 100644
index 0000000000..8eddfa985c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js
@@ -0,0 +1,36 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ %TypedArray%.prototype.toSorted doesn't call copmareFn if there is an error
+info: |
+ %TypedArray%.prototype.toSorted ( compareFn )
+
+ ...
+ 9. Sort items using an implementation-defined sequence of
+ calls to SortCompare. If any such call returns an abrupt
+ completion, stop before performing any further calls to
+ SortCompare or steps in this algorithm and return that completion.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var calls = 0;
+ var ta = new TA([3, 1, 2]);
+ try {
+ ta.toSorted(() => {
+ ++calls;
+ if (calls === 1) {
+ throw new Test262Error();
+ }
+ });
+ } catch (e) {}
+ assert.sameValue(calls <= 1, true, "compareFn is not called after an error");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js
new file mode 100644
index 0000000000..980a769545
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/ignores-species.js
@@ -0,0 +1,44 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ %TypedArray%.prototype.toSorted ignores @@species
+info: |
+ %TypedArray%.prototype.toSorted ( comparefn )
+
+ ...
+ 6. Let A be ? TypedArrayCreateSameType(O, « 𝔽(len) »).
+ ...
+
+ TypedArrayCreateSameType ( exemplar, argumentList )
+ ...
+ 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]].
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA();
+ ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array;
+ assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype);
+
+ ta = new TA();
+ ta.constructor = {
+ [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array,
+ };
+ assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype);
+
+ ta = new TA();
+ Object.defineProperty(ta, "constructor", {
+ get() {
+ throw new Test262Error("Should not get .constructor");
+ }
+ });
+ ta.toSorted();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js
new file mode 100644
index 0000000000..861e53d14e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/immutable.js
@@ -0,0 +1,21 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ %TypedArray%.prototype.toSorted does not mutate its this value
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([3, 1, 2]);
+ ta.toSorted();
+
+ assert.compareArray(ta, [3, 1, 2]);
+ assert.notSameValue(ta.toSorted(), ta);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js
new file mode 100644
index 0000000000..64511dc324
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js
@@ -0,0 +1,54 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ %TypedArray%.prototype.toSorted does not read a "length" property
+info: |
+ %TypedArray%.prototype.toSorted ( comparefn )
+
+ ...
+ 4. Let len be O.[[ArrayLength]].
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([3, 1, 2]);
+ Object.defineProperty(ta, "length", { value: 2 })
+ var res = ta.toSorted()
+ assert.compareArray(res, [1, 2, 3]);
+ assert.sameValue(res.length, 3);
+
+ ta = new TA([3, 1, 2]);
+ Object.defineProperty(ta, "length", { value: 5 });
+ res = ta.toSorted();
+ assert.compareArray(res, [1, 2, 3]);
+ assert.sameValue(res.length, 3);
+});
+
+function setLength(length) {
+ Object.defineProperty(TypedArray.prototype, "length", {
+ get: () => length,
+ });
+}
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([3, 1, 2]);
+
+ setLength(2);
+ var res = ta.toSorted();
+ setLength(3);
+ assert.compareArray(res, [1, 2, 3]);
+
+ setLength(5);
+ res = ta.toSorted();
+ setLength(3);
+
+ assert.compareArray(res, [1, 2, 3]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js
new file mode 100644
index 0000000000..5a9a625e33
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/length.js
@@ -0,0 +1,33 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ The "length" property of %TypedArray%.prototype.toSorted
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, has a length property
+ whose value is an integer. Unless otherwise specified, this value is equal to
+ the largest number of named arguments shown in the subclause headings for the
+ function description. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are shown using the form «...name») are not
+ included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in function object
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+verifyProperty(TypedArray.prototype.toSorted, "length", {
+ value: 1,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js
new file mode 100644
index 0000000000..cb7142622a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/name.js
@@ -0,0 +1,31 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ %TypedArray%.prototype.toSorted.name is "toSorted".
+info: |
+ %TypedArray%.prototype.toSorted ( comparefn )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+verifyProperty(TypedArray.prototype.toSorted, "name", {
+ value: "toSorted",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js
new file mode 100644
index 0000000000..2d4cd31d42
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js
@@ -0,0 +1,28 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ "toSorted" property of %TypedArray%.prototype
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+assert.sameValue(typeof TypedArray.prototype.toSorted, "function", "typeof");
+
+verifyProperty(TypedArray.prototype, "toSorted", {
+ value: TypedArray.prototype.toSorted,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/metadata/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js
new file mode 100644
index 0000000000..a2b960a50d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js
@@ -0,0 +1,36 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ %TypedArray%.prototype.toSorted does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy, Reflect.construct]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.toSorted),
+ false,
+ 'isConstructor(TypedArray.prototype.toSorted) must return false'
+);
+
+assert.throws(TypeError, () => {
+ new TypedArray.prototype.toSorted();
+}, '`new TypedArray.prototype.toSorted()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js
new file mode 100644
index 0000000000..37446545bf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toSorted/this-value-invalid.js
@@ -0,0 +1,47 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.toSorted
+description: >
+ %TypedArray%.prototype.toSorted throws if the receiver is not a valid TypedArray
+info: |
+ %TypedArray%.prototype.toSorted ( comparefn )
+
+ 2. Let O be the this value.
+ 3. Perform ? ValidateTypedArray(O).
+ ...
+includes: [detachArrayBuffer.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+var invalidValues = {
+ 'null': null,
+ 'undefined': undefined,
+ 'true': true,
+ '"abc"': "abc",
+ '12': 12,
+ 'Symbol()': Symbol(),
+ '[1, 2, 3]': [1, 2, 3],
+ '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 },
+ 'Uint8Array.prototype': Uint8Array.prototype,
+ '1n': 1n,
+};
+
+Object.entries(invalidValues).forEach(value => {
+ assert.throws(TypeError, () => {
+ TypedArray.prototype.toSorted.call(value[1]);
+ }, `${value[0]} is not a valid TypedArray`);
+});
+
+testWithTypedArrayConstructors(function(TA) {
+ let buffer = new ArrayBuffer(8);
+ let sample = new TA(buffer, 0, 1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, () => {
+ sample.toSorted();
+ }, `array has a detached buffer`);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString.js
new file mode 100644
index 0000000000..5b19a806fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tostring
+description: >
+ "toString" property of TypedArrayPrototype
+info: |
+ 22.2.3.28 %TypedArray%.prototype.toString ( )
+
+ The initial value of the %TypedArray%.prototype.toString data property is the
+ same built-in function object as the Array.prototype.toString method defined
+ in 22.1.3.27.
+
+ ES6 section 17: Every other data property described in clauses 18 through 26
+ and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(TypedArrayPrototype.toString, Array.prototype.toString);
+
+verifyNotEnumerable(TypedArrayPrototype, 'toString');
+verifyWritable(TypedArrayPrototype, 'toString');
+verifyConfigurable(TypedArrayPrototype, 'toString');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..533453c94a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tostring
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.29 %TypedArray%.prototype.toString ()
+
+ ...
+
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.toString();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js
new file mode 100644
index 0000000000..427bf7fcf6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/detached-buffer.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.tostring
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.29 %TypedArray%.prototype.toString ()
+
+ ...
+
+ 22.2.3.15 %TypedArray%.prototype.join ( separator )
+
+ This function is not generic. ValidateTypedArray is applied to the this value
+ prior to evaluating the algorithm. If its result is an abrupt completion that
+ exception is thrown instead of evaluating the algorithm.
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.toString();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js
new file mode 100644
index 0000000000..745ac903df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.toString does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.toString),
+ false,
+ 'isConstructor(TypedArray.prototype.toString) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.toString();
+}, '`let u8 = new Uint8Array(1); new u8.toString()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/toString/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/toString/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js
new file mode 100644
index 0000000000..a85532ab0d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/detached-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.values();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/iter-prototype.js
new file mode 100644
index 0000000000..e4606fccf8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/iter-prototype.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.values
+description: >
+ The prototype of the returned iterator is ArrayIteratorPrototype
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "value").
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.iterator, TypedArray]
+---*/
+
+var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]());
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var sample = new TA([0n, 42n, 64n]);
+ var iter = sample.values();
+
+ assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..adaab3ae2b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testBigIntTypedArray.js]
+features: [ArrayBuffer, BigInt, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.values,
+ 'function',
+ 'implements TypedArray.prototype.values'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithBigIntTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.values();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.values();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the values operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.values();
+ throw new Test262Error('values completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-itor.js
new file mode 100644
index 0000000000..deacd8b72e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/return-itor.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Return an iterator for the values.
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "value").
+includes: [testBigIntTypedArray.js]
+features: [BigInt, TypedArray]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var typedArray = new TA([0n, 42n, 64n]);
+ var itor = typedArray.values();
+
+ var next = itor.next();
+ assert.sameValue(next.value, 0n);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 42n);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 64n);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, undefined);
+ assert.sameValue(next.done, true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js
new file mode 100644
index 0000000000..732b108995
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/detached-buffer.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Throws a TypeError if this has a detached buffer
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ ...
+ 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js, detachArrayBuffer.js]
+features: [TypedArray]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample = new TA(1);
+ $DETACHBUFFER(sample.buffer);
+ assert.throws(TypeError, function() {
+ sample.values();
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js
new file mode 100644
index 0000000000..6baf62480c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-func.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Throws a TypeError exception when invoked as a function
+info: |
+ 22.2.3.29 %TypedArray%.prototype.values ( )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var values = TypedArray.prototype.values;
+
+assert.sameValue(typeof values, 'function');
+
+assert.throws(TypeError, function() {
+ values();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js
new file mode 100644
index 0000000000..9b2e7689f7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/invoked-as-method.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Requires a [[TypedArrayName]] internal slot.
+info: |
+ 22.2.3.29 %TypedArray%.prototype.values ( )
+
+ 1. Let O be the this value.
+ 2. Let valid be ValidateTypedArray(O).
+ 3. ReturnIfAbrupt(valid).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+assert.sameValue(typeof TypedArrayPrototype.values, 'function');
+
+assert.throws(TypeError, function() {
+ TypedArrayPrototype.values();
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js
new file mode 100644
index 0000000000..2ebe86343d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/iter-prototype.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.values
+description: >
+ The prototype of the returned iterator is ArrayIteratorPrototype
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "value").
+includes: [testTypedArray.js]
+features: [Symbol.iterator, TypedArray]
+---*/
+
+var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]());
+
+testWithTypedArrayConstructors(function(TA, N) {
+ var sample = new TA([0, 42, 64]);
+ var iter = sample.values();
+
+ assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js
new file mode 100644
index 0000000000..11e022a134
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.values
+description: >
+ %TypedArray%.prototype.values.length is 0.
+info: |
+ %TypedArray%.prototype.values ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.values.length, 0);
+
+verifyNotEnumerable(TypedArray.prototype.values, "length");
+verifyNotWritable(TypedArray.prototype.values, "length");
+verifyConfigurable(TypedArray.prototype.values, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js
new file mode 100644
index 0000000000..eacaf7f45e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.values
+description: >
+ %TypedArray%.prototype.values.name is "values".
+info: |
+ %TypedArray%.prototype.values ( )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+assert.sameValue(TypedArray.prototype.values.name, "values");
+
+verifyNotEnumerable(TypedArray.prototype.values, "name");
+verifyNotWritable(TypedArray.prototype.values, "name");
+verifyConfigurable(TypedArray.prototype.values, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js
new file mode 100644
index 0000000000..21b26b428f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/not-a-constructor.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ TypedArray.prototype.values does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [Reflect.construct, arrow-function, TypedArray]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.values),
+ false,
+ 'isConstructor(TypedArray.prototype.values) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let u8 = new Uint8Array(1); new u8.values();
+}, '`let u8 = new Uint8Array(1); new u8.values()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js
new file mode 100644
index 0000000000..3317588756
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: >
+ "values" property of TypedArrayPrototype
+info: |
+ ES6 section 17: Every other data property described in clauses 18 through
+ 26 and in Annex B.2 has the attributes { [[Writable]]: true,
+ [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js, testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var TypedArrayPrototype = TypedArray.prototype;
+
+verifyNotEnumerable(TypedArrayPrototype, 'values');
+verifyWritable(TypedArrayPrototype, 'values');
+verifyConfigurable(TypedArrayPrototype, 'values');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js
new file mode 100644
index 0000000000..3c6a3decc8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js
@@ -0,0 +1,62 @@
+// |reftest| skip -- resizable-arraybuffer is not supported
+// Copyright (C) 2021 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Return abrupt when "this" value fails buffer boundary checks
+includes: [testTypedArray.js]
+features: [ArrayBuffer, TypedArray, arrow-function, resizable-arraybuffer]
+---*/
+
+assert.sameValue(
+ typeof TypedArray.prototype.values,
+ 'function',
+ 'implements TypedArray.prototype.values'
+);
+
+assert.sameValue(
+ typeof ArrayBuffer.prototype.resize,
+ 'function',
+ 'implements ArrayBuffer.prototype.resize'
+);
+
+testWithTypedArrayConstructors(TA => {
+ var BPE = TA.BYTES_PER_ELEMENT;
+ var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5});
+ var array = new TA(ab, BPE, 2);
+
+ try {
+ ab.resize(BPE * 5);
+ } catch (_) {}
+
+ // no error following grow:
+ array.values();
+
+ try {
+ ab.resize(BPE * 3);
+ } catch (_) {}
+
+ // no error following shrink (within bounds):
+ array.values();
+
+ var expectedError;
+ try {
+ ab.resize(BPE * 2);
+ // If the preceding "resize" operation is successful, the typed array will
+ // be out out of bounds, so the subsequent prototype method should produce
+ // a TypeError due to the semantics of ValidateTypedArray.
+ expectedError = TypeError;
+ } catch (_) {
+ // The host is permitted to fail any "resize" operation at its own
+ // discretion. If that occurs, the values operation should complete
+ // successfully.
+ expectedError = Test262Error;
+ }
+
+ assert.throws(expectedError, () => {
+ array.values();
+ throw new Test262Error('values completed successfully');
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js
new file mode 100644
index 0000000000..5ebdfa17d5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/return-itor.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Return an iterator for the values.
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ ...
+ 3. Return CreateArrayIterator(O, "value").
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var sample = [0, 42, 64];
+
+testWithTypedArrayConstructors(function(TA) {
+ var typedArray = new TA(sample);
+ var itor = typedArray.values();
+
+ var next = itor.next();
+ assert.sameValue(next.value, 0);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 42);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, 64);
+ assert.sameValue(next.done, false);
+
+ next = itor.next();
+ assert.sameValue(next.value, undefined);
+ assert.sameValue(next.done, true);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js
new file mode 100644
index 0000000000..0169af4e91
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-object.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: Throws a TypeError exception when `this` is not Object
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [Symbol, TypedArray]
+---*/
+
+var values = TypedArray.prototype.values;
+
+assert.throws(TypeError, function() {
+ values.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ values.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ values.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ values.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ values.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ values.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ values.call(s);
+}, "this is a Symbol");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js
new file mode 100644
index 0000000000..7afa67e4a5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.values
+description: >
+ Throws a TypeError exception when `this` is not a TypedArray instance
+info: |
+ 22.2.3.30 %TypedArray%.prototype.values ( )
+
+ The following steps are taken:
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+
+ 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
+
+ 1. If Type(O) is not Object, throw a TypeError exception.
+ 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError
+ exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray]
+---*/
+
+var values = TypedArray.prototype.values;
+
+assert.throws(TypeError, function() {
+ values.call({});
+}, "this is an Object");
+
+assert.throws(TypeError, function() {
+ values.call([]);
+}, "this is an Array");
+
+var ab = new ArrayBuffer(8);
+assert.throws(TypeError, function() {
+ values.call(ab);
+}, "this is an ArrayBuffer instance");
+
+var dv = new DataView(new ArrayBuffer(8), 0, 1);
+assert.throws(TypeError, function() {
+ values.call(dv);
+}, "this is a DataView instance");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js
new file mode 100644
index 0000000000..0c32af8a93
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js
@@ -0,0 +1,34 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with invokes ToNumber before copying
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 7. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_).
+ 8. Else, set _value_ to ? ToNumber(_value_).
+ ...
+features: [BigInt, TypedArray, change-array-by-copy]
+includes: [testBigIntTypedArray.js, compareArray.js]
+---*/
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var arr = new TA([0n, 1n, 2n]);
+
+ var value = {
+ valueOf() {
+ arr[0] = 3n;
+ return 4n;
+ }
+ };
+
+ assert.compareArray(arr.with(1, value), [3n, 4n, 2n]);
+ assert.compareArray(arr, [3n, 1n, 2n]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/shell.js
new file mode 100644
index 0000000000..90ee9c114d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/BigInt/shell.js
@@ -0,0 +1,42 @@
+// GENERATED, DO NOT EDIT
+// file: testBigIntTypedArray.js
+// 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.
+defines:
+ - TypedArray
+ - testWithBigIntTypedArrayConstructors
+---*/
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithBigIntTypedArrayConstructors(f, selected) {
+ /**
+ * Array containing every BigInt typed array constructor.
+ */
+ var constructors = selected || [
+ BigInt64Array,
+ BigUint64Array
+ ];
+
+ 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;
+ }
+ }
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js
new file mode 100644
index 0000000000..b0e012ebed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/early-type-coercion.js
@@ -0,0 +1,34 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with invokes ToNumber before copying
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 7. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_).
+ 8. Else, set _value_ to ? ToNumber(_value_).
+ ...
+features: [TypedArray, change-array-by-copy]
+includes: [testTypedArray.js, compareArray.js]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var arr = new TA([0, 1, 2]);
+
+ var value = {
+ valueOf() {
+ arr[0] = 3;
+ return 4;
+ }
+ };
+
+ assert.compareArray(arr.with(1, value), [3, 4, 2]);
+ assert.compareArray(arr, [3, 1, 2]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js
new file mode 100644
index 0000000000..7049fcf2a7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/ignores-species.js
@@ -0,0 +1,44 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with ignores @@species
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 10. Let A be ? TypedArrayCreateSameType(O, « 𝔽(len) »).
+ ...
+
+ TypedArrayCreateSameType ( exemplar, argumentList )
+ ...
+ 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]].
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([1, 2, 3]);
+ ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array;
+ assert.sameValue(Object.getPrototypeOf(ta.with(0, 2)), TA.prototype);
+
+ ta = new TA([1, 2, 3]);
+ ta.constructor = {
+ [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array,
+ };
+ assert.sameValue(Object.getPrototypeOf(ta.with(0, 2)), TA.prototype);
+
+ ta = new TA([1, 2, 3]);
+ Object.defineProperty(ta, "constructor", {
+ get() {
+ throw new Test262Error("Should not get .constructor");
+ }
+ });
+ ta.with(0, 2);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js
new file mode 100644
index 0000000000..97746a08f0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/immutable.js
@@ -0,0 +1,22 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with does not mutate its this value
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([3, 1, 2]);
+ ta.with(0, 2);
+
+ assert.compareArray(ta, [3, 1, 2]);
+ assert.notSameValue(ta.with(0, 2), ta);
+ assert.notSameValue(ta.with(0, 3), ta);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js
new file mode 100644
index 0000000000..02eb24acac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js
@@ -0,0 +1,43 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-typed%array%.prototype.with
+description: >
+ %TypedArray%.prototype.with throws if the index is bigger than or equal to the array length.
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 3. Let len be O.[[ArrayLength]].
+ 3. Let relativeIndex be ? ToIntegerOrInfinity(index).
+ 4. If index >= 0, let actualIndex be relativeIndex.
+ 5. Else, let actualIndex be len + relativeIndex.
+ 6. If ! IsValidIntegerIndex(O, actualIndex) is false, throw a *RangeError* exception.
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var arr = new TA([0, 1, 2]);
+
+ assert.throws(RangeError, function() {
+ arr.with(3, 7);
+ });
+
+ assert.throws(RangeError, function() {
+ arr.with(10, 7);
+ });
+
+ assert.throws(RangeError, function() {
+ arr.with(2 ** 53 + 2, 7);
+ });
+
+ assert.throws(RangeError, function() {
+ arr.with(Infinity, 7);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js
new file mode 100644
index 0000000000..9b5993be7a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-casted-to-number.js
@@ -0,0 +1,32 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with casts the index to an integer.
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 2. Let len be ? LengthOfArrayLike(O).
+ 3. Let relativeIndex be ? ToIntegerOrInfinity(index).
+ 4. If index >= 0, let actualIndex be relativeIndex.
+ 5. Else, let actualIndex be len + relativeIndex.
+ ...
+features: [TypedArray, change-array-by-copy]
+includes: [testTypedArray.js, compareArray.js]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var arr = new TA([0, 4, 16]);
+
+ assert.compareArray(arr.with(1.2, 7), [0, 7, 16]);
+ assert.compareArray(arr.with("1", 3), [0, 3, 16]);
+ assert.compareArray(arr.with("-1", 5), [0, 4, 5]);
+ assert.compareArray(arr.with(NaN, 2), [2, 4, 16]);
+ assert.compareArray(arr.with("dog", 33), [33, 4, 16]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js
new file mode 100644
index 0000000000..3ac59b6926
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-negative.js
@@ -0,0 +1,31 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with adds length to index if it's negative.
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 2. Let len be ? LengthOfArrayLike(O).
+ 3. Let relativeIndex be ? ToIntegerOrInfinity(index).
+ 4. If index >= 0, let actualIndex be relativeIndex.
+ 5. Else, let actualIndex be len + relativeIndex.
+ ...
+features: [TypedArray, change-array-by-copy]
+includes: [testTypedArray.js, compareArray.js]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var arr = new TA([0, 1, 2]);
+
+ assert.compareArray(arr.with(-1, 4), [0, 1, 4]);
+ assert.compareArray(arr.with(-3, 4), [4, 1, 2]);
+ // -0 is not negative.
+ assert.compareArray(arr.with(-0, 4), [4, 1, 2]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js
new file mode 100644
index 0000000000..a9e9d2c8c6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js
@@ -0,0 +1,43 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with throws if the (negative) index is smaller than -length.
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 2. Let len be ? LengthOfArrayLike(O).
+ 3. Let relativeIndex be ? ToIntegerOrInfinity(index).
+ 4. If index >= 0, let actualIndex be relativeIndex.
+ 5. Else, let actualIndex be len + relativeIndex.
+ 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception.
+ ...
+features: [TypedArray, change-array-by-copy]
+includes: [testTypedArray.js]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var arr = new TA([0, 1, 2]);
+
+ assert.throws(RangeError, function() {
+ arr.with(-4, 7);
+ });
+
+ assert.throws(RangeError, function() {
+ arr.with(-10, 7);
+ });
+
+ assert.throws(RangeError, function() {
+ arr.with(-(2 ** 53) - 2, 7);
+ });
+
+ assert.throws(RangeError, function() {
+ arr.with(-Infinity, 7);
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js
new file mode 100644
index 0000000000..a7217ba15b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/length-property-ignored.js
@@ -0,0 +1,53 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with reads the TypedArray length ignoring the .length property
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ ...
+ 3. Let len be O.[[ArrayLength]].
+ ...
+includes: [testTypedArray.js, compareArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([3, 1, 2]);
+ Object.defineProperty(ta, "length", { value: 2 })
+ var res = ta.with(0, 0);
+ assert.compareArray(res, [0, 1, 2]);
+ assert.sameValue(res.length, 3);
+
+ ta = new TA([3, 1, 2]);
+ Object.defineProperty(ta, "length", { value: 5 });
+ res = ta.with(0, 0);
+ assert.compareArray(res, [0, 1, 2]);
+ assert.sameValue(res.length, 3);
+});
+
+function setLength(length) {
+ Object.defineProperty(TypedArray.prototype, "length", {
+ get: () => length,
+ });
+}
+
+testWithTypedArrayConstructors(TA => {
+ var ta = new TA([3, 1, 2]);
+
+ setLength(2);
+ var res = ta.with(0, 0);
+ setLength(3);
+ assert.compareArray(res, [0, 1, 2]);
+
+ setLength(5);
+ res = ta.with(0, 0);
+ setLength(3);
+ assert.compareArray(res, [0, 1, 2]);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/browser.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/browser.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js
new file mode 100644
index 0000000000..bc67b8ca53
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/length.js
@@ -0,0 +1,33 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ The "length" property of %TypedArray%.prototype.with
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every built-in function object, including constructors, has a length property
+ whose value is an integer. Unless otherwise specified, this value is equal to
+ the largest number of named arguments shown in the subclause headings for the
+ function description. Optional parameters (which are indicated with brackets:
+ [ ]) or rest parameters (which are shown using the form «...name») are not
+ included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in function object
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [testTypedArray.js, propertyHelper.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+verifyProperty(TypedArray.prototype.with, "length", {
+ value: 2,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js
new file mode 100644
index 0000000000..f223fac392
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/name.js
@@ -0,0 +1,31 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with.name is "with".
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [testTypedArray.js, propertyHelper.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+verifyProperty(TypedArray.prototype.with, "name", {
+ value: "with",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js
new file mode 100644
index 0000000000..f892d722a9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/property-descriptor.js
@@ -0,0 +1,28 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ "with" property of %TypedArray%.prototype
+info: |
+ 17 ECMAScript Standard Built-in Objects
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [testTypedArray.js, propertyHelper.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+assert.sameValue(typeof TypedArray.prototype.with, "function", "typeof");
+
+verifyProperty(TypedArray.prototype, "with", {
+ value: TypedArray.prototype.with,
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/metadata/shell.js
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js
new file mode 100644
index 0000000000..fb1cd4b92c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/not-a-constructor.js
@@ -0,0 +1,36 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ %TypedArray%.prototype.with does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js, testTypedArray.js]
+features: [TypedArray, change-array-by-copy, Reflect.construct]
+---*/
+
+assert.sameValue(
+ isConstructor(TypedArray.prototype.with),
+ false,
+ 'isConstructor(TypedArray.prototype.with) must return false'
+);
+
+assert.throws(TypeError, () => {
+ new TypedArray.prototype.with(0, 1);
+}, '`new %TypedArray%.prototype.with()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/shell.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js b/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js
new file mode 100644
index 0000000000..c256138afe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/prototype/with/this-value-invalid.js
@@ -0,0 +1,38 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Array.prototype.with||!xulRuntime.shell) -- change-array-by-copy is not enabled unconditionally, requires shell-options
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.with
+description: >
+ %TypedArray%.prototype.with throws if the receiver is null or undefined
+info: |
+ %TypedArray%.prototype.with ( index, value )
+
+ 1. Let O be the this value.
+ 2. Perform ? ValidateTypedArray(O).
+ ...
+includes: [testTypedArray.js]
+features: [TypedArray, change-array-by-copy]
+---*/
+
+var invalidValues = {
+ 'null': null,
+ 'undefined': undefined,
+ 'true': true,
+ '"abc"': "abc",
+ '12': 12,
+ 'Symbol()': Symbol(),
+ '[1, 2, 3]': [1, 2, 3],
+ '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 },
+ 'Uint8Array.prototype': Uint8Array.prototype,
+};
+
+Object.keys(invalidValues).forEach(desc => {
+ var value = invalidValues[desc];
+ assert.throws(TypeError, () => {
+ TypedArray.prototype.with.call(value, 0, 0);
+ }, `${desc} is not a valid TypedArray`);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/TypedArray/shell.js b/js/src/tests/test262/built-ins/TypedArray/shell.js
new file mode 100644
index 0000000000..abdb960ca1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArray/shell.js
@@ -0,0 +1,614 @@
+// GENERATED, DO NOT EDIT
+// file: byteConversionValues.js
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ Provide a list for original and expected values for different byte
+ conversions.
+ This helper is mostly used on tests for TypedArray and DataView, and each
+ array from the expected values must match the original values array on every
+ index containing its original value.
+defines: [byteConversionValues]
+---*/
+var byteConversionValues = {
+ values: [
+ 127, // 2 ** 7 - 1
+ 128, // 2 ** 7
+ 32767, // 2 ** 15 - 1
+ 32768, // 2 ** 15
+ 2147483647, // 2 ** 31 - 1
+ 2147483648, // 2 ** 31
+ 255, // 2 ** 8 - 1
+ 256, // 2 ** 8
+ 65535, // 2 ** 16 - 1
+ 65536, // 2 ** 16
+ 4294967295, // 2 ** 32 - 1
+ 4294967296, // 2 ** 32
+ 9007199254740991, // 2 ** 53 - 1
+ 9007199254740992, // 2 ** 53
+ 1.1,
+ 0.1,
+ 0.5,
+ 0.50000001,
+ 0.6,
+ 0.7,
+ undefined,
+ -1,
+ -0,
+ -0.1,
+ -1.1,
+ NaN,
+ -127, // - ( 2 ** 7 - 1 )
+ -128, // - ( 2 ** 7 )
+ -32767, // - ( 2 ** 15 - 1 )
+ -32768, // - ( 2 ** 15 )
+ -2147483647, // - ( 2 ** 31 - 1 )
+ -2147483648, // - ( 2 ** 31 )
+ -255, // - ( 2 ** 8 - 1 )
+ -256, // - ( 2 ** 8 )
+ -65535, // - ( 2 ** 16 - 1 )
+ -65536, // - ( 2 ** 16 )
+ -4294967295, // - ( 2 ** 32 - 1 )
+ -4294967296, // - ( 2 ** 32 )
+ Infinity,
+ -Infinity,
+ 0
+ ],
+
+ expected: {
+ Int8: [
+ 127, // 127
+ -128, // 128
+ -1, // 32767
+ 0, // 32768
+ -1, // 2147483647
+ 0, // 2147483648
+ -1, // 255
+ 0, // 256
+ -1, // 65535
+ 0, // 65536
+ -1, // 4294967295
+ 0, // 4294967296
+ -1, // 9007199254740991
+ 0, // 9007199254740992
+ 1, // 1.1
+ 0, // 0.1
+ 0, // 0.5
+ 0, // 0.50000001,
+ 0, // 0.6
+ 0, // 0.7
+ 0, // undefined
+ -1, // -1
+ 0, // -0
+ 0, // -0.1
+ -1, // -1.1
+ 0, // NaN
+ -127, // -127
+ -128, // -128
+ 1, // -32767
+ 0, // -32768
+ 1, // -2147483647
+ 0, // -2147483648
+ 1, // -255
+ 0, // -256
+ 1, // -65535
+ 0, // -65536
+ 1, // -4294967295
+ 0, // -4294967296
+ 0, // Infinity
+ 0, // -Infinity
+ 0
+ ],
+ Uint8: [
+ 127, // 127
+ 128, // 128
+ 255, // 32767
+ 0, // 32768
+ 255, // 2147483647
+ 0, // 2147483648
+ 255, // 255
+ 0, // 256
+ 255, // 65535
+ 0, // 65536
+ 255, // 4294967295
+ 0, // 4294967296
+ 255, // 9007199254740991
+ 0, // 9007199254740992
+ 1, // 1.1
+ 0, // 0.1
+ 0, // 0.5
+ 0, // 0.50000001,
+ 0, // 0.6
+ 0, // 0.7
+ 0, // undefined
+ 255, // -1
+ 0, // -0
+ 0, // -0.1
+ 255, // -1.1
+ 0, // NaN
+ 129, // -127
+ 128, // -128
+ 1, // -32767
+ 0, // -32768
+ 1, // -2147483647
+ 0, // -2147483648
+ 1, // -255
+ 0, // -256
+ 1, // -65535
+ 0, // -65536
+ 1, // -4294967295
+ 0, // -4294967296
+ 0, // Infinity
+ 0, // -Infinity
+ 0
+ ],
+ Uint8Clamped: [
+ 127, // 127
+ 128, // 128
+ 255, // 32767
+ 255, // 32768
+ 255, // 2147483647
+ 255, // 2147483648
+ 255, // 255
+ 255, // 256
+ 255, // 65535
+ 255, // 65536
+ 255, // 4294967295
+ 255, // 4294967296
+ 255, // 9007199254740991
+ 255, // 9007199254740992
+ 1, // 1.1,
+ 0, // 0.1
+ 0, // 0.5
+ 1, // 0.50000001,
+ 1, // 0.6
+ 1, // 0.7
+ 0, // undefined
+ 0, // -1
+ 0, // -0
+ 0, // -0.1
+ 0, // -1.1
+ 0, // NaN
+ 0, // -127
+ 0, // -128
+ 0, // -32767
+ 0, // -32768
+ 0, // -2147483647
+ 0, // -2147483648
+ 0, // -255
+ 0, // -256
+ 0, // -65535
+ 0, // -65536
+ 0, // -4294967295
+ 0, // -4294967296
+ 255, // Infinity
+ 0, // -Infinity
+ 0
+ ],
+ Int16: [
+ 127, // 127
+ 128, // 128
+ 32767, // 32767
+ -32768, // 32768
+ -1, // 2147483647
+ 0, // 2147483648
+ 255, // 255
+ 256, // 256
+ -1, // 65535
+ 0, // 65536
+ -1, // 4294967295
+ 0, // 4294967296
+ -1, // 9007199254740991
+ 0, // 9007199254740992
+ 1, // 1.1
+ 0, // 0.1
+ 0, // 0.5
+ 0, // 0.50000001,
+ 0, // 0.6
+ 0, // 0.7
+ 0, // undefined
+ -1, // -1
+ 0, // -0
+ 0, // -0.1
+ -1, // -1.1
+ 0, // NaN
+ -127, // -127
+ -128, // -128
+ -32767, // -32767
+ -32768, // -32768
+ 1, // -2147483647
+ 0, // -2147483648
+ -255, // -255
+ -256, // -256
+ 1, // -65535
+ 0, // -65536
+ 1, // -4294967295
+ 0, // -4294967296
+ 0, // Infinity
+ 0, // -Infinity
+ 0
+ ],
+ Uint16: [
+ 127, // 127
+ 128, // 128
+ 32767, // 32767
+ 32768, // 32768
+ 65535, // 2147483647
+ 0, // 2147483648
+ 255, // 255
+ 256, // 256
+ 65535, // 65535
+ 0, // 65536
+ 65535, // 4294967295
+ 0, // 4294967296
+ 65535, // 9007199254740991
+ 0, // 9007199254740992
+ 1, // 1.1
+ 0, // 0.1
+ 0, // 0.5
+ 0, // 0.50000001,
+ 0, // 0.6
+ 0, // 0.7
+ 0, // undefined
+ 65535, // -1
+ 0, // -0
+ 0, // -0.1
+ 65535, // -1.1
+ 0, // NaN
+ 65409, // -127
+ 65408, // -128
+ 32769, // -32767
+ 32768, // -32768
+ 1, // -2147483647
+ 0, // -2147483648
+ 65281, // -255
+ 65280, // -256
+ 1, // -65535
+ 0, // -65536
+ 1, // -4294967295
+ 0, // -4294967296
+ 0, // Infinity
+ 0, // -Infinity
+ 0
+ ],
+ Int32: [
+ 127, // 127
+ 128, // 128
+ 32767, // 32767
+ 32768, // 32768
+ 2147483647, // 2147483647
+ -2147483648, // 2147483648
+ 255, // 255
+ 256, // 256
+ 65535, // 65535
+ 65536, // 65536
+ -1, // 4294967295
+ 0, // 4294967296
+ -1, // 9007199254740991
+ 0, // 9007199254740992
+ 1, // 1.1
+ 0, // 0.1
+ 0, // 0.5
+ 0, // 0.50000001,
+ 0, // 0.6
+ 0, // 0.7
+ 0, // undefined
+ -1, // -1
+ 0, // -0
+ 0, // -0.1
+ -1, // -1.1
+ 0, // NaN
+ -127, // -127
+ -128, // -128
+ -32767, // -32767
+ -32768, // -32768
+ -2147483647, // -2147483647
+ -2147483648, // -2147483648
+ -255, // -255
+ -256, // -256
+ -65535, // -65535
+ -65536, // -65536
+ 1, // -4294967295
+ 0, // -4294967296
+ 0, // Infinity
+ 0, // -Infinity
+ 0
+ ],
+ Uint32: [
+ 127, // 127
+ 128, // 128
+ 32767, // 32767
+ 32768, // 32768
+ 2147483647, // 2147483647
+ 2147483648, // 2147483648
+ 255, // 255
+ 256, // 256
+ 65535, // 65535
+ 65536, // 65536
+ 4294967295, // 4294967295
+ 0, // 4294967296
+ 4294967295, // 9007199254740991
+ 0, // 9007199254740992
+ 1, // 1.1
+ 0, // 0.1
+ 0, // 0.5
+ 0, // 0.50000001,
+ 0, // 0.6
+ 0, // 0.7
+ 0, // undefined
+ 4294967295, // -1
+ 0, // -0
+ 0, // -0.1
+ 4294967295, // -1.1
+ 0, // NaN
+ 4294967169, // -127
+ 4294967168, // -128
+ 4294934529, // -32767
+ 4294934528, // -32768
+ 2147483649, // -2147483647
+ 2147483648, // -2147483648
+ 4294967041, // -255
+ 4294967040, // -256
+ 4294901761, // -65535
+ 4294901760, // -65536
+ 1, // -4294967295
+ 0, // -4294967296
+ 0, // Infinity
+ 0, // -Infinity
+ 0
+ ],
+ Float32: [
+ 127, // 127
+ 128, // 128
+ 32767, // 32767
+ 32768, // 32768
+ 2147483648, // 2147483647
+ 2147483648, // 2147483648
+ 255, // 255
+ 256, // 256
+ 65535, // 65535
+ 65536, // 65536
+ 4294967296, // 4294967295
+ 4294967296, // 4294967296
+ 9007199254740992, // 9007199254740991
+ 9007199254740992, // 9007199254740992
+ 1.100000023841858, // 1.1
+ 0.10000000149011612, // 0.1
+ 0.5, // 0.5
+ 0.5, // 0.50000001,
+ 0.6000000238418579, // 0.6
+ 0.699999988079071, // 0.7
+ NaN, // undefined
+ -1, // -1
+ -0, // -0
+ -0.10000000149011612, // -0.1
+ -1.100000023841858, // -1.1
+ NaN, // NaN
+ -127, // -127
+ -128, // -128
+ -32767, // -32767
+ -32768, // -32768
+ -2147483648, // -2147483647
+ -2147483648, // -2147483648
+ -255, // -255
+ -256, // -256
+ -65535, // -65535
+ -65536, // -65536
+ -4294967296, // -4294967295
+ -4294967296, // -4294967296
+ Infinity, // Infinity
+ -Infinity, // -Infinity
+ 0
+ ],
+ Float64: [
+ 127, // 127
+ 128, // 128
+ 32767, // 32767
+ 32768, // 32768
+ 2147483647, // 2147483647
+ 2147483648, // 2147483648
+ 255, // 255
+ 256, // 256
+ 65535, // 65535
+ 65536, // 65536
+ 4294967295, // 4294967295
+ 4294967296, // 4294967296
+ 9007199254740991, // 9007199254740991
+ 9007199254740992, // 9007199254740992
+ 1.1, // 1.1
+ 0.1, // 0.1
+ 0.5, // 0.5
+ 0.50000001, // 0.50000001,
+ 0.6, // 0.6
+ 0.7, // 0.7
+ NaN, // undefined
+ -1, // -1
+ -0, // -0
+ -0.1, // -0.1
+ -1.1, // -1.1
+ NaN, // NaN
+ -127, // -127
+ -128, // -128
+ -32767, // -32767
+ -32768, // -32768
+ -2147483647, // -2147483647
+ -2147483648, // -2147483648
+ -255, // -255
+ -256, // -256
+ -65535, // -65535
+ -65536, // -65536
+ -4294967295, // -4294967295
+ -4294967296, // -4294967296
+ Infinity, // Infinity
+ -Infinity, // -Infinity
+ 0
+ ]
+ }
+};
+
+// file: detachArrayBuffer.js
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ A function used in the process of asserting correctness of TypedArray objects.
+
+ $262.detachArrayBuffer is defined by a host.
+defines: [$DETACHBUFFER]
+---*/
+
+function $DETACHBUFFER(buffer) {
+ if (!$262 || typeof $262.detachArrayBuffer !== "function") {
+ throw new Test262Error("No method available to detach an ArrayBuffer");
+ }
+ $262.detachArrayBuffer(buffer);
+}
+
+// file: nans.js
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ A collection of NaN values produced from expressions that have been observed
+ to create distinct bit representations on various platforms. These provide a
+ weak basis for assertions regarding the consistent canonicalization of NaN
+ values in Array buffers.
+defines: [NaNs]
+---*/
+
+var NaNs = [
+ NaN,
+ Number.NaN,
+ NaN * 0,
+ 0/0,
+ Infinity/Infinity,
+ -(0/0),
+ Math.pow(-1, 0.5),
+ -Math.pow(-1, 0.5),
+ Number("Not-a-Number"),
+];
+
+// file: testTypedArray.js
+// 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 TypedArray objects.
+defines:
+ - typedArrayConstructors
+ - floatArrayConstructors
+ - intArrayConstructors
+ - TypedArray
+ - testWithTypedArrayConstructors
+ - testWithAtomicsFriendlyTypedArrayConstructors
+ - testWithNonAtomicsFriendlyTypedArrayConstructors
+ - testTypedArrayConversions
+---*/
+
+/**
+ * Array containing every typed array constructor.
+ */
+var typedArrayConstructors = [
+ Float64Array,
+ Float32Array,
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array,
+ Uint8ClampedArray
+];
+
+var floatArrayConstructors = typedArrayConstructors.slice(0, 2);
+var intArrayConstructors = typedArrayConstructors.slice(2, 7);
+
+/**
+ * The %TypedArray% intrinsic constructor function.
+ */
+var TypedArray = Object.getPrototypeOf(Int8Array);
+
+/**
+ * Callback for testing a typed array constructor.
+ *
+ * @callback typedArrayConstructorCallback
+ * @param {Function} Constructor the constructor object to test with.
+ */
+
+/**
+ * Calls the provided function for every typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithTypedArrayConstructors(f, selected) {
+ var constructors = selected || typedArrayConstructors;
+ 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;
+ }
+ }
+}
+
+/**
+ * Calls the provided function for every non-"Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, [
+ Float64Array,
+ Float32Array,
+ Uint8ClampedArray
+ ]);
+}
+
+/**
+ * Calls the provided function for every "Atomics Friendly" typed array constructor.
+ *
+ * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
+ * @param {Array} selected - An optional Array with filtered typed arrays
+ */
+function testWithAtomicsFriendlyTypedArrayConstructors(f) {
+ testWithTypedArrayConstructors(f, [
+ Int32Array,
+ Int16Array,
+ Int8Array,
+ Uint32Array,
+ Uint16Array,
+ Uint8Array,
+ ]);
+}
+
+/**
+ * Helper for conversion operations on TypedArrays, the expected values
+ * properties are indexed in order to match the respective value for each
+ * TypedArray constructor
+ * @param {Function} fn - the function to call for each constructor and value.
+ * will be called with the constructor, value, expected
+ * value, and a initial value that can be used to avoid
+ * a false positive with an equivalent expected value.
+ */
+function testTypedArrayConversions(byteConversionValues, fn) {
+ var values = byteConversionValues.values;
+ var expected = byteConversionValues.expected;
+
+ testWithTypedArrayConstructors(function(TA) {
+ var name = TA.name.slice(0, -5);
+
+ return values.forEach(function(value, index) {
+ var exp = expected[name][index];
+ var initial = 0;
+ if (exp === 0) {
+ initial = 1;
+ }
+ fn(TA, value, exp, initial);
+ });
+ });
+}