From 52f70e2f637731aae92a9c9a2d831310c3ab2e1e Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 2 Mar 2018 15:20:41 -0500 Subject: typed-array: ctor test renames (#1468) --- .../ctors-bigint/object-arg/as-array-returns.js | 26 +++++++ .../object-arg/as-generator-iterable-returns.js | 30 ++++++++ .../object-arg/custom-proto-access-throws.js | 48 ++++++++++++ .../ctors-bigint/object-arg/iterating-throws.js | 31 ++++++++ .../object-arg/iterator-not-callable-throws.js | 39 ++++++++++ .../ctors-bigint/object-arg/iterator-throws.js | 34 +++++++++ .../object-arg/length-excessive-throws.js | 30 ++++++++ .../object-arg/length-is-symbol-throws.js | 30 ++++++++ .../ctors-bigint/object-arg/length-throws.js | 34 +++++++++ .../object-arg/new-instance-extensibility.js | 43 +++++++++++ .../object-arg/object-arg-as-array-returns.js | 26 ------- .../object-arg-as-generator-iterable-returns.js | 30 -------- .../object-arg-custom-proto-access-throws.js | 48 ------------ .../object-arg/object-arg-iterating-throws.js | 31 -------- .../object-arg-iterator-not-callable-throws.js | 39 ---------- .../object-arg/object-arg-iterator-throws.js | 34 --------- .../object-arg-length-excessive-throws.js | 30 -------- .../object-arg-length-is-symbol-throws.js | 30 -------- .../object-arg/object-arg-length-throws.js | 34 --------- .../object-arg-new-instance-extensibility.js | 43 ----------- .../object-arg/object-arg-proto-from-ctor-realm.js | 37 --------- .../object-arg/object-arg-throws-from-property.js | 40 ---------- ...rg-throws-setting-obj-to-primitive-typeerror.js | 77 ------------------- .../object-arg-throws-setting-obj-to-primitive.js | 75 ------------------ .../object-arg-throws-setting-obj-tostring.js | 88 --------------------- ...ect-arg-throws-setting-obj-valueof-typeerror.js | 89 ---------------------- .../object-arg-throws-setting-obj-valueof.js | 82 -------------------- .../object-arg-throws-setting-property.js | 40 ---------- .../object-arg-throws-setting-symbol-property.js | 34 --------- .../object-arg-undefined-newtarget-throws.js | 30 -------- .../object-arg-use-custom-proto-if-object.js | 47 ------------ ...-default-proto-if-custom-proto-is-not-object.js | 47 ------------ .../object-arg/proto-from-ctor-realm.js | 37 +++++++++ .../object-arg/throws-from-property.js | 40 ++++++++++ .../throws-setting-obj-to-primitive-typeerror.js | 77 +++++++++++++++++++ .../object-arg/throws-setting-obj-to-primitive.js | 75 ++++++++++++++++++ .../object-arg/throws-setting-obj-tostring.js | 88 +++++++++++++++++++++ .../throws-setting-obj-valueof-typeerror.js | 89 ++++++++++++++++++++++ .../object-arg/throws-setting-obj-valueof.js | 82 ++++++++++++++++++++ .../object-arg/throws-setting-property.js | 40 ++++++++++ .../object-arg/throws-setting-symbol-property.js | 34 +++++++++ .../object-arg/undefined-newtarget-throws.js | 30 ++++++++ .../object-arg/use-custom-proto-if-object.js | 47 ++++++++++++ ...-default-proto-if-custom-proto-is-not-object.js | 47 ++++++++++++ .../typedarray-arg/custom-proto-access-throws.js | 47 ++++++++++++ ...tached-when-species-retrieved-different-type.js | 61 +++++++++++++++ .../detached-when-species-retrieved-same-type.js | 64 ++++++++++++++++ .../typedarray-arg/new-instance-extensibility.js | 46 +++++++++++ .../other-ctor-buffer-ctor-access-throws.js | 41 ++++++++++ ...er-ctor-custom-species-proto-from-ctor-realm.js | 58 ++++++++++++++ .../other-ctor-buffer-ctor-custom-species.js | 52 +++++++++++++ .../other-ctor-buffer-ctor-not-object-throws.js | 61 +++++++++++++++ ...other-ctor-buffer-ctor-species-access-throws.js | 45 +++++++++++ ...her-ctor-buffer-ctor-species-not-ctor-throws.js | 47 ++++++++++++ .../other-ctor-buffer-ctor-species-null.js | 44 +++++++++++ ...er-ctor-buffer-ctor-species-prototype-throws.js | 59 ++++++++++++++ .../other-ctor-buffer-ctor-species-undefined.js | 43 +++++++++++ .../other-ctor-returns-new-typedarray.js | 28 +++++++ .../typedarray-arg/proto-from-ctor-realm.js | 37 +++++++++ .../same-ctor-buffer-ctor-access-throws.js | 46 +++++++++++ ...er-ctor-species-custom-proto-from-ctor-realm.js | 68 +++++++++++++++++ .../same-ctor-buffer-ctor-species-custom.js | 60 +++++++++++++++ .../same-ctor-buffer-ctor-species-not-ctor.js | 49 ++++++++++++ .../same-ctor-buffer-ctor-species-null.js | 49 ++++++++++++ ...me-ctor-buffer-ctor-species-prototype-throws.js | 62 +++++++++++++++ .../same-ctor-buffer-ctor-species-throws.js | 49 ++++++++++++ .../same-ctor-buffer-ctor-species-undefined.js | 49 ++++++++++++ .../same-ctor-buffer-ctor-value-not-obj-throws.js | 65 ++++++++++++++++ .../same-ctor-returns-new-cloned-typedarray.js | 32 ++++++++ .../typedarray-arg-custom-proto-access-throws.js | 47 ------------ ...tached-when-species-retrieved-different-type.js | 61 --------------- ...rg-detached-when-species-retrieved-same-type.js | 64 ---------------- .../typedarray-arg-new-instance-extensibility.js | 46 ----------- ...ray-arg-other-ctor-buffer-ctor-access-throws.js | 41 ---------- ...er-ctor-custom-species-proto-from-ctor-realm.js | 58 -------------- ...ay-arg-other-ctor-buffer-ctor-custom-species.js | 52 ------------- ...arg-other-ctor-buffer-ctor-not-object-throws.js | 61 --------------- ...other-ctor-buffer-ctor-species-access-throws.js | 45 ----------- ...her-ctor-buffer-ctor-species-not-ctor-throws.js | 47 ------------ ...rray-arg-other-ctor-buffer-ctor-species-null.js | 44 ----------- ...er-ctor-buffer-ctor-species-prototype-throws.js | 59 -------------- ...arg-other-ctor-buffer-ctor-species-undefined.js | 43 ----------- ...darray-arg-other-ctor-returns-new-typedarray.js | 28 ------- .../typedarray-arg-proto-from-ctor-realm.js | 37 --------- ...rray-arg-same-ctor-buffer-ctor-access-throws.js | 46 ----------- ...er-ctor-species-custom-proto-from-ctor-realm.js | 68 ----------------- ...ray-arg-same-ctor-buffer-ctor-species-custom.js | 60 --------------- ...y-arg-same-ctor-buffer-ctor-species-not-ctor.js | 49 ------------ ...array-arg-same-ctor-buffer-ctor-species-null.js | 49 ------------ ...me-ctor-buffer-ctor-species-prototype-throws.js | 62 --------------- ...ray-arg-same-ctor-buffer-ctor-species-throws.js | 49 ------------ ...-arg-same-ctor-buffer-ctor-species-undefined.js | 49 ------------ ...g-same-ctor-buffer-ctor-value-not-obj-throws.js | 65 ---------------- ...-arg-same-ctor-returns-new-cloned-typedarray.js | 32 -------- .../typedarray-arg-undefined-newtarget-throws.js | 27 ------- .../typedarray-arg/undefined-newtarget-throws.js | 27 +++++++ ...teoffset-throws-from-modulo-element-size-sab.js | 38 --------- ...erbyteoffset-throws-from-modulo-element-size.js | 32 -------- ...buffer-arg-byteoffset-is-negative-throws-sab.js | 32 -------- .../buffer-arg-byteoffset-is-negative-throws.js | 31 -------- .../buffer-arg-byteoffset-is-negative-zero-sab.js | 23 ------ .../buffer-arg-byteoffset-is-negative-zero.js | 23 ------ .../buffer-arg-byteoffset-is-symbol-throws-sab.js | 29 ------- .../buffer-arg-byteoffset-is-symbol-throws.js | 28 ------- ...teoffset-throws-from-modulo-element-size-sab.js | 35 --------- ...g-byteoffset-throws-from-modulo-element-size.js | 27 ------- ...buffer-arg-byteoffset-to-number-detachbuffer.js | 21 ----- .../buffer-arg-byteoffset-to-number-throws-sab.js | 33 -------- .../buffer-arg-byteoffset-to-number-throws.js | 32 -------- .../buffer-arg-custom-proto-access-throws-sab.js | 48 ------------ .../buffer-arg-custom-proto-access-throws.js | 47 ------------ .../buffer-arg-defined-length-and-offset-sab.js | 33 -------- .../buffer-arg-defined-length-and-offset.js | 32 -------- .../buffer-arg/buffer-arg-defined-length-sab.js | 35 --------- .../ctors/buffer-arg/buffer-arg-defined-length.js | 34 --------- .../buffer-arg-defined-negative-length-sab.js | 29 ------- .../buffer-arg-defined-negative-length.js | 28 ------- .../buffer-arg/buffer-arg-defined-offset-sab.js | 33 -------- .../ctors/buffer-arg/buffer-arg-defined-offset.js | 32 -------- .../ctors/buffer-arg/buffer-arg-detachedbuffer.js | 21 ----- .../buffer-arg-excessive-length-throws-sab.js | 32 -------- .../buffer-arg-excessive-length-throws.js | 31 -------- .../buffer-arg-excessive-offset-throws-sab.js | 36 --------- .../buffer-arg-excessive-offset-throws.js | 35 --------- ...fer-arg-invoked-with-undefined-newtarget-sab.js | 27 ------- .../buffer-arg-invoked-with-undefined-newtarget.js | 26 ------- .../buffer-arg/buffer-arg-is-referenced-sab.js | 33 -------- .../ctors/buffer-arg/buffer-arg-is-referenced.js | 32 -------- .../buffer-arg-length-access-throws-sab.js | 34 --------- .../buffer-arg/buffer-arg-length-access-throws.js | 33 -------- .../buffer-arg-length-is-symbol-throws-sab.js | 30 -------- .../buffer-arg-length-is-symbol-throws.js | 29 ------- .../buffer-arg-length-to-number-detachbuffer.js | 21 ----- .../buffer-arg-new-instance-extensibility-sab.js | 38 --------- .../buffer-arg-new-instance-extensibility.js | 37 --------- .../buffer-arg-proto-from-ctor-realm-sab.js | 38 --------- .../buffer-arg/buffer-arg-proto-from-ctor-realm.js | 37 --------- .../buffer-arg-returns-new-instance-sab.js | 34 --------- .../buffer-arg/buffer-arg-returns-new-instance.js | 33 -------- .../buffer-arg-toindex-bytelength-sab.js | 73 ------------------ .../buffer-arg/buffer-arg-toindex-bytelength.js | 72 ----------------- .../buffer-arg-toindex-byteoffset-sab.js | 87 --------------------- .../buffer-arg/buffer-arg-toindex-byteoffset.js | 86 --------------------- ...r-arg-typedarray-backed-by-sharedarraybuffer.js | 23 ------ .../buffer-arg-use-custom-proto-if-object-sab.js | 49 ------------ .../buffer-arg-use-custom-proto-if-object.js | 48 ------------ ...ault-proto-if-custom-proto-is-not-object-sab.js | 48 ------------ ...-default-proto-if-custom-proto-is-not-object.js | 47 ------------ ...teoffset-throws-from-modulo-element-size-sab.js | 38 +++++++++ ...erbyteoffset-throws-from-modulo-element-size.js | 32 ++++++++ .../byteoffset-is-negative-throws-sab.js | 32 ++++++++ .../buffer-arg/byteoffset-is-negative-throws.js | 31 ++++++++ .../buffer-arg/byteoffset-is-negative-zero-sab.js | 23 ++++++ .../buffer-arg/byteoffset-is-negative-zero.js | 23 ++++++ .../buffer-arg/byteoffset-is-symbol-throws-sab.js | 29 +++++++ .../buffer-arg/byteoffset-is-symbol-throws.js | 28 +++++++ ...teoffset-throws-from-modulo-element-size-sab.js | 35 +++++++++ .../byteoffset-throws-from-modulo-element-size.js | 27 +++++++ .../byteoffset-to-number-detachbuffer.js | 21 +++++ .../buffer-arg/byteoffset-to-number-throws-sab.js | 33 ++++++++ .../buffer-arg/byteoffset-to-number-throws.js | 32 ++++++++ .../buffer-arg/custom-proto-access-throws-sab.js | 48 ++++++++++++ .../ctors/buffer-arg/custom-proto-access-throws.js | 47 ++++++++++++ .../buffer-arg/defined-length-and-offset-sab.js | 33 ++++++++ .../ctors/buffer-arg/defined-length-and-offset.js | 32 ++++++++ .../ctors/buffer-arg/defined-length-sab.js | 35 +++++++++ .../TypedArrays/ctors/buffer-arg/defined-length.js | 34 +++++++++ .../buffer-arg/defined-negative-length-sab.js | 29 +++++++ .../ctors/buffer-arg/defined-negative-length.js | 28 +++++++ .../ctors/buffer-arg/defined-offset-sab.js | 33 ++++++++ .../TypedArrays/ctors/buffer-arg/defined-offset.js | 32 ++++++++ .../TypedArrays/ctors/buffer-arg/detachedbuffer.js | 21 +++++ .../buffer-arg/excessive-length-throws-sab.js | 32 ++++++++ .../ctors/buffer-arg/excessive-length-throws.js | 31 ++++++++ .../buffer-arg/excessive-offset-throws-sab.js | 36 +++++++++ .../ctors/buffer-arg/excessive-offset-throws.js | 35 +++++++++ .../invoked-with-undefined-newtarget-sab.js | 27 +++++++ .../buffer-arg/invoked-with-undefined-newtarget.js | 26 +++++++ .../ctors/buffer-arg/is-referenced-sab.js | 33 ++++++++ .../TypedArrays/ctors/buffer-arg/is-referenced.js | 32 ++++++++ .../ctors/buffer-arg/length-access-throws-sab.js | 34 +++++++++ .../ctors/buffer-arg/length-access-throws.js | 33 ++++++++ .../buffer-arg/length-is-symbol-throws-sab.js | 30 ++++++++ .../ctors/buffer-arg/length-is-symbol-throws.js | 29 +++++++ .../buffer-arg/length-to-number-detachbuffer.js | 21 +++++ .../buffer-arg/new-instance-extensibility-sab.js | 38 +++++++++ .../ctors/buffer-arg/new-instance-extensibility.js | 37 +++++++++ .../ctors/buffer-arg/proto-from-ctor-realm-sab.js | 38 +++++++++ .../ctors/buffer-arg/proto-from-ctor-realm.js | 37 +++++++++ .../ctors/buffer-arg/returns-new-instance-sab.js | 34 +++++++++ .../ctors/buffer-arg/returns-new-instance.js | 33 ++++++++ .../ctors/buffer-arg/toindex-bytelength-sab.js | 73 ++++++++++++++++++ .../ctors/buffer-arg/toindex-bytelength.js | 72 +++++++++++++++++ .../ctors/buffer-arg/toindex-byteoffset-sab.js | 87 +++++++++++++++++++++ .../ctors/buffer-arg/toindex-byteoffset.js | 86 +++++++++++++++++++++ .../typedarray-backed-by-sharedarraybuffer.js | 23 ++++++ .../buffer-arg/use-custom-proto-if-object-sab.js | 49 ++++++++++++ .../ctors/buffer-arg/use-custom-proto-if-object.js | 48 ++++++++++++ ...ault-proto-if-custom-proto-is-not-object-sab.js | 48 ++++++++++++ ...-default-proto-if-custom-proto-is-not-object.js | 47 ++++++++++++ .../ctors/length-arg/custom-proto-access-throws.js | 43 +++++++++++ .../TypedArrays/ctors/length-arg/init-zeros.js | 55 +++++++++++++ .../length-arg/is-infinity-throws-rangeerror.js | 27 +++++++ .../is-negative-integer-throws-rangeerror.js | 37 +++++++++ .../ctors/length-arg/is-symbol-throws.js | 26 +++++++ .../length-arg-custom-proto-access-throws.js | 43 ----------- .../ctors/length-arg/length-arg-init-zeros.js | 55 ------------- .../length-arg-is-infinity-throws-rangeerror.js | 27 ------- ...th-arg-is-negative-integer-throws-rangeerror.js | 37 --------- .../length-arg/length-arg-is-symbol-throws.js | 26 ------- .../length-arg-new-instance-extensibility.js | 38 --------- .../length-arg/length-arg-proto-from-ctor-realm.js | 36 --------- .../ctors/length-arg/length-arg-returns-object.js | 33 -------- .../ctors/length-arg/length-arg-toindex-length.js | 53 ------------- .../length-arg-undefined-newtarget-throws.js | 28 ------- .../length-arg-use-custom-proto-if-object.js | 44 ----------- ...-default-proto-if-custom-proto-is-not-object.js | 43 ----------- .../ctors/length-arg/new-instance-extensibility.js | 38 +++++++++ .../ctors/length-arg/proto-from-ctor-realm.js | 36 +++++++++ .../TypedArrays/ctors/length-arg/returns-object.js | 33 ++++++++ .../TypedArrays/ctors/length-arg/toindex-length.js | 53 +++++++++++++ .../ctors/length-arg/undefined-newtarget-throws.js | 28 +++++++ .../ctors/length-arg/use-custom-proto-if-object.js | 44 +++++++++++ ...-default-proto-if-custom-proto-is-not-object.js | 43 +++++++++++ .../ctors/no-args/custom-proto-access-throws.js | 43 +++++++++++ .../ctors/no-args/new-instance-extensibility.js | 38 +++++++++ .../no-args/no-args-custom-proto-access-throws.js | 43 ----------- .../no-args/no-args-new-instance-extensibility.js | 38 --------- .../ctors/no-args/no-args-proto-from-ctor-realm.js | 36 --------- .../ctors/no-args/no-args-returns-object.js | 32 -------- .../no-args/no-args-undefined-newtarget-throws.js | 23 ------ .../no-args/no-args-use-custom-proto-if-object.js | 44 ----------- ...-default-proto-if-custom-proto-is-not-object.js | 43 ----------- .../ctors/no-args/proto-from-ctor-realm.js | 36 +++++++++ .../TypedArrays/ctors/no-args/returns-object.js | 32 ++++++++ .../ctors/no-args/undefined-newtarget-throws.js | 23 ++++++ .../ctors/no-args/use-custom-proto-if-object.js | 44 +++++++++++ ...-default-proto-if-custom-proto-is-not-object.js | 43 +++++++++++ .../ctors/object-arg/as-array-returns.js | 28 +++++++ .../object-arg/as-generator-iterable-returns.js | 30 ++++++++ .../conversion-operation-consistent-nan.js | 61 +++++++++++++++ .../ctors/object-arg/conversion-operation.js | 53 +++++++++++++ .../ctors/object-arg/custom-proto-access-throws.js | 48 ++++++++++++ .../ctors/object-arg/iterating-throws.js | 31 ++++++++ .../object-arg/iterator-not-callable-throws.js | 39 ++++++++++ .../ctors/object-arg/iterator-throws.js | 34 +++++++++ .../ctors/object-arg/length-excessive-throws.js | 30 ++++++++ .../ctors/object-arg/length-is-symbol-throws.js | 30 ++++++++ .../TypedArrays/ctors/object-arg/length-throws.js | 34 +++++++++ .../ctors/object-arg/new-instance-extensibility.js | 43 +++++++++++ .../object-arg/object-arg-as-array-returns.js | 28 ------- .../object-arg-as-generator-iterable-returns.js | 30 -------- ...ject-arg-conversion-operation-consistent-nan.js | 61 --------------- .../object-arg/object-arg-conversion-operation.js | 53 ------------- .../object-arg-custom-proto-access-throws.js | 48 ------------ .../object-arg/object-arg-iterating-throws.js | 31 -------- .../object-arg-iterator-not-callable-throws.js | 39 ---------- .../ctors/object-arg/object-arg-iterator-throws.js | 34 --------- .../object-arg-length-excessive-throws.js | 30 -------- .../object-arg-length-is-symbol-throws.js | 30 -------- .../ctors/object-arg/object-arg-length-throws.js | 34 --------- .../object-arg-new-instance-extensibility.js | 43 ----------- .../object-arg/object-arg-proto-from-ctor-realm.js | 37 --------- .../ctors/object-arg/object-arg-returns.js | 45 ----------- .../object-arg/object-arg-throws-from-property.js | 38 --------- ...rg-throws-setting-obj-to-primitive-typeerror.js | 77 ------------------- .../object-arg-throws-setting-obj-to-primitive.js | 75 ------------------ .../object-arg-throws-setting-obj-tostring.js | 88 --------------------- ...ect-arg-throws-setting-obj-valueof-typeerror.js | 89 ---------------------- .../object-arg-throws-setting-obj-valueof.js | 82 -------------------- .../object-arg-throws-setting-property.js | 38 --------- .../object-arg-throws-setting-symbol-property.js | 34 --------- .../object-arg-undefined-newtarget-throws.js | 30 -------- .../object-arg-use-custom-proto-if-object.js | 47 ------------ ...-default-proto-if-custom-proto-is-not-object.js | 47 ------------ .../ctors/object-arg/proto-from-ctor-realm.js | 37 +++++++++ .../TypedArrays/ctors/object-arg/returns.js | 45 +++++++++++ .../ctors/object-arg/throws-from-property.js | 38 +++++++++ .../throws-setting-obj-to-primitive-typeerror.js | 77 +++++++++++++++++++ .../object-arg/throws-setting-obj-to-primitive.js | 75 ++++++++++++++++++ .../object-arg/throws-setting-obj-tostring.js | 88 +++++++++++++++++++++ .../throws-setting-obj-valueof-typeerror.js | 89 ++++++++++++++++++++++ .../ctors/object-arg/throws-setting-obj-valueof.js | 82 ++++++++++++++++++++ .../ctors/object-arg/throws-setting-property.js | 38 +++++++++ .../object-arg/throws-setting-symbol-property.js | 34 +++++++++ .../ctors/object-arg/undefined-newtarget-throws.js | 30 ++++++++ .../ctors/object-arg/use-custom-proto-if-object.js | 47 ++++++++++++ ...-default-proto-if-custom-proto-is-not-object.js | 47 ++++++++++++ .../typedarray-arg/custom-proto-access-throws.js | 47 ++++++++++++ ...tached-when-species-retrieved-different-type.js | 61 +++++++++++++++ .../detached-when-species-retrieved-same-type.js | 64 ++++++++++++++++ .../typedarray-arg/new-instance-extensibility.js | 46 +++++++++++ .../other-ctor-buffer-ctor-access-throws.js | 41 ++++++++++ ...er-ctor-custom-species-proto-from-ctor-realm.js | 59 ++++++++++++++ .../other-ctor-buffer-ctor-custom-species.js | 52 +++++++++++++ .../other-ctor-buffer-ctor-not-object-throws.js | 61 +++++++++++++++ ...other-ctor-buffer-ctor-species-access-throws.js | 45 +++++++++++ ...her-ctor-buffer-ctor-species-not-ctor-throws.js | 47 ++++++++++++ .../other-ctor-buffer-ctor-species-null.js | 44 +++++++++++ ...er-ctor-buffer-ctor-species-prototype-throws.js | 59 ++++++++++++++ .../other-ctor-buffer-ctor-species-undefined.js | 43 +++++++++++ .../other-ctor-returns-new-typedarray.js | 28 +++++++ .../ctors/typedarray-arg/proto-from-ctor-realm.js | 37 +++++++++ .../ctors/typedarray-arg/returns-new-instance.js | 31 ++++++++ .../same-ctor-buffer-ctor-access-throws.js | 46 +++++++++++ ...er-ctor-species-custom-proto-from-ctor-realm.js | 68 +++++++++++++++++ .../same-ctor-buffer-ctor-species-custom.js | 60 +++++++++++++++ .../same-ctor-buffer-ctor-species-not-ctor.js | 49 ++++++++++++ .../same-ctor-buffer-ctor-species-null.js | 49 ++++++++++++ ...me-ctor-buffer-ctor-species-prototype-throws.js | 62 +++++++++++++++ .../same-ctor-buffer-ctor-species-throws.js | 49 ++++++++++++ .../same-ctor-buffer-ctor-species-undefined.js | 49 ++++++++++++ .../same-ctor-buffer-ctor-value-not-obj-throws.js | 65 ++++++++++++++++ .../same-ctor-returns-new-cloned-typedarray.js | 32 ++++++++ .../typedarray-arg-custom-proto-access-throws.js | 47 ------------ ...tached-when-species-retrieved-different-type.js | 61 --------------- ...rg-detached-when-species-retrieved-same-type.js | 64 ---------------- .../typedarray-arg-new-instance-extensibility.js | 46 ----------- ...ray-arg-other-ctor-buffer-ctor-access-throws.js | 41 ---------- ...er-ctor-custom-species-proto-from-ctor-realm.js | 59 -------------- ...ay-arg-other-ctor-buffer-ctor-custom-species.js | 52 ------------- ...arg-other-ctor-buffer-ctor-not-object-throws.js | 61 --------------- ...other-ctor-buffer-ctor-species-access-throws.js | 45 ----------- ...her-ctor-buffer-ctor-species-not-ctor-throws.js | 47 ------------ ...rray-arg-other-ctor-buffer-ctor-species-null.js | 44 ----------- ...er-ctor-buffer-ctor-species-prototype-throws.js | 59 -------------- ...arg-other-ctor-buffer-ctor-species-undefined.js | 43 ----------- ...darray-arg-other-ctor-returns-new-typedarray.js | 28 ------- .../typedarray-arg-proto-from-ctor-realm.js | 37 --------- .../typedarray-arg-returns-new-instance.js | 31 -------- ...rray-arg-same-ctor-buffer-ctor-access-throws.js | 46 ----------- ...er-ctor-species-custom-proto-from-ctor-realm.js | 68 ----------------- ...ray-arg-same-ctor-buffer-ctor-species-custom.js | 60 --------------- ...y-arg-same-ctor-buffer-ctor-species-not-ctor.js | 49 ------------ ...array-arg-same-ctor-buffer-ctor-species-null.js | 49 ------------ ...me-ctor-buffer-ctor-species-prototype-throws.js | 62 --------------- ...ray-arg-same-ctor-buffer-ctor-species-throws.js | 49 ------------ ...-arg-same-ctor-buffer-ctor-species-undefined.js | 49 ------------ ...g-same-ctor-buffer-ctor-value-not-obj-throws.js | 65 ---------------- ...-arg-same-ctor-returns-new-cloned-typedarray.js | 32 -------- .../typedarray-arg-undefined-newtarget-throws.js | 27 ------- .../typedarray-arg-use-custom-proto-if-object.js | 48 ------------ ...-default-proto-if-custom-proto-is-not-object.js | 47 ------------ .../typedarray-arg/undefined-newtarget-throws.js | 27 +++++++ .../typedarray-arg/use-custom-proto-if-object.js | 48 ++++++++++++ ...-default-proto-if-custom-proto-is-not-object.js | 47 ++++++++++++ 346 files changed, 7551 insertions(+), 7551 deletions(-) create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/as-array-returns.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/as-generator-iterable-returns.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/custom-proto-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/iterating-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-not-callable-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/length-excessive-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/length-is-symbol-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/length-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-object.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-from-property.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-tostring.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-property.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-symbol-property.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/undefined-newtarget-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/use-custom-proto-if-object.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/custom-proto-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-different-type.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-same-type.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/new-instance-extensibility.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-null.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-returns-new-typedarray.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-null.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-custom-proto-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js delete mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js create mode 100644 test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/undefined-newtarget-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-detachbuffer.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-detachedbuffer.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-to-number-detachbuffer.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-typedarray-backed-by-sharedarraybuffer.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js delete mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-offset-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-offset.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-length.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-offset-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/defined-offset.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/detachedbuffer.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/excessive-offset-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/excessive-offset-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/length-to-number-detachbuffer.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js create mode 100644 test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/custom-proto-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/init-zeros.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/is-infinity-throws-rangeerror.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/is-negative-integer-throws-rangeerror.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/is-symbol-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-custom-proto-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-init-zeros.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-infinity-throws-rangeerror.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-negative-integer-throws-rangeerror.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-symbol-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-returns-object.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-toindex-length.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-undefined-newtarget-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-custom-proto-if-object.js delete mode 100644 test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/new-instance-extensibility.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/returns-object.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/toindex-length.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/undefined-newtarget-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/use-custom-proto-if-object.js create mode 100644 test/built-ins/TypedArrays/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/no-args/custom-proto-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/no-args/new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors/no-args/no-args-custom-proto-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/no-args/no-args-new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors/no-args/no-args-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors/no-args/no-args-returns-object.js delete mode 100644 test/built-ins/TypedArrays/ctors/no-args/no-args-undefined-newtarget-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/no-args/no-args-use-custom-proto-if-object.js delete mode 100644 test/built-ins/TypedArrays/ctors/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/no-args/proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors/no-args/returns-object.js create mode 100644 test/built-ins/TypedArrays/ctors/no-args/undefined-newtarget-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/no-args/use-custom-proto-if-object.js create mode 100644 test/built-ins/TypedArrays/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/as-array-returns.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/as-generator-iterable-returns.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/conversion-operation-consistent-nan.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/conversion-operation.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/custom-proto-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/iterating-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/iterator-not-callable-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/iterator-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/length-excessive-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/length-is-symbol-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/length-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js delete mode 100644 test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/returns.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-from-property.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-tostring.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof-typeerror.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-setting-property.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/throws-setting-symbol-property.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/undefined-newtarget-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/use-custom-proto-if-object.js create mode 100644 test/built-ins/TypedArrays/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/custom-proto-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/new-instance-extensibility.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-null.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-returns-new-typedarray.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/returns-new-instance.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-access-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-custom-proto-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-new-instance-extensibility.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-returns-new-instance.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-custom-proto-if-object.js delete mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/undefined-newtarget-throws.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/use-custom-proto-if-object.js create mode 100644 test/built-ins/TypedArrays/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.js (limited to 'test') diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/as-array-returns.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/as-array-returns.js new file mode 100644 index 000000000..48cfaf7f2 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/as-array-returns.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-object +description: > + Return typedArray from array argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var typedArray = new TA([7n, 42n]); + assert.sameValue(typedArray.length, 2); + assert.sameValue(typedArray[0], 7n); + assert.sameValue(typedArray[1], 42n); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/as-generator-iterable-returns.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/as-generator-iterable-returns.js new file mode 100644 index 000000000..b5df7bc98 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/as-generator-iterable-returns.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-object +description: > + Return typedArray from iterable argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var obj = (function *() { + yield 7n; yield 42n; + })(); + + var typedArray = new TA(obj); + assert.sameValue(typedArray.length, 2); + assert.sameValue(typedArray[0], 7n); + assert.sameValue(typedArray[1], 42n); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/custom-proto-access-throws.js new file mode 100644 index 000000000..ef668514d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/custom-proto-access-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-object +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Reflect, TypedArray] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +var o = {}; + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [o], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterating-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterating-throws.js new file mode 100644 index 000000000..bf3e5e369 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterating-throws.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-object +description: > + Return abrupt from iterating object argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var obj = (function *() { + yield 0; + throw new Test262Error(); + })(); + + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-not-callable-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-not-callable-throws.js new file mode 100644 index 000000000..18d988ef1 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-not-callable-throws.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-object +description: > + Return abrupt when object @@iterator is not callable +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.iterator, TypedArray] +---*/ + +var obj = function () {}; + +testWithBigIntTypedArrayConstructors(function(TA) { + obj[Symbol.iterator] = {}; + assert.throws(TypeError, function() { + new TA(obj); + }); + + obj[Symbol.iterator] = true; + assert.throws(TypeError, function() { + new TA(obj); + }); + + obj[Symbol.iterator] = 42; + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-throws.js new file mode 100644 index 000000000..7db332def --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/iterator-throws.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-object +description: > + Return abrupt from getting object @@iterator +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.iterator, TypedArray] +---*/ + +var obj = function () {}; + +Object.defineProperty(obj, Symbol.iterator, { + get() { + throw new Test262Error(); + } +}); + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-excessive-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-excessive-throws.js new file mode 100644 index 000000000..d7fb7216e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-excessive-throws.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-object +description: > + Return abrupt from allocating array buffer with excessive length +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 6. Perform ? AllocateTypedArrayBuffer(O, len). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + length: Math.pow(2, 53) +}; + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-is-symbol-throws.js new file mode 100644 index 000000000..a41f8a01b --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-is-symbol-throws.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-object +description: > + Return abrupt from length property as a Symbol on the object argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 5. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var obj = { + length: Symbol("1") +}; + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-throws.js new file mode 100644 index 000000000..6272147d4 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/length-throws.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-object +description: > + Return abrupt from getting length property on the object argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 5. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get() { + throw new Test262Error(); + } +}); + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/new-instance-extensibility.js new file mode 100644 index 000000000..7332f854d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/new-instance-extensibility.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-object +description: > + The new typedArray instance from an object argument is extensible +info: | + 22.2.4.4 TypedArray ( object ) + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var obj = { + "0": 0n, + "1": 1n, + "2": 2n, + length: 3 + }; + + var sample = new TA(obj); + + assert(Object.isExtensible(sample)); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js deleted file mode 100644 index 48cfaf7f2..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-array-returns.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return typedArray from array argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var typedArray = new TA([7n, 42n]); - assert.sameValue(typedArray.length, 2); - assert.sameValue(typedArray[0], 7n); - assert.sameValue(typedArray[1], 42n); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js deleted file mode 100644 index b5df7bc98..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-as-generator-iterable-returns.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return typedArray from iterable argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var obj = (function *() { - yield 7n; yield 42n; - })(); - - var typedArray = new TA(obj); - assert.sameValue(typedArray.length, 2); - assert.sameValue(typedArray[0], 7n); - assert.sameValue(typedArray[1], 42n); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.js deleted file mode 100644 index ef668514d..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-custom-proto-access-throws.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], - NewTarget, "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Reflect, TypedArray] ----*/ - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -var o = {}; - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [o], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-throws.js deleted file mode 100644 index bf3e5e369..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterating-throws.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from iterating object argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 4. Let arrayLike be ? IterableToArrayLike(object). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var obj = (function *() { - yield 0; - throw new Test262Error(); - })(); - - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js deleted file mode 100644 index 18d988ef1..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-not-callable-throws.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt when object @@iterator is not callable -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 4. Let arrayLike be ? IterableToArrayLike(object). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.iterator, TypedArray] ----*/ - -var obj = function () {}; - -testWithBigIntTypedArrayConstructors(function(TA) { - obj[Symbol.iterator] = {}; - assert.throws(TypeError, function() { - new TA(obj); - }); - - obj[Symbol.iterator] = true; - assert.throws(TypeError, function() { - new TA(obj); - }); - - obj[Symbol.iterator] = 42; - assert.throws(TypeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.js deleted file mode 100644 index 7db332def..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-iterator-throws.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from getting object @@iterator -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 4. Let arrayLike be ? IterableToArrayLike(object). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.iterator, TypedArray] ----*/ - -var obj = function () {}; - -Object.defineProperty(obj, Symbol.iterator, { - get() { - throw new Test262Error(); - } -}); - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js deleted file mode 100644 index d7fb7216e..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-excessive-throws.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from allocating array buffer with excessive length -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 6. Perform ? AllocateTypedArrayBuffer(O, len). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -var obj = { - length: Math.pow(2, 53) -}; - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js deleted file mode 100644 index a41f8a01b..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-is-symbol-throws.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from length property as a Symbol on the object argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 5. Let len be ? ToLength(? Get(arrayLike, "length")). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol, TypedArray] ----*/ - -var obj = { - length: Symbol("1") -}; - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.js deleted file mode 100644 index 6272147d4..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-length-throws.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from getting length property on the object argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 5. Let len be ? ToLength(? Get(arrayLike, "length")). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -var obj = {}; - -Object.defineProperty(obj, "length", { - get() { - throw new Test262Error(); - } -}); - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js deleted file mode 100644 index 7332f854d..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-new-instance-extensibility.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - The new typedArray instance from an object argument is extensible -info: | - 22.2.4.4 TypedArray ( object ) - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var obj = { - "0": 0n, - "1": 1n, - "2": 2n, - length: 3 - }; - - var sample = new TA(obj); - - assert(Object.isExtensible(sample)); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-proto-from-ctor-realm.js deleted file mode 100644 index 19315f593..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-proto-from-ctor-realm.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - [...] - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testBigIntTypedArray.js] -features: [BigInt, cross-realm, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithBigIntTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [{}], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js deleted file mode 100644 index 758bf286d..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-from-property.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from getting object property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -var obj = { - length: 4 -}; - -Object.defineProperty(obj, "2", { - get() { - throw new Test262Error(); - } -}); - -testWithBigIntTypedArrayConstructors(function(TA) { - obj[0] = 0n; - obj[1] = 0n; - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js deleted file mode 100644 index 027ad4ba6..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Throw TypeError from @@toPrimitive returning an Object when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.toPrimitive, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var toPrimitive = 0; - var valueOf = 0; - - sample[Symbol.toPrimitive] = function() { - toPrimitive++; - return {}; - }; - - sample.valueOf = function() { - valueOf++; - }; - - assert.throws(TypeError, function() { - new TA([8n, sample]); - }, "abrupt completion from sample @@toPrimitive"); - - assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); - assert.sameValue(valueOf, 0, "sample.valueOf is not called"); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js deleted file mode 100644 index 9d84bee67..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-to-primitive.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from @@toPrimitive when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.toPrimitive, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var toPrimitive = 0; - var valueOf = 0; - - sample[Symbol.toPrimitive] = function() { - toPrimitive++; - throw new Test262Error(); - }; - - sample.valueOf = function() { - valueOf++; - }; - - assert.throws(Test262Error, function() { - new TA([8n, sample]); - }, "abrupt completion from sample @@toPrimitive"); - - assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); - assert.sameValue(valueOf, 0, "it does not call sample.valueOf"); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js deleted file mode 100644 index 58801c0b0..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-tostring.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from toString() when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... - 7. Return ? OrdinaryToPrimitive(input, hint). - - OrdinaryToPrimitive - - ... - 5. For each name in methodNames in List order, do - a. Let method be ? Get(O, name). - b. If IsCallable(method) is true, then - i. Let result be ? Call(method, O). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var valueOf = 0; - var toString = 0; - - sample.valueOf = function() { - valueOf++; - return {}; - }; - - sample.toString = function() { - toString++; - throw new Test262Error(); - }; - - assert.throws(Test262Error, function() { - new TA([8n, sample]); - }, "abrupt completion from ToNumber(sample)"); - - assert.sameValue(valueOf, 1, "valueOf called once"); - assert.sameValue(toString, 1, "toString called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js deleted file mode 100644 index 90a587af7..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Throw TypeError from OrdinaryToPrimitive when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... - 7. Return ? OrdinaryToPrimitive(input, hint). - - OrdinaryToPrimitive - - ... - 5. For each name in methodNames in List order, do - a. Let method be ? Get(O, name). - b. If IsCallable(method) is true, then - i. Let result be ? Call(method, O). - ii. If Type(result) is not Object, return result. - 6. Throw a TypeError exception. -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var valueOf = 0; - var toString = 0; - - sample.valueOf = function() { - valueOf++; - return {}; - }; - - sample.toString = function() { - toString++; - return {}; - }; - - assert.throws(TypeError, function() { - new TA([8n, sample]); - }, "abrupt completion from ToNumber(sample)"); - - assert.sameValue(valueOf, 1, "valueOf called once"); - assert.sameValue(toString, 1, "toString called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js deleted file mode 100644 index d5138d56e..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-obj-valueof.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from valueOf() when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... - 7. Return ? OrdinaryToPrimitive(input, hint). - - OrdinaryToPrimitive - - ... - 5. For each name in methodNames in List order, do - a. Let method be ? Get(O, name). - b. If IsCallable(method) is true, then - i. Let result be ? Call(method, O). - ii. If Type(result) is not Object, return result. - 6. Throw a TypeError exception. -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var valueOf = 0; - - sample.valueOf = function() { - valueOf++; - throw new Test262Error(); - }; - - assert.throws(Test262Error, function() { - new TA([8n, sample]); - }, "abrupt completion from ToNumber(sample)"); - - assert.sameValue(valueOf, 1, "valueOf called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js deleted file mode 100644 index 626472c90..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-property.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from setting property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -var obj = { - "2": { - valueOf() { - throw new Test262Error(); - } - }, - length: 4 -}; - -testWithBigIntTypedArrayConstructors(function(TA) { - obj[0] = 0n; - obj[1] = 0n; - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.js deleted file mode 100644 index 0ca0cd655..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-throws-setting-symbol-property.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from setting property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol, TypedArray] ----*/ - -var obj = { - "2": Symbol("1"), - length: 4 -}; - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js deleted file mode 100644 index 7892e3b86..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-undefined-newtarget-throws.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 2. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - TA({}); - }); - - assert.throws(TypeError, function() { - TA([]); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-object.js deleted file mode 100644 index 1a2ae7ccb..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-custom-proto-if-object.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Use prototype from new target if it's an Object -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], - NewTarget, "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testBigIntTypedArray.js] -features: [BigInt, Reflect, TypedArray] ----*/ - -function newTarget() {} -var proto = {}; -newTarget.prototype = proto; - -testWithBigIntTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [], newTarget); - - assert.sameValue(ta.constructor, Object); - assert.sameValue(Object.getPrototypeOf(ta), proto); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js deleted file mode 100644 index a6f3a362e..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Use prototype from %TypedArray% if newTarget's prototype is not an Object -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], - NewTarget, "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -function newTarget() {} -newTarget.prototype = null; -var o = []; - -testWithBigIntTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [o], newTarget); - - assert.sameValue(ta.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/proto-from-ctor-realm.js new file mode 100644 index 000000000..19315f593 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/proto-from-ctor-realm.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-object +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + [...] + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testBigIntTypedArray.js] +features: [BigInt, cross-realm, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithBigIntTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [{}], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-from-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-from-property.js new file mode 100644 index 000000000..758bf286d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-from-property.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-object +description: > + Return abrupt from getting object property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + length: 4 +}; + +Object.defineProperty(obj, "2", { + get() { + throw new Test262Error(); + } +}); + +testWithBigIntTypedArrayConstructors(function(TA) { + obj[0] = 0n; + obj[1] = 0n; + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.js new file mode 100644 index 000000000..027ad4ba6 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive-typeerror.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-object +description: > + Throw TypeError from @@toPrimitive returning an Object when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.toPrimitive, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var toPrimitive = 0; + var valueOf = 0; + + sample[Symbol.toPrimitive] = function() { + toPrimitive++; + return {}; + }; + + sample.valueOf = function() { + valueOf++; + }; + + assert.throws(TypeError, function() { + new TA([8n, sample]); + }, "abrupt completion from sample @@toPrimitive"); + + assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); + assert.sameValue(valueOf, 0, "sample.valueOf is not called"); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive.js new file mode 100644 index 000000000..9d84bee67 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-to-primitive.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-object +description: > + Return abrupt from @@toPrimitive when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.toPrimitive, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var toPrimitive = 0; + var valueOf = 0; + + sample[Symbol.toPrimitive] = function() { + toPrimitive++; + throw new Test262Error(); + }; + + sample.valueOf = function() { + valueOf++; + }; + + assert.throws(Test262Error, function() { + new TA([8n, sample]); + }, "abrupt completion from sample @@toPrimitive"); + + assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); + assert.sameValue(valueOf, 0, "it does not call sample.valueOf"); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-tostring.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-tostring.js new file mode 100644 index 000000000..58801c0b0 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-tostring.js @@ -0,0 +1,88 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-typedarray-object +description: > + Return abrupt from toString() when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... + 7. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive + + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var valueOf = 0; + var toString = 0; + + sample.valueOf = function() { + valueOf++; + return {}; + }; + + sample.toString = function() { + toString++; + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + new TA([8n, sample]); + }, "abrupt completion from ToNumber(sample)"); + + assert.sameValue(valueOf, 1, "valueOf called once"); + assert.sameValue(toString, 1, "toString called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.js new file mode 100644 index 000000000..90a587af7 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof-typeerror.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-object +description: > + Throw TypeError from OrdinaryToPrimitive when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... + 7. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive + + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var valueOf = 0; + var toString = 0; + + sample.valueOf = function() { + valueOf++; + return {}; + }; + + sample.toString = function() { + toString++; + return {}; + }; + + assert.throws(TypeError, function() { + new TA([8n, sample]); + }, "abrupt completion from ToNumber(sample)"); + + assert.sameValue(valueOf, 1, "valueOf called once"); + assert.sameValue(toString, 1, "toString called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof.js new file mode 100644 index 000000000..d5138d56e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-obj-valueof.js @@ -0,0 +1,82 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-typedarray-object +description: > + Return abrupt from valueOf() when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... + 7. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive + + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var valueOf = 0; + + sample.valueOf = function() { + valueOf++; + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + new TA([8n, sample]); + }, "abrupt completion from ToNumber(sample)"); + + assert.sameValue(valueOf, 1, "valueOf called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-property.js new file mode 100644 index 000000000..626472c90 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-property.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-object +description: > + Return abrupt from setting property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + "2": { + valueOf() { + throw new Test262Error(); + } + }, + length: 4 +}; + +testWithBigIntTypedArrayConstructors(function(TA) { + obj[0] = 0n; + obj[1] = 0n; + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-symbol-property.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-symbol-property.js new file mode 100644 index 000000000..0ca0cd655 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/throws-setting-symbol-property.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-object +description: > + Return abrupt from setting property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var obj = { + "2": Symbol("1"), + length: 4 +}; + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/undefined-newtarget-throws.js new file mode 100644 index 000000000..7892e3b86 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/undefined-newtarget-throws.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-object +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA({}); + }); + + assert.throws(TypeError, function() { + TA([]); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/use-custom-proto-if-object.js new file mode 100644 index 000000000..1a2ae7ccb --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/use-custom-proto-if-object.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-object +description: > + Use prototype from new target if it's an Object +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testBigIntTypedArray.js] +features: [BigInt, Reflect, TypedArray] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithBigIntTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], newTarget); + + assert.sameValue(ta.constructor, Object); + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.js new file mode 100644 index 000000000..a6f3a362e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/object-arg/use-default-proto-if-custom-proto-is-not-object.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-object +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +function newTarget() {} +newTarget.prototype = null; +var o = []; + +testWithBigIntTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [o], newTarget); + + assert.sameValue(ta.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/custom-proto-access-throws.js new file mode 100644 index 000000000..ab89da072 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/custom-proto-access-throws.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-typedarray +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Reflect, TypedArray] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +var sample = new Int8Array(); + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [sample], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-different-type.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-different-type.js new file mode 100644 index 000000000..c5de19602 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-different-type.js @@ -0,0 +1,61 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray-typedarray +description: > + When a TypedArray is created from another TypedArray with a different element-type + and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still + executed. +info: | + 22.2.4.3 TypedArray ( typedArray ) + + ... + 16. If IsSharedArrayBuffer(srcData) is false, then + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + 18. If SameValue(elementType, srcType) is true, then + ... + 19. Else, + a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", + « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). + ... +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray, Symbol.species] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var speciesCallCount = 0; + var bufferConstructor = Object.defineProperty({}, Symbol.species, { + get: function() { + speciesCallCount += 1; + $DETACHBUFFER(ta.buffer); + return speciesConstructor; + } + }); + + var prototypeCallCount = 0; + var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { + get: function() { + prototypeCallCount += 1; + return null; + } + }); + + var ta = new TA(0); + ta.buffer.constructor = bufferConstructor; + + assert.throws(TypeError, function() { + var targetType = TA !== Int32Array ? Int32Array : Uint32Array; + new targetType(ta); + }, "TypeError thrown for detached source buffer"); + + assert.sameValue(speciesCallCount, 1, "@@species getter called once"); + assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-same-type.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-same-type.js new file mode 100644 index 000000000..c4f45c49c --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/detached-when-species-retrieved-same-type.js @@ -0,0 +1,64 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray-typedarray +description: > + When a TypedArray is created from another TypedArray with the same element-type + and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still + executed. +info: | + 22.2.4.3 TypedArray ( typedArray ) + + ... + 16. If IsSharedArrayBuffer(srcData) is false, then + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + 18. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, byteLength, bufferConstructor). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength, cloneConstructor ) + + ... + 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). + 4. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", + « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). + ... +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray, Symbol.species] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var speciesCallCount = 0; + var bufferConstructor = Object.defineProperty({}, Symbol.species, { + get: function() { + speciesCallCount += 1; + $DETACHBUFFER(ta.buffer); + return speciesConstructor; + } + }); + + var prototypeCallCount = 0; + var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { + get: function() { + prototypeCallCount += 1; + return null; + } + }); + + var ta = new TA(0); + ta.buffer.constructor = bufferConstructor; + + assert.throws(TypeError, function() { + new TA(ta); + }, "TypeError thrown for detached source buffer"); + + assert.sameValue(speciesCallCount, 1, "@@species getter called once"); + assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/new-instance-extensibility.js new file mode 100644 index 000000000..5fbd869d6 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/new-instance-extensibility.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-typedarray +description: > + The new typedArray instance from a typedArray argument is extensible +info: | + 22.2.4.3 TypedArray ( typedArray ) + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var typedArraySample1 = new BigInt64Array(); +var typedArraySample2 = new BigInt64Array(); +Object.preventExtensions(typedArraySample2); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample1 = new TA(typedArraySample1); + + assert(Object.isExtensible(sample1), "new instance is extensible"); + + var sample2 = new TA(typedArraySample2); + assert( + Object.isExtensible(sample2), + "new instance does not inherit extensibility from typedarray argument" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-access-throws.js new file mode 100644 index 000000000..686c02008 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-access-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-typedarray +description: > + Return abrupt completion from getting typedArray argument's buffer.constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; + var sample = new OtherCtor(); + + Object.defineProperty(sample.buffer, "constructor", { + get() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js new file mode 100644 index 000000000..5a5d7ee0a --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.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-typedarray +description: > + Derive the ArrayBuffer prototype from the realm of the species constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 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. + ... + + 9.1.14 GetPrototypeFromConstructor + + ... + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, cross-realm, Symbol.species, TypedArray] +---*/ + +var sample1 = new BigInt64Array(); +var sample2 = new BigUint64Array(); +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = TA === BigInt64Array ? sample2 : sample1; + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = C; + + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype + ); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species.js new file mode 100644 index 000000000..1ff1e5db5 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-custom-species.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 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. + ... + +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +var sample1 = new BigInt64Array(); +var sample2 = new BigUint64Array(); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = TA === BigInt64Array ? sample2 : sample1; + var ctor = {}; + var called = 0; + var custom = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() { + called++; + }; + + ctor[Symbol.species].prototype = custom; + + var typedArray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js new file mode 100644 index 000000000..44b76c2b9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.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-typedarray +description: > + Return abrupt completion from typedArray argument's buffer.constructor's value +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var sample1 = new BigInt64Array(); +var sample2 = new BigUint64Array(); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = TA === BigInt64Array ? sample2 : sample1; + + sample.buffer.constructor = 1; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = true; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = ""; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = null; + assert.throws(TypeError, function() { + new TA(sample); + }); + + var s = Symbol("1"); + sample.buffer.constructor = s; + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js new file mode 100644 index 000000000..8b3933eed --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-access-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-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +var sample1 = new BigInt64Array(); +var sample2 = new BigUint64Array(); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = TA === BigInt64Array ? sample2 : sample1; + var ctor = {}; + + sample.buffer.constructor = ctor; + Object.defineProperty(ctor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js new file mode 100644 index 000000000..09a8068e9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 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] +---*/ + +var sample1 = new BigInt64Array(); +var sample2 = new BigUint64Array(); + +var ctor = function() { + throw new Test262Error(); +}; +var m = { m() {} }.m; +ctor[Symbol.species] = m; + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = TA === BigInt64Array ? sample2 : sample1; + + sample.buffer.constructor = ctor; + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-null.js new file mode 100644 index 000000000..2eeb50e38 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-null.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-typedarray +description: > + Use default ArrayBuffer constructor on null buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 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 OtherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var sample = new OtherCtor(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = null; + var typedArray = new TA(sample); + + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is null" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js new file mode 100644 index 000000000..705b8a731 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 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. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + ... + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, + "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +var sample1 = new BigInt64Array(); +var sample2 = new BigUint64Array(); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = TA === BigInt64Array ? sample2 : sample1; + var ctor = {}; + var called = 0; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() {called++;}.bind(null); + Object.defineProperty(ctor[Symbol.species], "prototype", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js new file mode 100644 index 000000000..9a265f124 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-buffer-ctor-species-undefined.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 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 OtherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var sample = new OtherCtor(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = undefined; + var a = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(a.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is undefined" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-returns-new-typedarray.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-returns-new-typedarray.js new file mode 100644 index 000000000..754abcd42 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/other-ctor-returns-new-typedarray.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-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var sample1 = new BigInt64Array(); +var sample2 = new BigUint64Array(); + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = TA === BigInt64Array ? sample2 : sample1; + var typedArray = new TA(sample); + + assert.sameValue(typedArray.length, 7); + assert.notSameValue(typedArray, sample); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/proto-from-ctor-realm.js new file mode 100644 index 000000000..7e9498549 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/proto-from-ctor-realm.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-typedarray +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + [...] + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testBigIntTypedArray.js] +features: [BigInt, cross-realm, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithBigIntTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [new TA()], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-access-throws.js new file mode 100644 index 000000000..51fa9a835 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-access-throws.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-typedarray +description: > + Return abrupt completion from getting typedArray argument's buffer.constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(); + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js new file mode 100644 index 000000000..90de96428 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.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-typedarray +description: > + Derive the ArrayBuffer prototype from the realm of the species constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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. + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... + + 9.1.14 GetPrototypeFromConstructor + + ... + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, cross-realm, Symbol.species, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = C; + + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype + ); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom.js new file mode 100644 index 000000000..743b03e3f --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-custom.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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. + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + var called = 0; + var custom = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() { + called++; + }; + + ctor[Symbol.species].prototype = custom; + + var typedArray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js new file mode 100644 index 000000000..32cbc01bc --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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(); + var ctor = {}; + var m = { m() {} }; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = m; + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-null.js new file mode 100644 index 000000000..842ccd3d1 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-null.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-typedarray +description: > + Use default ArrayBuffer constructor on null buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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(4); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = null; + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is null" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js new file mode 100644 index 000000000..042d4213d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... + + 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. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + ... + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, + "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function(){}.bind(null); + Object.defineProperty(ctor[Symbol.species], "prototype", { + get() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-throws.js new file mode 100644 index 000000000..0aa7517b8 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-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-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + Object.defineProperty(ctor, Symbol.species, { + get() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js new file mode 100644 index 000000000..251a396e8 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-species-undefined.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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(4); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = undefined; + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is undefined" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js new file mode 100644 index 000000000..a3ca9a041 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-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-typedarray +description: > + Return abrupt completion from typedArray argument's buffer.constructor's value +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... + 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(); + + sample.buffer.constructor = 1; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = true; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = ''; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = null; + assert.throws(TypeError, function() { + new TA(sample); + }); + + var s = Symbol('1'); + sample.buffer.constructor = s; + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js new file mode 100644 index 000000000..2176cebdb --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/same-ctor-returns-new-cloned-typedarray.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-typedarray +description: > + Same typedArray ctor argument returns a new cloned typedArray +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + 23. Return O. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(7); + var typedArray = new TA(sample); + + assert.sameValue(typedArray.length, 7); + assert.notSameValue(typedArray, sample); + assert.notSameValue(typedArray.buffer, sample.buffer); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-custom-proto-access-throws.js deleted file mode 100644 index ab89da072..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-custom-proto-access-throws.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Reflect, TypedArray] ----*/ - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -var sample = new Int8Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [sample], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js deleted file mode 100644 index c5de19602..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with a different element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - ... - 19. Else, - a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] -features: [BigInt, TypedArray, Symbol.species] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - var targetType = TA !== Int32Array ? Int32Array : Uint32Array; - new targetType(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js deleted file mode 100644 index c4f45c49c..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with the same element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, byteLength, bufferConstructor). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength, cloneConstructor ) - - ... - 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). - 4. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] -features: [BigInt, TypedArray, Symbol.species] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - new TA(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js deleted file mode 100644 index 5fbd869d6..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-new-instance-extensibility.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - The new typedArray instance from a typedArray argument is extensible -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -var typedArraySample1 = new BigInt64Array(); -var typedArraySample2 = new BigInt64Array(); -Object.preventExtensions(typedArraySample2); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample1 = new TA(typedArraySample1); - - assert(Object.isExtensible(sample1), "new instance is extensible"); - - var sample2 = new TA(typedArraySample2); - assert( - Object.isExtensible(sample2), - "new instance does not inherit extensibility from typedarray argument" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index 686c02008..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; - var sample = new OtherCtor(); - - Object.defineProperty(sample.buffer, "constructor", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js deleted file mode 100644 index 5a5d7ee0a..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 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. - ... - - 9.1.14 GetPrototypeFromConstructor - - ... - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, cross-realm, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js deleted file mode 100644 index 1ff1e5db5..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 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. - ... - -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js deleted file mode 100644 index 44b76c2b9..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 4. If Type(C) is not Object, throw a TypeError exception. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ""; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol("1"); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js deleted file mode 100644 index 8b3933eed..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js deleted file mode 100644 index 09a8068e9..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 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] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -var ctor = function() { - throw new Test262Error(); -}; -var m = { m() {} }.m; -ctor[Symbol.species] = m; - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - - sample.buffer.constructor = ctor; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js deleted file mode 100644 index 2eeb50e38..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on null buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 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 OtherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; - var sample = new OtherCtor(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = null; - var typedArray = new TA(sample); - - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is null" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index 705b8a731..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 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. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() {called++;}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js deleted file mode 100644 index 9a265f124..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 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 OtherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; - var sample = new OtherCtor(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = undefined; - var a = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(a.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is undefined" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js deleted file mode 100644 index 754abcd42..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -var sample1 = new BigInt64Array(); -var sample2 = new BigUint64Array(); - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = TA === BigInt64Array ? sample2 : sample1; - var typedArray = new TA(sample); - - assert.sameValue(typedArray.length, 7); - assert.notSameValue(typedArray, sample); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js deleted file mode 100644 index 7e9498549..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - [...] - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testBigIntTypedArray.js] -features: [BigInt, cross-realm, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithBigIntTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [new TA()], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index 51fa9a835..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js deleted file mode 100644 index 90de96428..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 9.1.14 GetPrototypeFromConstructor - - ... - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, cross-realm, Symbol.species, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js deleted file mode 100644 index 743b03e3f..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js deleted file mode 100644 index 32cbc01bc..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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(); - var ctor = {}; - var m = { m() {} }; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = m; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js deleted file mode 100644 index 842ccd3d1..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on null buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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(4); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = null; - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is null" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index 042d4213d..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 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. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function(){}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js deleted file mode 100644 index 0aa7517b8..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, Symbol.species, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js deleted file mode 100644 index 251a396e8..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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(4); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = undefined; - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is undefined" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js deleted file mode 100644 index a3ca9a041..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 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(); - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ''; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol('1'); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js deleted file mode 100644 index 2176cebdb..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Same typedArray ctor argument returns a new cloned typedArray -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - 23. Return O. -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(7); - var typedArray = new TA(sample); - - assert.sameValue(typedArray.length, 7); - assert.notSameValue(typedArray, sample); - assert.notSameValue(typedArray.buffer, sample.buffer); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js deleted file mode 100644 index 82fd5c823..000000000 --- a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 2. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testBigIntTypedArray.js] -features: [BigInt, TypedArray] ----*/ - -testWithBigIntTypedArrayConstructors(function(TA) { - var typedArray = new TA(4); - - assert.throws(TypeError, function() { - TA(typedArray); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/undefined-newtarget-throws.js new file mode 100644 index 000000000..82fd5c823 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors-bigint/typedarray-arg/undefined-newtarget-throws.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-typedarray +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var typedArray = new TA(4); + + assert.throws(TypeError, function() { + TA(typedArray); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js deleted file mode 100644 index 8baba4efa..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js +++ /dev/null @@ -1,38 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Throws a RangeError if bufferByteLength modulo elementSize ≠ 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - - Let elementSize be the Number value of the Element Size value in Table 56 for constructorName.* - ... - If length is either not present or undefined, then - a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. - ... - - * Int8Array, Uint8Array, Uint8ClampedArray all have element size 1, so will never fail. - -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(1); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer); - }); - - assert.throws(RangeError, function() { - new TA(buffer, 0, undefined); - }); -}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js deleted file mode 100644 index 1c916b43c..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Throws a RangeError if bufferByteLength modulo elementSize ≠ 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 13. If length is undefined, then - a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(1); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer); - }); - - assert.throws(RangeError, function() { - new TA(buffer, 0, undefined); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws-sab.js deleted file mode 100644 index 89f58a1cd..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws-sab.js +++ /dev/null @@ -1,32 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Throws a RangeError if ToInteger(byteOffset) is < 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToInteger(byteOffset). - 8. If offset < 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer, -1); - }); - assert.throws(RangeError, function() { - new TA(buffer, -Infinity); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws.js deleted file mode 100644 index 058892465..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-throws.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Throws a RangeError if ToInteger(byteOffset) is < 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToInteger(byteOffset). - 8. If offset < 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer, -1); - }); - assert.throws(RangeError, function() { - new TA(buffer, -Infinity); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero-sab.js deleted file mode 100644 index 1073b5af8..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero-sab.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: pending -description: > - TypedArray's [[ByteOffset]] internal slot is always a positive number, test with negative zero. -info: | - %TypedArray% ( buffer [ , byteOffset [ , length ] ] ) - - ... - 6. Let offset be ? ToInteger(byteOffset). - 7. If offset < 0, throw a RangeError exception. - 8. If offset is -0, let offset be +0. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TAConstructor) { - var typedArray = new TAConstructor(new SharedArrayBuffer(8), -0); - assert.sameValue(typedArray.byteOffset, +0); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero.js deleted file mode 100644 index 13d0a3e14..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-negative-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: pending -description: > - TypedArray's [[ByteOffset]] internal slot is always a positive number, test with negative zero. -info: | - %TypedArray% ( buffer [ , byteOffset [ , length ] ] ) - - ... - 6. Let offset be ? ToInteger(byteOffset). - 7. If offset < 0, throw a RangeError exception. - 8. If offset is -0, let offset be +0. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TAConstructor) { - var typedArray = new TAConstructor(new ArrayBuffer(8), -0); - assert.sameValue(typedArray.byteOffset, +0); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws-sab.js deleted file mode 100644 index b5fc270c9..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws-sab.js +++ /dev/null @@ -1,29 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Return abrupt from parsing integer value from byteOffset as a symbol -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToInteger(byteOffset). - ... -includes: [testTypedArray.js] -features: [Symbol, SharedArrayBuffer, TypedArray] ----*/ - -var byteOffset = Symbol("1"); -var buffer = new SharedArrayBuffer(8); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(buffer, byteOffset); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws.js deleted file mode 100644 index 60039a1f5..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-is-symbol-throws.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Return abrupt from parsing integer value from byteOffset as a symbol -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToInteger(byteOffset). - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var byteOffset = Symbol("1"); -var buffer = new ArrayBuffer(8); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(buffer, byteOffset); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js deleted file mode 100644 index d67216a0c..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js +++ /dev/null @@ -1,35 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Throws a RangeError if ToInteger(byteOffset) modulo elementSize is not 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - - Let elementSize be the Number value of the Element Size value in Table 56 for constructorName.* - - ... - If offset modulo elementSize ≠ 0, throw a RangeError exception. - ... - - * Int8Array, Uint8Array, Uint8ClampedArray all have element size 1, so will never fail. - -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer, 7); - }); -}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); - diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size.js deleted file mode 100644 index f495e6bcc..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-throws-from-modulo-element-size.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Throws a RangeError if ToInteger(byteOffset) modulo elementSize is not 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 10. If offset modulo elementSize ≠ 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer, 7); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-detachbuffer.js deleted file mode 100644 index b8936e8cd..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-detachbuffer.js +++ /dev/null @@ -1,21 +0,0 @@ -// 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-buffer-byteoffset-length -description: If TypedArray() is passed a detached buffer, throw -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - ... - 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - ... -includes: [testTypedArray.js, detachArrayBuffer.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var offset = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(3 * offset); - var byteOffset = { valueOf() { $DETACHBUFFER(buffer); return offset; } }; - assert.throws(TypeError, () => new TA(buffer, byteOffset)); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws-sab.js deleted file mode 100644 index e7b336c5e..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws-sab.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Return abrupt from parsing integer value from byteOffset -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToInteger(byteOffset). - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); -var byteOffset = { - valueOf: function() { - throw new Test262Error(); - } -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(buffer, byteOffset); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws.js deleted file mode 100644 index 20cd4b796..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-byteoffset-to-number-throws.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Return abrupt from parsing integer value from byteOffset -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToInteger(byteOffset). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); -var byteOffset = { - valueOf: function() { - throw new Test262Error(); - } -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(buffer, byteOffset); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws-sab.js deleted file mode 100644 index b3ff8c56e..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws-sab.js +++ /dev/null @@ -1,48 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testTypedArray.js] -features: [Reflect, SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [buffer], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws.js deleted file mode 100644 index a1b823317..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-custom-proto-access-throws.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [buffer], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset-sab.js deleted file mode 100644 index 2107146b1..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset-sab.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Return new typedArray from defined length and offset -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var offset = TA.BYTES_PER_ELEMENT; - var buffer = new SharedArrayBuffer(3 * offset); - - var ta1 = new TA(buffer, offset, 2); - assert.sameValue(ta1.length, 2, "ta1.length"); - assert.sameValue(ta1.buffer, buffer, "ta1.buffer"); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var ta2 = new TA(buffer, offset, 0); - assert.sameValue(ta2.length, 0, "ta2.length"); - assert.sameValue(ta2.buffer, buffer, "ta2.buffer"); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset.js deleted file mode 100644 index aefd48b55..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-and-offset.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Return new typedArray from defined length and offset -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var offset = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(3 * offset); - - var ta1 = new TA(buffer, offset, 2); - assert.sameValue(ta1.length, 2, "ta1.length"); - assert.sameValue(ta1.buffer, buffer, "ta1.buffer"); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var ta2 = new TA(buffer, offset, 0); - assert.sameValue(ta2.length, 0, "ta2.length"); - assert.sameValue(ta2.buffer, buffer, "ta2.buffer"); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-sab.js deleted file mode 100644 index a06e530d0..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length-sab.js +++ /dev/null @@ -1,35 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Return new typedArray from defined length -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var length = 4; - var buffer = new SharedArrayBuffer(bpe * length * 4); - - var ta1 = new TA(buffer, 0, length); - assert.sameValue(ta1.length, length); - assert.sameValue(ta1.buffer, buffer); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var ta2 = new TA(buffer, 0, 0); - assert.sameValue(ta2.length, 0); - assert.sameValue(ta2.buffer, buffer); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length.js deleted file mode 100644 index 11fb1c4a4..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-length.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Return new typedArray from defined length -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var length = 4; - var buffer = new ArrayBuffer(bpe * length * 4); - - var ta1 = new TA(buffer, 0, length); - assert.sameValue(ta1.length, length); - assert.sameValue(ta1.buffer, buffer); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var ta2 = new TA(buffer, 0, 0); - assert.sameValue(ta2.length, 0); - assert.sameValue(ta2.buffer, buffer); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length-sab.js deleted file mode 100644 index 4d1b1d29c..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length-sab.js +++ /dev/null @@ -1,29 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Throws RangeError for negative ToInteger(length) -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(16); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer, 0, -1); - }); - - assert.throws(RangeError, function() { - new TA(buffer, 0, -Infinity); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length.js deleted file mode 100644 index d57d466d9..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-negative-length.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Throws RangeError for negative ToInteger(length) -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(16); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(buffer, 0, -1); - }); - - assert.throws(RangeError, function() { - new TA(buffer, 0, -Infinity); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset-sab.js deleted file mode 100644 index 515d822c1..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset-sab.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Return new typedArray from defined offset -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var buffer = new SharedArrayBuffer(bpe * 4); - - var ta1 = new TA(buffer, bpe * 2); - assert.sameValue(ta1.length, 2); - assert.sameValue(ta1.buffer, buffer); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var ta2 = new TA(buffer, 0); - assert.sameValue(ta2.length, 4); - assert.sameValue(ta2.buffer, buffer); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset.js deleted file mode 100644 index 89e290b52..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-defined-offset.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Return new typedArray from defined offset -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(bpe * 4); - - var ta1 = new TA(buffer, bpe * 2); - assert.sameValue(ta1.length, 2); - assert.sameValue(ta1.buffer, buffer); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var ta2 = new TA(buffer, 0); - assert.sameValue(ta2.length, 4); - assert.sameValue(ta2.buffer, buffer); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-detachedbuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-detachedbuffer.js deleted file mode 100644 index b015d4c34..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-detachedbuffer.js +++ /dev/null @@ -1,21 +0,0 @@ -// 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-buffer-byteoffset-length -description: If TypedArray() is passed a detached buffer, throw -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - ... - 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - ... -includes: [testTypedArray.js, detachArrayBuffer.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var offset = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(3 * offset); - $DETACHBUFFER(buffer); - assert.throws(TypeError, () => new TA(buffer)); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws-sab.js deleted file mode 100644 index 2549e93fd..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws-sab.js +++ /dev/null @@ -1,32 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - If offset + newByteLength > bufferByteLength, throw a RangeError exception. -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 14. Else, - a. Let newLength be ? ToLength(length). - b. Let newByteLength be newLength × elementSize. - c. If offset+newByteLength > bufferByteLength, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var buffer = new SharedArrayBuffer(bpe); - - assert.throws(RangeError, function() { - new TA(buffer, 0, bpe * 2); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws.js deleted file mode 100644 index 3ff3a6d61..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-length-throws.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - If offset + newByteLength > bufferByteLength, throw a RangeError exception. -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 14. Else, - a. Let newLength be ? ToLength(length). - b. Let newByteLength be newLength × elementSize. - c. If offset+newByteLength > bufferByteLength, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(bpe); - - assert.throws(RangeError, function() { - new TA(buffer, 0, bpe * 2); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws-sab.js deleted file mode 100644 index 62cf41145..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws-sab.js +++ /dev/null @@ -1,36 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Throws a RangeError if bufferByteLength - ToInteger(byteOffset) < 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 13. If length is undefined, then - a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. - b. Let newByteLength be bufferByteLength - offset. - c. If newByteLength < 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var buffer = new SharedArrayBuffer(bpe); - - assert.throws(RangeError, function() { - new TA(buffer, bpe * 2); - }); - - assert.throws(RangeError, function() { - new TA(buffer, bpe * 2, undefined); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws.js deleted file mode 100644 index 5daf40ce7..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-excessive-offset-throws.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Throws a RangeError if bufferByteLength - ToInteger(byteOffset) < 0 -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 13. If length is undefined, then - a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. - b. Let newByteLength be bufferByteLength - offset. - c. If newByteLength < 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(bpe); - - assert.throws(RangeError, function() { - new TA(buffer, bpe * 2); - }); - - assert.throws(RangeError, function() { - new TA(buffer, bpe * 2, undefined); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget-sab.js deleted file mode 100644 index 24061049a..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget-sab.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 2. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var buffer = new SharedArrayBuffer(4); - assert.throws(TypeError, function() { - TA(buffer); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget.js deleted file mode 100644 index 218b7c2c0..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-invoked-with-undefined-newtarget.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 2. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(4); - assert.throws(TypeError, function() { - TA(buffer); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced-sab.js deleted file mode 100644 index 44c29229c..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced-sab.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Reuse buffer argument instead of making a new clone -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 15. Set O's [[ViewedArrayBuffer]] internal slot to buffer. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - - var buffer = new SharedArrayBuffer(bpe); - - var ta1 = new TA(buffer); - var ta2 = new TA(buffer); - - assert.sameValue(ta1.buffer, buffer); - assert.sameValue(ta2.buffer, buffer); - assert.sameValue(ta1.buffer, ta2.buffer); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced.js deleted file mode 100644 index 0154deaf4..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-is-referenced.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Reuse buffer argument instead of making a new clone -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 15. Set O's [[ViewedArrayBuffer]] internal slot to buffer. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - - var buffer = new ArrayBuffer(bpe); - - var ta1 = new TA(buffer); - var ta2 = new TA(buffer); - - assert.sameValue(ta1.buffer, buffer); - assert.sameValue(ta2.buffer, buffer); - assert.sameValue(ta1.buffer, ta2.buffer); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws-sab.js deleted file mode 100644 index 16872f860..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws-sab.js +++ /dev/null @@ -1,34 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Returns abrupt from ToLength(length) -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 14. Else, - a. Let newLength be ? ToLength(length). - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); -var len = { - valueOf() { - throw new Test262Error(); - } -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(buffer, 0, len); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws.js deleted file mode 100644 index ea99b8b40..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-access-throws.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Returns abrupt from ToLength(length) -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 14. Else, - a. Let newLength be ? ToLength(length). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); -var len = { - valueOf() { - throw new Test262Error(); - } -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(buffer, 0, len); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws-sab.js deleted file mode 100644 index 8b77b806d..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws-sab.js +++ /dev/null @@ -1,30 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Throws a TypeError if length is a Symbol -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 14. Else, - a. Let newLength be ? ToLength(length). - ... -includes: [testTypedArray.js] -features: [Symbol, SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); -var s = Symbol("1"); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(buffer, 0, s); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws.js deleted file mode 100644 index db8ac8303..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-is-symbol-throws.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Throws a TypeError if length is a Symbol -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 14. Else, - a. Let newLength be ? ToLength(length). - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); -var s = Symbol("1"); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(buffer, 0, s); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-to-number-detachbuffer.js deleted file mode 100644 index c8c3eb34b..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-length-to-number-detachbuffer.js +++ /dev/null @@ -1,21 +0,0 @@ -// 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-buffer-byteoffset-length -description: If TypedArray() is passed a detached buffer, throw -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - ... - 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - ... -includes: [testTypedArray.js, detachArrayBuffer.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var offset = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(3 * offset); - var length = { valueOf() { $DETACHBUFFER(buffer); return 1; } }; - assert.throws(TypeError, () => new TA(buffer, 0, length)); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility-sab.js deleted file mode 100644 index 2b765a78f..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility-sab.js +++ /dev/null @@ -1,38 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - The new typedArray instance from a buffer argument is extensible -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var buffer = new SharedArrayBuffer(8); - var sample = new TA(buffer); - - assert(Object.isExtensible(sample)); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility.js deleted file mode 100644 index 74336215f..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-new-instance-extensibility.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - The new typedArray instance from a buffer argument is extensible -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(8); - var sample = new TA(buffer); - - assert(Object.isExtensible(sample)); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm-sab.js deleted file mode 100644 index 9cab95b47..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm-sab.js +++ /dev/null @@ -1,38 +0,0 @@ -// 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-buffer-byteoffset-length -description: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - [...] - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testTypedArray.js] -features: [cross-realm, SharedArrayBuffer, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [new SharedArrayBuffer(8)], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm.js deleted file mode 100644 index d93538db4..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-proto-from-ctor-realm.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - [...] - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testTypedArray.js] -features: [cross-realm, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [new ArrayBuffer(8)], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance-sab.js deleted file mode 100644 index 52de96252..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance-sab.js +++ /dev/null @@ -1,34 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Return new typedArray from undefined offset and length -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - - var buffer1 = new SharedArrayBuffer(bpe * 4); - var ta1 = new TA(buffer1); - assert.sameValue(ta1.length, 4); - assert.sameValue(ta1.buffer, buffer1); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var buffer2 = new SharedArrayBuffer(0); - var ta2 = new TA(buffer2); - assert.sameValue(ta2.length, 0); - assert.sameValue(ta2.buffer, buffer2); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance.js deleted file mode 100644 index 4723e75f9..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-returns-new-instance.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Return new typedArray from undefined offset and length -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var bpe = TA.BYTES_PER_ELEMENT; - - var buffer1 = new ArrayBuffer(bpe * 4); - var ta1 = new TA(buffer1); - assert.sameValue(ta1.length, 4); - assert.sameValue(ta1.buffer, buffer1); - assert.sameValue(ta1.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); - - var buffer2 = new ArrayBuffer(0); - var ta2 = new TA(buffer2); - assert.sameValue(ta2.length, 0); - assert.sameValue(ta2.buffer, buffer2); - assert.sameValue(ta2.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength-sab.js deleted file mode 100644 index 5fd87715f..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength-sab.js +++ /dev/null @@ -1,73 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - ToIndex(length) operations -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 11. If length is either not present or undefined, then - ... - 12. Else, - a. Let newLength be ? ToIndex(length). - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(16); - -var obj1 = { - valueOf: function() { - return 1; - } -}; - -var obj2 = { - toString: function() { - return 1; - } -}; - -var items = [ - [-0, 0, "-0"], - [obj1, 1, "object's valueOf"], - [obj2, 1, "object's toString"], - ["", 0, "the Empty string"], - ["0", 0, "string '0'"], - ["1", 1, "string '1'"], - [false, 0, "false"], - [true, 1, "true"], - [NaN, 0, "NaN"], - [null, 0, "null"], - [0.1, 0, "0.1"], - [0.9, 0, "0.9"], - [1.1, 1, "1.1"], - [1.9, 1, "1.9"], - [-0.1, 0, "-0.1"], - [-0.99999, 0, "-0.99999"] -]; - -testWithTypedArrayConstructors(function(TA) { - items.forEach(function(item) { - var len = item[0]; - var expected = item[1]; - var name = item[2]; - - var typedArray = new TA(buffer, 0, len); - assert.sameValue(typedArray.length, expected, name + " length"); - assert.sameValue(typedArray.constructor, TA, name + " constructor"); - assert.sameValue( - Object.getPrototypeOf(typedArray), - TA.prototype, - name + " prototype" - ); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength.js deleted file mode 100644 index ae660b820..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-bytelength.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - ToIndex(length) operations -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 11. If length is either not present or undefined, then - ... - 12. Else, - a. Let newLength be ? ToIndex(length). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(16); - -var obj1 = { - valueOf: function() { - return 1; - } -}; - -var obj2 = { - toString: function() { - return 1; - } -}; - -var items = [ - [-0, 0, "-0"], - [obj1, 1, "object's valueOf"], - [obj2, 1, "object's toString"], - ["", 0, "the Empty string"], - ["0", 0, "string '0'"], - ["1", 1, "string '1'"], - [false, 0, "false"], - [true, 1, "true"], - [NaN, 0, "NaN"], - [null, 0, "null"], - [0.1, 0, "0.1"], - [0.9, 0, "0.9"], - [1.1, 1, "1.1"], - [1.9, 1, "1.9"], - [-0.1, 0, "-0.1"], - [-0.99999, 0, "-0.99999"] -]; - -testWithTypedArrayConstructors(function(TA) { - items.forEach(function(item) { - var len = item[0]; - var expected = item[1]; - var name = item[2]; - - var typedArray = new TA(buffer, 0, len); - assert.sameValue(typedArray.length, expected, name + " length"); - assert.sameValue(typedArray.constructor, TA, name + " constructor"); - assert.sameValue( - Object.getPrototypeOf(typedArray), - TA.prototype, - name + " prototype" - ); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset-sab.js deleted file mode 100644 index 43ae9f601..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset-sab.js +++ /dev/null @@ -1,87 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - ToIndex(byteOffset) operations -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToIndex(byteOffset). - 8. If offset modulo elementSize ≠ 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(16); - -var obj1 = { - valueOf: function() { - return 8; - } -}; - -var obj2 = { - toString: function() { - return 8; - } -}; - -var items = [ - [-0, 0, "-0"], - [obj1, 8, "object's valueOf"], - [obj2, 8, "object's toString"], - ["", 0, "the Empty string"], - ["0", 0, "string '0'"], - ["8", 8, "string '8'"], - [false, 0, "false"], - [NaN, 0, "NaN"], - [null, 0, "null"], - [undefined, 0, "undefined"], - [0.1, 0, "0.1"], - [0.9, 0, "0.9"], - [8.1, 8, "8.1"], - [8.9, 8, "8.9"], - [-0.1, 0, "-0.1"], - [-0.99999, 0, "-0.99999"] -]; - -testWithTypedArrayConstructors(function(TA) { - items.forEach(function(item) { - var offset = item[0]; - var expected = item[1]; - var name = item[2]; - - var typedArray = new TA(buffer, offset); - assert.sameValue(typedArray.byteOffset, expected, name + " byteOffset"); - assert.sameValue(typedArray.constructor, TA, name + " constructor"); - assert.sameValue( - Object.getPrototypeOf(typedArray), - TA.prototype, - name + " prototype" - ); - }); - - // Testing `true`. See step 8 - if (TA.BYTES_PER_ELEMENT === 1) { - var typedArray = new TA(buffer, true); - assert.sameValue(typedArray.byteOffset, 1, "true => 1 byteOffset"); - assert.sameValue(typedArray.constructor, TA, "true => 1 constructor"); - assert.sameValue( - Object.getPrototypeOf(typedArray), - TA.prototype, - "true => 1 prototype" - ); - } else { - assert.throws(RangeError, function() { - new TA(buffer, true); - }, "1 modulo elementSize ≠ 0, throws a RangeError"); - } -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset.js deleted file mode 100644 index 35a087aaf..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-toindex-byteoffset.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - ToIndex(byteOffset) operations -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 7. Let offset be ? ToIndex(byteOffset). - 8. If offset modulo elementSize ≠ 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(16); - -var obj1 = { - valueOf: function() { - return 8; - } -}; - -var obj2 = { - toString: function() { - return 8; - } -}; - -var items = [ - [-0, 0, "-0"], - [obj1, 8, "object's valueOf"], - [obj2, 8, "object's toString"], - ["", 0, "the Empty string"], - ["0", 0, "string '0'"], - ["8", 8, "string '8'"], - [false, 0, "false"], - [NaN, 0, "NaN"], - [null, 0, "null"], - [undefined, 0, "undefined"], - [0.1, 0, "0.1"], - [0.9, 0, "0.9"], - [8.1, 8, "8.1"], - [8.9, 8, "8.9"], - [-0.1, 0, "-0.1"], - [-0.99999, 0, "-0.99999"] -]; - -testWithTypedArrayConstructors(function(TA) { - items.forEach(function(item) { - var offset = item[0]; - var expected = item[1]; - var name = item[2]; - - var typedArray = new TA(buffer, offset); - assert.sameValue(typedArray.byteOffset, expected, name + " byteOffset"); - assert.sameValue(typedArray.constructor, TA, name + " constructor"); - assert.sameValue( - Object.getPrototypeOf(typedArray), - TA.prototype, - name + " prototype" - ); - }); - - // Testing `true`. See step 8 - if (TA.BYTES_PER_ELEMENT === 1) { - var typedArray = new TA(buffer, true); - assert.sameValue(typedArray.byteOffset, 1, "true => 1 byteOffset"); - assert.sameValue(typedArray.constructor, TA, "true => 1 constructor"); - assert.sameValue( - Object.getPrototypeOf(typedArray), - TA.prototype, - "true => 1 prototype" - ); - } else { - assert.throws(RangeError, function() { - new TA(buffer, true); - }, "1 modulo elementSize ≠ 0, throws a RangeError"); - } -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-typedarray-backed-by-sharedarraybuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-typedarray-backed-by-sharedarraybuffer.js deleted file mode 100644 index 739d1cdd2..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-typedarray-backed-by-sharedarraybuffer.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2017 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - Passing a SharedArrayBuffer-backed TypedArray to a TypedArray constructor - produces an ArrayBuffer-backed TypedArray. -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var sab = new SharedArrayBuffer(4); -var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; - -testWithTypedArrayConstructors(function(View1) { - var ta1 = new View1(sab); - testWithTypedArrayConstructors(function(View2) { - var ta2 = new View2(ta1); - assert.sameValue(ta2.buffer.constructor, ArrayBuffer, - "TypedArray of SharedArrayBuffer-backed TypedArray is ArrayBuffer-backed"); - }, int_views); -}, int_views); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object-sab.js deleted file mode 100644 index c963b6bb1..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object-sab.js +++ /dev/null @@ -1,49 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Use prototype from new target if it's an Object -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [SharedArrayBuffer, Reflect, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); - -function newTarget() {} -var proto = {}; -newTarget.prototype = proto; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [buffer], newTarget); - - assert.sameValue(ta.constructor, Object); - assert.sameValue(Object.getPrototypeOf(ta), proto); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object.js deleted file mode 100644 index 9eefdf56d..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-custom-proto-if-object.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Use prototype from new target if it's an Object -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); - -function newTarget() {} -var proto = {}; -newTarget.prototype = proto; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [buffer], newTarget); - - assert.sameValue(ta.constructor, Object); - assert.sameValue(Object.getPrototypeOf(ta), proto); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js deleted file mode 100644 index 8c91aa84d..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js +++ /dev/null @@ -1,48 +0,0 @@ -// 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-buffer-byteoffset-length -description: > - Use prototype from %TypedArray% if newTarget's prototype is not an Object -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [SharedArrayBuffer, TypedArray] ----*/ - -var buffer = new SharedArrayBuffer(8); - -function newTarget() {} -newTarget.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [buffer], newTarget); - - assert.sameValue(ta.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js deleted file mode 100644 index df4909dab..000000000 --- a/test/built-ins/TypedArrays/ctors/buffer-arg/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-buffer-byteoffset-length -description: > - Use prototype from %TypedArray% if newTarget's prototype is not an Object -info: | - 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has an [[ArrayBufferData]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var buffer = new ArrayBuffer(8); - -function newTarget() {} -newTarget.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [buffer], newTarget); - - assert.sameValue(ta.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js new file mode 100644 index 000000000..8baba4efa --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size-sab.js @@ -0,0 +1,38 @@ +// 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-buffer-byteoffset-length +description: > + Throws a RangeError if bufferByteLength modulo elementSize ≠ 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + + Let elementSize be the Number value of the Element Size value in Table 56 for constructorName.* + ... + If length is either not present or undefined, then + a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. + ... + + * Int8Array, Uint8Array, Uint8ClampedArray all have element size 1, so will never fail. + +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(1); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer); + }); + + assert.throws(RangeError, function() { + new TA(buffer, 0, undefined); + }); +}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.js new file mode 100644 index 000000000..1c916b43c --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/bufferbyteoffset-throws-from-modulo-element-size.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-buffer-byteoffset-length +description: > + Throws a RangeError if bufferByteLength modulo elementSize ≠ 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 13. If length is undefined, then + a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(1); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer); + }); + + assert.throws(RangeError, function() { + new TA(buffer, 0, undefined); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js new file mode 100644 index 000000000..89f58a1cd --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws-sab.js @@ -0,0 +1,32 @@ +// 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-buffer-byteoffset-length +description: > + Throws a RangeError if ToInteger(byteOffset) is < 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + 8. If offset < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, -1); + }); + assert.throws(RangeError, function() { + new TA(buffer, -Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws.js new file mode 100644 index 000000000..058892465 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-throws.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-buffer-byteoffset-length +description: > + Throws a RangeError if ToInteger(byteOffset) is < 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + 8. If offset < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, -1); + }); + assert.throws(RangeError, function() { + new TA(buffer, -Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero-sab.js new file mode 100644 index 000000000..1073b5af8 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero-sab.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: pending +description: > + TypedArray's [[ByteOffset]] internal slot is always a positive number, test with negative zero. +info: | + %TypedArray% ( buffer [ , byteOffset [ , length ] ] ) + + ... + 6. Let offset be ? ToInteger(byteOffset). + 7. If offset < 0, throw a RangeError exception. + 8. If offset is -0, let offset be +0. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TAConstructor) { + var typedArray = new TAConstructor(new SharedArrayBuffer(8), -0); + assert.sameValue(typedArray.byteOffset, +0); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero.js new file mode 100644 index 000000000..13d0a3e14 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-negative-zero.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: pending +description: > + TypedArray's [[ByteOffset]] internal slot is always a positive number, test with negative zero. +info: | + %TypedArray% ( buffer [ , byteOffset [ , length ] ] ) + + ... + 6. Let offset be ? ToInteger(byteOffset). + 7. If offset < 0, throw a RangeError exception. + 8. If offset is -0, let offset be +0. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TAConstructor) { + var typedArray = new TAConstructor(new ArrayBuffer(8), -0); + assert.sameValue(typedArray.byteOffset, +0); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js new file mode 100644 index 000000000..b5fc270c9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws-sab.js @@ -0,0 +1,29 @@ +// 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-buffer-byteoffset-length +description: > + Return abrupt from parsing integer value from byteOffset as a symbol +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + ... +includes: [testTypedArray.js] +features: [Symbol, SharedArrayBuffer, TypedArray] +---*/ + +var byteOffset = Symbol("1"); +var buffer = new SharedArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(buffer, byteOffset); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws.js new file mode 100644 index 000000000..60039a1f5 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-is-symbol-throws.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-buffer-byteoffset-length +description: > + Return abrupt from parsing integer value from byteOffset as a symbol +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var byteOffset = Symbol("1"); +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(buffer, byteOffset); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js new file mode 100644 index 000000000..d67216a0c --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size-sab.js @@ -0,0 +1,35 @@ +// 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-buffer-byteoffset-length +description: > + Throws a RangeError if ToInteger(byteOffset) modulo elementSize is not 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + + Let elementSize be the Number value of the Element Size value in Table 56 for constructorName.* + + ... + If offset modulo elementSize ≠ 0, throw a RangeError exception. + ... + + * Int8Array, Uint8Array, Uint8ClampedArray all have element size 1, so will never fail. + +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, 7); + }); +}, [ Float64Array, Float32Array, Int32Array, Int16Array, Uint32Array, Uint16Array ]); + diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.js new file mode 100644 index 000000000..f495e6bcc --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-throws-from-modulo-element-size.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-buffer-byteoffset-length +description: > + Throws a RangeError if ToInteger(byteOffset) modulo elementSize is not 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 10. If offset modulo elementSize ≠ 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, 7); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js new file mode 100644 index 000000000..b8936e8cd --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-detachbuffer.js @@ -0,0 +1,21 @@ +// 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-buffer-byteoffset-length +description: If TypedArray() is passed a detached buffer, throw +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + ... + 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var offset = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(3 * offset); + var byteOffset = { valueOf() { $DETACHBUFFER(buffer); return offset; } }; + assert.throws(TypeError, () => new TA(buffer, byteOffset)); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws-sab.js new file mode 100644 index 000000000..e7b336c5e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws-sab.js @@ -0,0 +1,33 @@ +// 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-buffer-byteoffset-length +description: > + Return abrupt from parsing integer value from byteOffset +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); +var byteOffset = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(buffer, byteOffset); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws.js new file mode 100644 index 000000000..20cd4b796 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/byteoffset-to-number-throws.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-buffer-byteoffset-length +description: > + Return abrupt from parsing integer value from byteOffset +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); +var byteOffset = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(buffer, byteOffset); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws-sab.js new file mode 100644 index 000000000..b3ff8c56e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws-sab.js @@ -0,0 +1,48 @@ +// 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-buffer-byteoffset-length +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testTypedArray.js] +features: [Reflect, SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [buffer], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws.js new file mode 100644 index 000000000..a1b823317 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/custom-proto-access-throws.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-buffer-byteoffset-length +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [buffer], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-offset-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-offset-sab.js new file mode 100644 index 000000000..2107146b1 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-offset-sab.js @@ -0,0 +1,33 @@ +// 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-buffer-byteoffset-length +description: > + Return new typedArray from defined length and offset +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var offset = TA.BYTES_PER_ELEMENT; + var buffer = new SharedArrayBuffer(3 * offset); + + var ta1 = new TA(buffer, offset, 2); + assert.sameValue(ta1.length, 2, "ta1.length"); + assert.sameValue(ta1.buffer, buffer, "ta1.buffer"); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, offset, 0); + assert.sameValue(ta2.length, 0, "ta2.length"); + assert.sameValue(ta2.buffer, buffer, "ta2.buffer"); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-offset.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-offset.js new file mode 100644 index 000000000..aefd48b55 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-and-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-buffer-byteoffset-length +description: > + Return new typedArray from defined length and offset +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var offset = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(3 * offset); + + var ta1 = new TA(buffer, offset, 2); + assert.sameValue(ta1.length, 2, "ta1.length"); + assert.sameValue(ta1.buffer, buffer, "ta1.buffer"); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, offset, 0); + assert.sameValue(ta2.length, 0, "ta2.length"); + assert.sameValue(ta2.buffer, buffer, "ta2.buffer"); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-sab.js new file mode 100644 index 000000000..a06e530d0 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length-sab.js @@ -0,0 +1,35 @@ +// 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-buffer-byteoffset-length +description: > + Return new typedArray from defined length +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var length = 4; + var buffer = new SharedArrayBuffer(bpe * length * 4); + + var ta1 = new TA(buffer, 0, length); + assert.sameValue(ta1.length, length); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, 0, 0); + assert.sameValue(ta2.length, 0); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-length.js new file mode 100644 index 000000000..11fb1c4a4 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-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-buffer-byteoffset-length +description: > + Return new typedArray from defined length +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var length = 4; + var buffer = new ArrayBuffer(bpe * length * 4); + + var ta1 = new TA(buffer, 0, length); + assert.sameValue(ta1.length, length); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, 0, 0); + assert.sameValue(ta2.length, 0); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length-sab.js new file mode 100644 index 000000000..4d1b1d29c --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length-sab.js @@ -0,0 +1,29 @@ +// 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-buffer-byteoffset-length +description: > + Throws RangeError for negative ToInteger(length) +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(16); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, 0, -1); + }); + + assert.throws(RangeError, function() { + new TA(buffer, 0, -Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length.js new file mode 100644 index 000000000..d57d466d9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-negative-length.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-buffer-byteoffset-length +description: > + Throws RangeError for negative ToInteger(length) +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(16); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, 0, -1); + }); + + assert.throws(RangeError, function() { + new TA(buffer, 0, -Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-offset-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-offset-sab.js new file mode 100644 index 000000000..515d822c1 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-offset-sab.js @@ -0,0 +1,33 @@ +// 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-buffer-byteoffset-length +description: > + Return new typedArray from defined offset +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new SharedArrayBuffer(bpe * 4); + + var ta1 = new TA(buffer, bpe * 2); + assert.sameValue(ta1.length, 2); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, 0); + assert.sameValue(ta2.length, 4); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/defined-offset.js b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-offset.js new file mode 100644 index 000000000..89e290b52 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/defined-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-buffer-byteoffset-length +description: > + Return new typedArray from defined offset +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(bpe * 4); + + var ta1 = new TA(buffer, bpe * 2); + assert.sameValue(ta1.length, 2); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, 0); + assert.sameValue(ta2.length, 4); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/detachedbuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/detachedbuffer.js new file mode 100644 index 000000000..b015d4c34 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/detachedbuffer.js @@ -0,0 +1,21 @@ +// 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-buffer-byteoffset-length +description: If TypedArray() is passed a detached buffer, throw +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + ... + 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var offset = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(3 * offset); + $DETACHBUFFER(buffer); + assert.throws(TypeError, () => new TA(buffer)); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws-sab.js new file mode 100644 index 000000000..2549e93fd --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws-sab.js @@ -0,0 +1,32 @@ +// 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-buffer-byteoffset-length +description: > + If offset + newByteLength > bufferByteLength, throw a RangeError exception. +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + b. Let newByteLength be newLength × elementSize. + c. If offset+newByteLength > bufferByteLength, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new SharedArrayBuffer(bpe); + + assert.throws(RangeError, function() { + new TA(buffer, 0, bpe * 2); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws.js new file mode 100644 index 000000000..3ff3a6d61 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-length-throws.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-buffer-byteoffset-length +description: > + If offset + newByteLength > bufferByteLength, throw a RangeError exception. +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + b. Let newByteLength be newLength × elementSize. + c. If offset+newByteLength > bufferByteLength, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(bpe); + + assert.throws(RangeError, function() { + new TA(buffer, 0, bpe * 2); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-offset-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-offset-throws-sab.js new file mode 100644 index 000000000..62cf41145 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-offset-throws-sab.js @@ -0,0 +1,36 @@ +// 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-buffer-byteoffset-length +description: > + Throws a RangeError if bufferByteLength - ToInteger(byteOffset) < 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 13. If length is undefined, then + a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. + b. Let newByteLength be bufferByteLength - offset. + c. If newByteLength < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new SharedArrayBuffer(bpe); + + assert.throws(RangeError, function() { + new TA(buffer, bpe * 2); + }); + + assert.throws(RangeError, function() { + new TA(buffer, bpe * 2, undefined); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-offset-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-offset-throws.js new file mode 100644 index 000000000..5daf40ce7 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/excessive-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-buffer-byteoffset-length +description: > + Throws a RangeError if bufferByteLength - ToInteger(byteOffset) < 0 +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 13. If length is undefined, then + a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. + b. Let newByteLength be bufferByteLength - offset. + c. If newByteLength < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(bpe); + + assert.throws(RangeError, function() { + new TA(buffer, bpe * 2); + }); + + assert.throws(RangeError, function() { + new TA(buffer, bpe * 2, undefined); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js new file mode 100644 index 000000000..24061049a --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget-sab.js @@ -0,0 +1,27 @@ +// 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-buffer-byteoffset-length +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var buffer = new SharedArrayBuffer(4); + assert.throws(TypeError, function() { + TA(buffer); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget.js b/test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget.js new file mode 100644 index 000000000..218b7c2c0 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/invoked-with-undefined-newtarget.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-buffer-byteoffset-length +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(4); + assert.throws(TypeError, function() { + TA(buffer); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced-sab.js new file mode 100644 index 000000000..44c29229c --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced-sab.js @@ -0,0 +1,33 @@ +// 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-buffer-byteoffset-length +description: > + Reuse buffer argument instead of making a new clone +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 15. Set O's [[ViewedArrayBuffer]] internal slot to buffer. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + + var buffer = new SharedArrayBuffer(bpe); + + var ta1 = new TA(buffer); + var ta2 = new TA(buffer); + + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta1.buffer, ta2.buffer); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced.js b/test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced.js new file mode 100644 index 000000000..0154deaf4 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/is-referenced.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-buffer-byteoffset-length +description: > + Reuse buffer argument instead of making a new clone +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 15. Set O's [[ViewedArrayBuffer]] internal slot to buffer. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + + var buffer = new ArrayBuffer(bpe); + + var ta1 = new TA(buffer); + var ta2 = new TA(buffer); + + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta1.buffer, ta2.buffer); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws-sab.js new file mode 100644 index 000000000..16872f860 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws-sab.js @@ -0,0 +1,34 @@ +// 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-buffer-byteoffset-length +description: > + Returns abrupt from ToLength(length) +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); +var len = { + valueOf() { + throw new Test262Error(); + } +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(buffer, 0, len); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws.js new file mode 100644 index 000000000..ea99b8b40 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/length-access-throws.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-buffer-byteoffset-length +description: > + Returns abrupt from ToLength(length) +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); +var len = { + valueOf() { + throw new Test262Error(); + } +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(buffer, 0, len); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws-sab.js new file mode 100644 index 000000000..8b77b806d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws-sab.js @@ -0,0 +1,30 @@ +// 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-buffer-byteoffset-length +description: > + Throws a TypeError if length is a Symbol +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + ... +includes: [testTypedArray.js] +features: [Symbol, SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); +var s = Symbol("1"); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(buffer, 0, s); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws.js new file mode 100644 index 000000000..db8ac8303 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/length-is-symbol-throws.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-buffer-byteoffset-length +description: > + Throws a TypeError if length is a Symbol +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); +var s = Symbol("1"); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(buffer, 0, s); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/length-to-number-detachbuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/length-to-number-detachbuffer.js new file mode 100644 index 000000000..c8c3eb34b --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/length-to-number-detachbuffer.js @@ -0,0 +1,21 @@ +// 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-buffer-byteoffset-length +description: If TypedArray() is passed a detached buffer, throw +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + ... + 9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var offset = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(3 * offset); + var length = { valueOf() { $DETACHBUFFER(buffer); return 1; } }; + assert.throws(TypeError, () => new TA(buffer, 0, length)); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility-sab.js new file mode 100644 index 000000000..2b765a78f --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility-sab.js @@ -0,0 +1,38 @@ +// 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-buffer-byteoffset-length +description: > + The new typedArray instance from a buffer argument is extensible +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var buffer = new SharedArrayBuffer(8); + var sample = new TA(buffer); + + assert(Object.isExtensible(sample)); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility.js new file mode 100644 index 000000000..74336215f --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/new-instance-extensibility.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-buffer-byteoffset-length +description: > + The new typedArray instance from a buffer argument is extensible +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(8); + var sample = new TA(buffer); + + assert(Object.isExtensible(sample)); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm-sab.js new file mode 100644 index 000000000..9cab95b47 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm-sab.js @@ -0,0 +1,38 @@ +// 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-buffer-byteoffset-length +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + [...] + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testTypedArray.js] +features: [cross-realm, SharedArrayBuffer, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [new SharedArrayBuffer(8)], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm.js new file mode 100644 index 000000000..d93538db4 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/proto-from-ctor-realm.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-buffer-byteoffset-length +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + [...] + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testTypedArray.js] +features: [cross-realm, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [new ArrayBuffer(8)], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance-sab.js new file mode 100644 index 000000000..52de96252 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance-sab.js @@ -0,0 +1,34 @@ +// 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-buffer-byteoffset-length +description: > + Return new typedArray from undefined offset and length +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + + var buffer1 = new SharedArrayBuffer(bpe * 4); + var ta1 = new TA(buffer1); + assert.sameValue(ta1.length, 4); + assert.sameValue(ta1.buffer, buffer1); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var buffer2 = new SharedArrayBuffer(0); + var ta2 = new TA(buffer2); + assert.sameValue(ta2.length, 0); + assert.sameValue(ta2.buffer, buffer2); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance.js b/test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance.js new file mode 100644 index 000000000..4723e75f9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/returns-new-instance.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-buffer-byteoffset-length +description: > + Return new typedArray from undefined offset and length +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + + var buffer1 = new ArrayBuffer(bpe * 4); + var ta1 = new TA(buffer1); + assert.sameValue(ta1.length, 4); + assert.sameValue(ta1.buffer, buffer1); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var buffer2 = new ArrayBuffer(0); + var ta2 = new TA(buffer2); + assert.sameValue(ta2.length, 0); + assert.sameValue(ta2.buffer, buffer2); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength-sab.js new file mode 100644 index 000000000..5fd87715f --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength-sab.js @@ -0,0 +1,73 @@ +// 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-buffer-byteoffset-length +description: > + ToIndex(length) operations +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 11. If length is either not present or undefined, then + ... + 12. Else, + a. Let newLength be ? ToIndex(length). + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(16); + +var obj1 = { + valueOf: function() { + return 1; + } +}; + +var obj2 = { + toString: function() { + return 1; + } +}; + +var items = [ + [-0, 0, "-0"], + [obj1, 1, "object's valueOf"], + [obj2, 1, "object's toString"], + ["", 0, "the Empty string"], + ["0", 0, "string '0'"], + ["1", 1, "string '1'"], + [false, 0, "false"], + [true, 1, "true"], + [NaN, 0, "NaN"], + [null, 0, "null"], + [0.1, 0, "0.1"], + [0.9, 0, "0.9"], + [1.1, 1, "1.1"], + [1.9, 1, "1.9"], + [-0.1, 0, "-0.1"], + [-0.99999, 0, "-0.99999"] +]; + +testWithTypedArrayConstructors(function(TA) { + items.forEach(function(item) { + var len = item[0]; + var expected = item[1]; + var name = item[2]; + + var typedArray = new TA(buffer, 0, len); + assert.sameValue(typedArray.length, expected, name + " length"); + assert.sameValue(typedArray.constructor, TA, name + " constructor"); + assert.sameValue( + Object.getPrototypeOf(typedArray), + TA.prototype, + name + " prototype" + ); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength.js b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength.js new file mode 100644 index 000000000..ae660b820 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-bytelength.js @@ -0,0 +1,72 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-typedarray-buffer-byteoffset-length +description: > + ToIndex(length) operations +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 11. If length is either not present or undefined, then + ... + 12. Else, + a. Let newLength be ? ToIndex(length). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(16); + +var obj1 = { + valueOf: function() { + return 1; + } +}; + +var obj2 = { + toString: function() { + return 1; + } +}; + +var items = [ + [-0, 0, "-0"], + [obj1, 1, "object's valueOf"], + [obj2, 1, "object's toString"], + ["", 0, "the Empty string"], + ["0", 0, "string '0'"], + ["1", 1, "string '1'"], + [false, 0, "false"], + [true, 1, "true"], + [NaN, 0, "NaN"], + [null, 0, "null"], + [0.1, 0, "0.1"], + [0.9, 0, "0.9"], + [1.1, 1, "1.1"], + [1.9, 1, "1.9"], + [-0.1, 0, "-0.1"], + [-0.99999, 0, "-0.99999"] +]; + +testWithTypedArrayConstructors(function(TA) { + items.forEach(function(item) { + var len = item[0]; + var expected = item[1]; + var name = item[2]; + + var typedArray = new TA(buffer, 0, len); + assert.sameValue(typedArray.length, expected, name + " length"); + assert.sameValue(typedArray.constructor, TA, name + " constructor"); + assert.sameValue( + Object.getPrototypeOf(typedArray), + TA.prototype, + name + " prototype" + ); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset-sab.js new file mode 100644 index 000000000..43ae9f601 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset-sab.js @@ -0,0 +1,87 @@ +// 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-buffer-byteoffset-length +description: > + ToIndex(byteOffset) operations +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToIndex(byteOffset). + 8. If offset modulo elementSize ≠ 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(16); + +var obj1 = { + valueOf: function() { + return 8; + } +}; + +var obj2 = { + toString: function() { + return 8; + } +}; + +var items = [ + [-0, 0, "-0"], + [obj1, 8, "object's valueOf"], + [obj2, 8, "object's toString"], + ["", 0, "the Empty string"], + ["0", 0, "string '0'"], + ["8", 8, "string '8'"], + [false, 0, "false"], + [NaN, 0, "NaN"], + [null, 0, "null"], + [undefined, 0, "undefined"], + [0.1, 0, "0.1"], + [0.9, 0, "0.9"], + [8.1, 8, "8.1"], + [8.9, 8, "8.9"], + [-0.1, 0, "-0.1"], + [-0.99999, 0, "-0.99999"] +]; + +testWithTypedArrayConstructors(function(TA) { + items.forEach(function(item) { + var offset = item[0]; + var expected = item[1]; + var name = item[2]; + + var typedArray = new TA(buffer, offset); + assert.sameValue(typedArray.byteOffset, expected, name + " byteOffset"); + assert.sameValue(typedArray.constructor, TA, name + " constructor"); + assert.sameValue( + Object.getPrototypeOf(typedArray), + TA.prototype, + name + " prototype" + ); + }); + + // Testing `true`. See step 8 + if (TA.BYTES_PER_ELEMENT === 1) { + var typedArray = new TA(buffer, true); + assert.sameValue(typedArray.byteOffset, 1, "true => 1 byteOffset"); + assert.sameValue(typedArray.constructor, TA, "true => 1 constructor"); + assert.sameValue( + Object.getPrototypeOf(typedArray), + TA.prototype, + "true => 1 prototype" + ); + } else { + assert.throws(RangeError, function() { + new TA(buffer, true); + }, "1 modulo elementSize ≠ 0, throws a RangeError"); + } +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset.js b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset.js new file mode 100644 index 000000000..35a087aaf --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/toindex-byteoffset.js @@ -0,0 +1,86 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-typedarray-buffer-byteoffset-length +description: > + ToIndex(byteOffset) operations +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToIndex(byteOffset). + 8. If offset modulo elementSize ≠ 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(16); + +var obj1 = { + valueOf: function() { + return 8; + } +}; + +var obj2 = { + toString: function() { + return 8; + } +}; + +var items = [ + [-0, 0, "-0"], + [obj1, 8, "object's valueOf"], + [obj2, 8, "object's toString"], + ["", 0, "the Empty string"], + ["0", 0, "string '0'"], + ["8", 8, "string '8'"], + [false, 0, "false"], + [NaN, 0, "NaN"], + [null, 0, "null"], + [undefined, 0, "undefined"], + [0.1, 0, "0.1"], + [0.9, 0, "0.9"], + [8.1, 8, "8.1"], + [8.9, 8, "8.9"], + [-0.1, 0, "-0.1"], + [-0.99999, 0, "-0.99999"] +]; + +testWithTypedArrayConstructors(function(TA) { + items.forEach(function(item) { + var offset = item[0]; + var expected = item[1]; + var name = item[2]; + + var typedArray = new TA(buffer, offset); + assert.sameValue(typedArray.byteOffset, expected, name + " byteOffset"); + assert.sameValue(typedArray.constructor, TA, name + " constructor"); + assert.sameValue( + Object.getPrototypeOf(typedArray), + TA.prototype, + name + " prototype" + ); + }); + + // Testing `true`. See step 8 + if (TA.BYTES_PER_ELEMENT === 1) { + var typedArray = new TA(buffer, true); + assert.sameValue(typedArray.byteOffset, 1, "true => 1 byteOffset"); + assert.sameValue(typedArray.constructor, TA, "true => 1 constructor"); + assert.sameValue( + Object.getPrototypeOf(typedArray), + TA.prototype, + "true => 1 prototype" + ); + } else { + assert.throws(RangeError, function() { + new TA(buffer, true); + }, "1 modulo elementSize ≠ 0, throws a RangeError"); + } +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js b/test/built-ins/TypedArrays/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js new file mode 100644 index 000000000..739d1cdd2 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/typedarray-backed-by-sharedarraybuffer.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray-typedarray +description: > + Passing a SharedArrayBuffer-backed TypedArray to a TypedArray constructor + produces an ArrayBuffer-backed TypedArray. +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var sab = new SharedArrayBuffer(4); +var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; + +testWithTypedArrayConstructors(function(View1) { + var ta1 = new View1(sab); + testWithTypedArrayConstructors(function(View2) { + var ta2 = new View2(ta1); + assert.sameValue(ta2.buffer.constructor, ArrayBuffer, + "TypedArray of SharedArrayBuffer-backed TypedArray is ArrayBuffer-backed"); + }, int_views); +}, int_views); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object-sab.js new file mode 100644 index 000000000..c963b6bb1 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object-sab.js @@ -0,0 +1,49 @@ +// 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-buffer-byteoffset-length +description: > + Use prototype from new target if it's an Object +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [SharedArrayBuffer, Reflect, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [buffer], newTarget); + + assert.sameValue(ta.constructor, Object); + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object.js new file mode 100644 index 000000000..9eefdf56d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/use-custom-proto-if-object.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-buffer-byteoffset-length +description: > + Use prototype from new target if it's an Object +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [buffer], newTarget); + + assert.sameValue(ta.constructor, Object); + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js b/test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js new file mode 100644 index 000000000..8c91aa84d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object-sab.js @@ -0,0 +1,48 @@ +// 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-buffer-byteoffset-length +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var buffer = new SharedArrayBuffer(8); + +function newTarget() {} +newTarget.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [buffer], newTarget); + + assert.sameValue(ta.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.js new file mode 100644 index 000000000..df4909dab --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/buffer-arg/use-default-proto-if-custom-proto-is-not-object.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-buffer-byteoffset-length +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: | + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(8); + +function newTarget() {} +newTarget.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [buffer], newTarget); + + assert.sameValue(ta.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/length-arg/custom-proto-access-throws.js new file mode 100644 index 000000000..6ad49fdab --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/custom-proto-access-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-length +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 8. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, elementLength). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [1], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/init-zeros.js b/test/built-ins/TypedArrays/ctors/length-arg/init-zeros.js new file mode 100644 index 000000000..b36131709 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/init-zeros.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-length +description: All bytes are initialized to zero +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 8. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, elementLength). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 5. If length was not passed, then + ... + 6. Else, + a. Perform ? AllocateTypedArrayBuffer(obj, length). + + 22.2.4.2.2 Runtime Semantics: AllocateTypedArrayBuffer + + 7. Let data be ? AllocateArrayBuffer(%ArrayBuffer%, byteLength). + + 24.1.1.1 AllocateArrayBuffer + + 3. Let block be ? CreateByteDataBlock(byteLength). + + 6.2.6.1 CreateByteDataBlock + + 1. Assert: size≥0. + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + 3. Set all of the bytes of db to 0. + 4. Return db. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var subject = new TA(9); + + assert.sameValue(subject[0], 0, 'index 0'); + assert.sameValue(subject[1], 0, 'index 1'); + assert.sameValue(subject[2], 0, 'index 2'); + assert.sameValue(subject[3], 0, 'index 3'); + assert.sameValue(subject[4], 0, 'index 4'); + assert.sameValue(subject[5], 0, 'index 5'); + assert.sameValue(subject[6], 0, 'index 6'); + assert.sameValue(subject[7], 0, 'index 7'); + assert.sameValue(subject[8], 0, 'index 8'); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/is-infinity-throws-rangeerror.js b/test/built-ins/TypedArrays/ctors/length-arg/is-infinity-throws-rangeerror.js new file mode 100644 index 000000000..0084d5d6a --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/is-infinity-throws-rangeerror.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-length +description: > + Throws a RangeError if length is a Infinity value +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 4. Let numberLength be ? ToNumber(length). + 5. Let elementLength be ToLength(numberLength). + 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/is-negative-integer-throws-rangeerror.js b/test/built-ins/TypedArrays/ctors/length-arg/is-negative-integer-throws-rangeerror.js new file mode 100644 index 000000000..0ff5d5a3f --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/is-negative-integer-throws-rangeerror.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-length +description: > + Throws a RangeError if ToInteger(length) is a negative value +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 3. Let elementLength be ? ToIndex(length). + ... + + 7.1.17 ToIndex ( value ) + + 1. If value is undefined, then + ... + 2. Else, + a. Let integerIndex be ? ToInteger(value). + b. If integerIndex < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(-1); + }); + + assert.throws(RangeError, function() { + new TA(-Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/length-arg/is-symbol-throws.js new file mode 100644 index 000000000..797dd4922 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/is-symbol-throws.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-length +description: > + If length is a Symbol, throw a TypeError exception. +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 4. Let numberLength be ? ToNumber(length). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol('1'); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(s); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-custom-proto-access-throws.js deleted file mode 100644 index 6ad49fdab..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-custom-proto-access-throws.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 8. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, elementLength). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [1], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-init-zeros.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-init-zeros.js deleted file mode 100644 index b36131709..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-init-zeros.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: All bytes are initialized to zero -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 8. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, elementLength). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 5. If length was not passed, then - ... - 6. Else, - a. Perform ? AllocateTypedArrayBuffer(obj, length). - - 22.2.4.2.2 Runtime Semantics: AllocateTypedArrayBuffer - - 7. Let data be ? AllocateArrayBuffer(%ArrayBuffer%, byteLength). - - 24.1.1.1 AllocateArrayBuffer - - 3. Let block be ? CreateByteDataBlock(byteLength). - - 6.2.6.1 CreateByteDataBlock - - 1. Assert: size≥0. - 2. Let db be a new Data Block value consisting of size bytes. If it is - impossible to create such a Data Block, throw a RangeError exception. - 3. Set all of the bytes of db to 0. - 4. Return db. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var subject = new TA(9); - - assert.sameValue(subject[0], 0, 'index 0'); - assert.sameValue(subject[1], 0, 'index 1'); - assert.sameValue(subject[2], 0, 'index 2'); - assert.sameValue(subject[3], 0, 'index 3'); - assert.sameValue(subject[4], 0, 'index 4'); - assert.sameValue(subject[5], 0, 'index 5'); - assert.sameValue(subject[6], 0, 'index 6'); - assert.sameValue(subject[7], 0, 'index 7'); - assert.sameValue(subject[8], 0, 'index 8'); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-infinity-throws-rangeerror.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-infinity-throws-rangeerror.js deleted file mode 100644 index 0084d5d6a..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-infinity-throws-rangeerror.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - Throws a RangeError if length is a Infinity value -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 4. Let numberLength be ? ToNumber(length). - 5. Let elementLength be ToLength(numberLength). - 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError - exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(Infinity); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-negative-integer-throws-rangeerror.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-negative-integer-throws-rangeerror.js deleted file mode 100644 index 0ff5d5a3f..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-negative-integer-throws-rangeerror.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - Throws a RangeError if ToInteger(length) is a negative value -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 3. Let elementLength be ? ToIndex(length). - ... - - 7.1.17 ToIndex ( value ) - - 1. If value is undefined, then - ... - 2. Else, - a. Let integerIndex be ? ToInteger(value). - b. If integerIndex < 0, throw a RangeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(-1); - }); - - assert.throws(RangeError, function() { - new TA(-Infinity); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-symbol-throws.js deleted file mode 100644 index 797dd4922..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-is-symbol-throws.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - If length is a Symbol, throw a TypeError exception. -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 4. Let numberLength be ? ToNumber(length). - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var s = Symbol('1'); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(s); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-new-instance-extensibility.js deleted file mode 100644 index d9b03deca..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-new-instance-extensibility.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - The new typedArray instance from a length argument is extensible -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 8. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, elementLength). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(4); - - assert(Object.isExtensible(sample)); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-proto-from-ctor-realm.js deleted file mode 100644 index 77cef2616..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-proto-from-ctor-realm.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 8. Return ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%", elementLength). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testTypedArray.js] -features: [cross-realm, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [0], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-returns-object.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-returns-object.js deleted file mode 100644 index 8a9121d88..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-returns-object.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - Return a TypedArray object -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 8. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, elementLength). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 7. Return obj -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(4); - var length = typedArray.length; - - assert.sameValue(length, 4, "length"); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-toindex-length.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-toindex-length.js deleted file mode 100644 index 4d16ff711..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-toindex-length.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - ToIndex(length) operations -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 3. Let elementLength be ? ToIndex(length). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var items = [ - [-0, 0, "-0"], - ["", 0, "the Empty string"], - ["0", 0, "string '0'"], - ["1", 1, "string '1'"], - [true, 1, "true"], - [false, 0, "false"], - [NaN, 0, "NaN"], - [null, 0, "null"], - [undefined, 0, "undefined"], - [0.1, 0, "0.1"], - [0.9, 0, "0.9"], - [1.1, 1, "1.1"], - [1.9, 1, "1.9"], - [-0.1, 0, "-0.1"], - [-0.99999, 0, "-0.99999"] -]; - -testWithTypedArrayConstructors(function(TA) { - items.forEach(function(item) { - var len = item[0]; - var expected = item[1]; - var name = item[2]; - - var typedArray = new TA(len); - assert.sameValue(typedArray.length, expected, name + " length"); - assert.sameValue(typedArray.constructor, TA, name + " constructor"); - assert.sameValue( - Object.getPrototypeOf(typedArray), - TA.prototype, - name + " prototype" - ); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-undefined-newtarget-throws.js deleted file mode 100644 index 6a238255e..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-undefined-newtarget-throws.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 2. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - TA(0); - }); - - assert.throws(TypeError, function() { - TA(Infinity); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-custom-proto-if-object.js deleted file mode 100644 index b36ff7014..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-custom-proto-if-object.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - Use prototype from new target if it's an Object -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 8. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, elementLength). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -function newTarget() {} -var proto = {}; -newTarget.prototype = proto; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [1], newTarget); - - assert.sameValue(ta.constructor, Object); - assert.sameValue(Object.getPrototypeOf(ta), proto); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js deleted file mode 100644 index e5fc367c0..000000000 --- a/test/built-ins/TypedArrays/ctors/length-arg/length-arg-use-default-proto-if-custom-proto-is-not-object.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-length -description: > - Use prototype from %TypedArray% if newTarget's prototype is not an Object -info: | - 22.2.4.2 TypedArray ( length ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is not Object. - - ... - 8. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, elementLength). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -function newTarget() {} -newTarget.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [1], newTarget); - - assert.sameValue(ta.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/length-arg/new-instance-extensibility.js new file mode 100644 index 000000000..d9b03deca --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/new-instance-extensibility.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-length +description: > + The new typedArray instance from a length argument is extensible +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 8. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, elementLength). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(4); + + assert(Object.isExtensible(sample)); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/length-arg/proto-from-ctor-realm.js new file mode 100644 index 000000000..77cef2616 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/proto-from-ctor-realm.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-length +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 8. Return ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%", elementLength). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testTypedArray.js] +features: [cross-realm, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [0], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/returns-object.js b/test/built-ins/TypedArrays/ctors/length-arg/returns-object.js new file mode 100644 index 000000000..8a9121d88 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/returns-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-length +description: > + Return a TypedArray object +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 8. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, elementLength). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 7. Return obj +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(4); + var length = typedArray.length; + + assert.sameValue(length, 4, "length"); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/toindex-length.js b/test/built-ins/TypedArrays/ctors/length-arg/toindex-length.js new file mode 100644 index 000000000..4d16ff711 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/toindex-length.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-length +description: > + ToIndex(length) operations +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 3. Let elementLength be ? ToIndex(length). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var items = [ + [-0, 0, "-0"], + ["", 0, "the Empty string"], + ["0", 0, "string '0'"], + ["1", 1, "string '1'"], + [true, 1, "true"], + [false, 0, "false"], + [NaN, 0, "NaN"], + [null, 0, "null"], + [undefined, 0, "undefined"], + [0.1, 0, "0.1"], + [0.9, 0, "0.9"], + [1.1, 1, "1.1"], + [1.9, 1, "1.9"], + [-0.1, 0, "-0.1"], + [-0.99999, 0, "-0.99999"] +]; + +testWithTypedArrayConstructors(function(TA) { + items.forEach(function(item) { + var len = item[0]; + var expected = item[1]; + var name = item[2]; + + var typedArray = new TA(len); + assert.sameValue(typedArray.length, expected, name + " length"); + assert.sameValue(typedArray.constructor, TA, name + " constructor"); + assert.sameValue( + Object.getPrototypeOf(typedArray), + TA.prototype, + name + " prototype" + ); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/length-arg/undefined-newtarget-throws.js new file mode 100644 index 000000000..6a238255e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/undefined-newtarget-throws.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-length +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA(0); + }); + + assert.throws(TypeError, function() { + TA(Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/length-arg/use-custom-proto-if-object.js new file mode 100644 index 000000000..b36ff7014 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/use-custom-proto-if-object.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-length +description: > + Use prototype from new target if it's an Object +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 8. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, elementLength). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [1], newTarget); + + assert.sameValue(ta.constructor, Object); + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.js new file mode 100644 index 000000000..e5fc367c0 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/length-arg/use-default-proto-if-custom-proto-is-not-object.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-length +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: | + 22.2.4.2 TypedArray ( length ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is not Object. + + ... + 8. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, elementLength). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +function newTarget() {} +newTarget.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [1], newTarget); + + assert.sameValue(ta.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/no-args/custom-proto-access-throws.js new file mode 100644 index 000000000..6b383e32e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/no-args/custom-proto-access-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 +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.1 TypedArray( ) + + This description applies only if the TypedArray function is called with no + arguments. + + ... + 3. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, 0). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/no-args/new-instance-extensibility.js new file mode 100644 index 000000000..cced58d2e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/no-args/new-instance-extensibility.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 +description: > + The new typedArray instance is extensible +info: | + 22.2.4.1 TypedArray( ) + + This description applies only if the TypedArray function is called with no + arguments. + + ... + 3. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, 0). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert(Object.isExtensible(sample)); +}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/no-args-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/no-args/no-args-custom-proto-access-throws.js deleted file mode 100644 index 6b383e32e..000000000 --- a/test/built-ins/TypedArrays/ctors/no-args/no-args-custom-proto-access-throws.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 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: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.1 TypedArray( ) - - This description applies only if the TypedArray function is called with no - arguments. - - ... - 3. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, 0). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/no-args-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/no-args/no-args-new-instance-extensibility.js deleted file mode 100644 index cced58d2e..000000000 --- a/test/built-ins/TypedArrays/ctors/no-args/no-args-new-instance-extensibility.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 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: > - The new typedArray instance is extensible -info: | - 22.2.4.1 TypedArray( ) - - This description applies only if the TypedArray function is called with no - arguments. - - ... - 3. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, 0). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - - assert(Object.isExtensible(sample)); -}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/no-args-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/no-args/no-args-proto-from-ctor-realm.js deleted file mode 100644 index c69922185..000000000 --- a/test/built-ins/TypedArrays/ctors/no-args/no-args-proto-from-ctor-realm.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 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: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 3. Return ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%", 0). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testTypedArray.js] -features: [cross-realm, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/no-args-returns-object.js b/test/built-ins/TypedArrays/ctors/no-args/no-args-returns-object.js deleted file mode 100644 index c7274e5f9..000000000 --- a/test/built-ins/TypedArrays/ctors/no-args/no-args-returns-object.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 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: > - Return a TypedArray object -info: | - 22.2.4.1 TypedArray( ) - - This description applies only if the TypedArray function is called with no - arguments. - - ... - 3. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, 0). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 7. Return obj -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(); - - assert.sameValue(typedArray.length, 0); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/no-args-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/no-args/no-args-undefined-newtarget-throws.js deleted file mode 100644 index a06139865..000000000 --- a/test/built-ins/TypedArrays/ctors/no-args/no-args-undefined-newtarget-throws.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 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: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.1 TypedArray( ) - - This description applies only if the TypedArray function is called with no - arguments. - - 1. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - TA(); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/no-args-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/no-args/no-args-use-custom-proto-if-object.js deleted file mode 100644 index 4266724f0..000000000 --- a/test/built-ins/TypedArrays/ctors/no-args/no-args-use-custom-proto-if-object.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 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: > - Use prototype from new target if it's an Object -info: | - 22.2.4.1 TypedArray( ) - - This description applies only if the TypedArray function is called with no - arguments. - - ... - 3. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, 0). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -function newTarget() {} -var proto = {}; -newTarget.prototype = proto; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [], newTarget); - - assert.sameValue(ta.constructor, Object); - assert.sameValue(Object.getPrototypeOf(ta), proto); -}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js deleted file mode 100644 index e76ef585e..000000000 --- a/test/built-ins/TypedArrays/ctors/no-args/no-args-use-default-proto-if-custom-proto-is-not-object.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 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: > - Use prototype from %TypedArray% if newTarget's prototype is not an Object -info: | - 22.2.4.1 TypedArray( ) - - This description applies only if the TypedArray function is called with no - arguments. - - ... - 3. Return ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%, 0). - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -function newTarget() {} -newTarget.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [], newTarget); - - assert.sameValue(ta.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/no-args/proto-from-ctor-realm.js new file mode 100644 index 000000000..c69922185 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/no-args/proto-from-ctor-realm.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 +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 3. Return ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%", 0). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testTypedArray.js] +features: [cross-realm, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/returns-object.js b/test/built-ins/TypedArrays/ctors/no-args/returns-object.js new file mode 100644 index 000000000..c7274e5f9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/no-args/returns-object.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 +description: > + Return a TypedArray object +info: | + 22.2.4.1 TypedArray( ) + + This description applies only if the TypedArray function is called with no + arguments. + + ... + 3. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, 0). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 7. Return obj +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(); + + assert.sameValue(typedArray.length, 0); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/no-args/undefined-newtarget-throws.js new file mode 100644 index 000000000..a06139865 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/no-args/undefined-newtarget-throws.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 +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.1 TypedArray( ) + + This description applies only if the TypedArray function is called with no + arguments. + + 1. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA(); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/no-args/use-custom-proto-if-object.js new file mode 100644 index 000000000..4266724f0 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/no-args/use-custom-proto-if-object.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 +description: > + Use prototype from new target if it's an Object +info: | + 22.2.4.1 TypedArray( ) + + This description applies only if the TypedArray function is called with no + arguments. + + ... + 3. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, 0). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], newTarget); + + assert.sameValue(ta.constructor, Object); + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.js new file mode 100644 index 000000000..e76ef585e --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/no-args/use-default-proto-if-custom-proto-is-not-object.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 +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: | + 22.2.4.1 TypedArray( ) + + This description applies only if the TypedArray function is called with no + arguments. + + ... + 3. Return ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%, 0). + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +function newTarget() {} +newTarget.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], newTarget); + + assert.sameValue(ta.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/as-array-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/as-array-returns.js new file mode 100644 index 000000000..a5e3c3bbc --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/as-array-returns.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-object +description: > + Return typedArray from array argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = [7, 42]; + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(obj); + assert.sameValue(typedArray.length, 2); + assert.sameValue(typedArray[0], 7); + assert.sameValue(typedArray[1], 42); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/as-generator-iterable-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/as-generator-iterable-returns.js new file mode 100644 index 000000000..f9af0defe --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/as-generator-iterable-returns.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-object +description: > + Return typedArray from iterable argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var obj = (function *() { + yield 7; yield 42; + })(); + + var typedArray = new TA(obj); + assert.sameValue(typedArray.length, 2); + assert.sameValue(typedArray[0], 7); + assert.sameValue(typedArray[1], 42); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/conversion-operation-consistent-nan.js b/test/built-ins/TypedArrays/ctors/object-arg/conversion-operation-consistent-nan.js new file mode 100644 index 000000000..d01684942 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/conversion-operation-consistent-nan.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-object +description: Consistent canonicalization of NaN values +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 9. Repeat, while k < len + ... + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue). + ... + + 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 first = new FloatArray(distinctNaNs); + var second = new FloatArray(distinctNaNs); + var firstBytes = new Uint8Array(first.buffer); + var secondBytes = new Uint8Array(second.buffer); + + assert(compareArray(firstBytes, secondBytes)); +} + +testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/conversion-operation.js b/test/built-ins/TypedArrays/ctors/object-arg/conversion-operation.js new file mode 100644 index 000000000..959054911 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/conversion-operation.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-object +description: > + Verify conversion values on returned instance +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 9. Repeat, while k < len + ... + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue). + ... + + 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) { + var sample = new TA([value]); + + assert.sameValue(sample[0], expected, value + " converts to " + expected); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/custom-proto-access-throws.js new file mode 100644 index 000000000..f5ced4ea4 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/custom-proto-access-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-object +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +var o = {}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [o], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/iterating-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/iterating-throws.js new file mode 100644 index 000000000..41fc55509 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/iterating-throws.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-object +description: > + Return abrupt from iterating object argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var obj = (function *() { + yield 0; + throw new Test262Error(); + })(); + + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/iterator-not-callable-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/iterator-not-callable-throws.js new file mode 100644 index 000000000..ad6db0877 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/iterator-not-callable-throws.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-object +description: > + Return abrupt when object @@iterator is not callable +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var obj = function () {}; + +testWithTypedArrayConstructors(function(TA) { + obj[Symbol.iterator] = {}; + assert.throws(TypeError, function() { + new TA(obj); + }); + + obj[Symbol.iterator] = true; + assert.throws(TypeError, function() { + new TA(obj); + }); + + obj[Symbol.iterator] = 42; + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/iterator-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/iterator-throws.js new file mode 100644 index 000000000..571ad77ad --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/iterator-throws.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-object +description: > + Return abrupt from getting object @@iterator +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var obj = function () {}; + +Object.defineProperty(obj, Symbol.iterator, { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/length-excessive-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/length-excessive-throws.js new file mode 100644 index 000000000..f8279f50a --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/length-excessive-throws.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-object +description: > + Return abrupt from allocating array buffer with excessive length +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 6. Perform ? AllocateTypedArrayBuffer(O, len). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + length: Math.pow(2, 53) +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/length-is-symbol-throws.js new file mode 100644 index 000000000..b452dea03 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/length-is-symbol-throws.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-object +description: > + Return abrupt from length property as a Symbol on the object argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 5. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var obj = { + length: Symbol("1") +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/length-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/length-throws.js new file mode 100644 index 000000000..08f8cd130 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/length-throws.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-object +description: > + Return abrupt from getting length property on the object argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 5. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/object-arg/new-instance-extensibility.js new file mode 100644 index 000000000..86a2ac837 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/new-instance-extensibility.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-object +description: > + The new typedArray instance from an object argument is extensible +info: | + 22.2.4.4 TypedArray ( object ) + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + "0": 0, + "1": 1, + "2": 2, + length: 3 +}; + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(obj); + + assert(Object.isExtensible(sample)); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js deleted file mode 100644 index a5e3c3bbc..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-array-returns.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return typedArray from array argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var obj = [7, 42]; - -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(obj); - assert.sameValue(typedArray.length, 2); - assert.sameValue(typedArray[0], 7); - assert.sameValue(typedArray[1], 42); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.js deleted file mode 100644 index f9af0defe..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-as-generator-iterable-returns.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return typedArray from iterable argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var obj = (function *() { - yield 7; yield 42; - })(); - - var typedArray = new TA(obj); - assert.sameValue(typedArray.length, 2); - assert.sameValue(typedArray[0], 7); - assert.sameValue(typedArray[1], 42); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js deleted file mode 100644 index d01684942..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation-consistent-nan.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: Consistent canonicalization of NaN values -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 9. Repeat, while k < len - ... - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue). - ... - - 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 first = new FloatArray(distinctNaNs); - var second = new FloatArray(distinctNaNs); - var firstBytes = new Uint8Array(first.buffer); - var secondBytes = new Uint8Array(second.buffer); - - assert(compareArray(firstBytes, secondBytes)); -} - -testWithTypedArrayConstructors(body, [Float32Array, Float64Array]); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js deleted file mode 100644 index 959054911..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-conversion-operation.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-object -description: > - Verify conversion values on returned instance -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 9. Repeat, while k < len - ... - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 15. Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue). - ... - - 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) { - var sample = new TA([value]); - - assert.sameValue(sample[0], expected, value + " converts to " + expected); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.js deleted file mode 100644 index f5ced4ea4..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-custom-proto-access-throws.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], - NewTarget, "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -var o = {}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [o], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.js deleted file mode 100644 index 41fc55509..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterating-throws.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from iterating object argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 4. Let arrayLike be ? IterableToArrayLike(object). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var obj = (function *() { - yield 0; - throw new Test262Error(); - })(); - - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.js deleted file mode 100644 index ad6db0877..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-not-callable-throws.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt when object @@iterator is not callable -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 4. Let arrayLike be ? IterableToArrayLike(object). - ... -includes: [testTypedArray.js] -features: [Symbol.iterator, TypedArray] ----*/ - -var obj = function () {}; - -testWithTypedArrayConstructors(function(TA) { - obj[Symbol.iterator] = {}; - assert.throws(TypeError, function() { - new TA(obj); - }); - - obj[Symbol.iterator] = true; - assert.throws(TypeError, function() { - new TA(obj); - }); - - obj[Symbol.iterator] = 42; - assert.throws(TypeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.js deleted file mode 100644 index 571ad77ad..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-iterator-throws.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from getting object @@iterator -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 4. Let arrayLike be ? IterableToArrayLike(object). - ... -includes: [testTypedArray.js] -features: [Symbol.iterator, TypedArray] ----*/ - -var obj = function () {}; - -Object.defineProperty(obj, Symbol.iterator, { - get() { - throw new Test262Error(); - } -}); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.js deleted file mode 100644 index f8279f50a..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-excessive-throws.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from allocating array buffer with excessive length -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 6. Perform ? AllocateTypedArrayBuffer(O, len). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var obj = { - length: Math.pow(2, 53) -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(RangeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.js deleted file mode 100644 index b452dea03..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-is-symbol-throws.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from length property as a Symbol on the object argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 5. Let len be ? ToLength(? Get(arrayLike, "length")). - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var obj = { - length: Symbol("1") -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.js deleted file mode 100644 index 08f8cd130..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-length-throws.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from getting length property on the object argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 5. Let len be ? ToLength(? Get(arrayLike, "length")). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var obj = {}; - -Object.defineProperty(obj, "length", { - get() { - throw new Test262Error(); - } -}); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.js deleted file mode 100644 index 86a2ac837..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-new-instance-extensibility.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - The new typedArray instance from an object argument is extensible -info: | - 22.2.4.4 TypedArray ( object ) - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var obj = { - "0": 0, - "1": 1, - "2": 2, - length: 3 -}; - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(obj); - - assert(Object.isExtensible(sample)); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js deleted file mode 100644 index a92ceee00..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-proto-from-ctor-realm.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - [...] - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testTypedArray.js] -features: [cross-realm, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [{}], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js deleted file mode 100644 index 57eec9720..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-returns.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return typedArray from object argument -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var obj = { - "0": null, - "2": 42, - "3": "7", - "4": NaN, - "5": Symbol("1"), - length: 5 -}; - -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(obj); - assert.sameValue(typedArray.length, 5); - assert.sameValue(typedArray[0], 0); - assert.sameValue(typedArray[2], 42); - assert.sameValue(typedArray[3], 7); - assert.sameValue(typedArray[5], undefined); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); - - if (TA === Float32Array || TA === Float64Array) { - assert.sameValue(typedArray[1], NaN); - assert.sameValue(typedArray[4], NaN); - } else { - assert.sameValue(typedArray[1], 0); - assert.sameValue(typedArray[4], 0); - } -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.js deleted file mode 100644 index f9d384b5c..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-from-property.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from getting object property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var obj = { - length: 4 -}; - -Object.defineProperty(obj, "2", { - get() { - throw new Test262Error(); - } -}); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js deleted file mode 100644 index 215bf75fc..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive-typeerror.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Throw TypeError from @@toPrimitive returning an Object when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [Symbol.toPrimitive, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var toPrimitive = 0; - var valueOf = 0; - - sample[Symbol.toPrimitive] = function() { - toPrimitive++; - return {}; - }; - - sample.valueOf = function() { - valueOf++; - }; - - assert.throws(TypeError, function() { - new TA([8, sample]); - }, "abrupt completion from sample @@toPrimitive"); - - assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); - assert.sameValue(valueOf, 0, "sample.valueOf is not called"); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js deleted file mode 100644 index 7a7170b6f..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-to-primitive.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from @@toPrimitive when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - ... -includes: [testTypedArray.js] -features: [Symbol.toPrimitive, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var toPrimitive = 0; - var valueOf = 0; - - sample[Symbol.toPrimitive] = function() { - toPrimitive++; - throw new Test262Error(); - }; - - sample.valueOf = function() { - valueOf++; - }; - - assert.throws(Test262Error, function() { - new TA([8, sample]); - }, "abrupt completion from sample @@toPrimitive"); - - assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); - assert.sameValue(valueOf, 0, "it does not call sample.valueOf"); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js deleted file mode 100644 index 482e11595..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-tostring.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from toString() when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... - 7. Return ? OrdinaryToPrimitive(input, hint). - - OrdinaryToPrimitive - - ... - 5. For each name in methodNames in List order, do - a. Let method be ? Get(O, name). - b. If IsCallable(method) is true, then - i. Let result be ? Call(method, O). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var valueOf = 0; - var toString = 0; - - sample.valueOf = function() { - valueOf++; - return {}; - }; - - sample.toString = function() { - toString++; - throw new Test262Error(); - }; - - assert.throws(Test262Error, function() { - new TA([8, sample]); - }, "abrupt completion from ToNumber(sample)"); - - assert.sameValue(valueOf, 1, "valueOf called once"); - assert.sameValue(toString, 1, "toString called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js deleted file mode 100644 index 767dd2182..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof-typeerror.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Throw TypeError from OrdinaryToPrimitive when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... - 7. Return ? OrdinaryToPrimitive(input, hint). - - OrdinaryToPrimitive - - ... - 5. For each name in methodNames in List order, do - a. Let method be ? Get(O, name). - b. If IsCallable(method) is true, then - i. Let result be ? Call(method, O). - ii. If Type(result) is not Object, return result. - 6. Throw a TypeError exception. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var valueOf = 0; - var toString = 0; - - sample.valueOf = function() { - valueOf++; - return {}; - }; - - sample.toString = function() { - toString++; - return {}; - }; - - assert.throws(TypeError, function() { - new TA([8, sample]); - }, "abrupt completion from ToNumber(sample)"); - - assert.sameValue(valueOf, 1, "valueOf called once"); - assert.sameValue(toString, 1, "toString called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js deleted file mode 100644 index f9baf7758..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-obj-valueof.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from valueOf() when setting a property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... - - 9.4.5.5 [[Set]] ( P, V, Receiver) - - ... - 2. If Type(P) is String and if SameValue(O, Receiver) is true, then - a. Let numericIndex be ! CanonicalNumericIndexString(P). - b. If numericIndex is not undefined, then - i. Return ? IntegerIndexedElementSet(O, numericIndex, V). - ... - - 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - - ... - 3. Let numValue be ? ToNumber(value). - ... - - 7.1.3 ToNumber ( argument ) - - Object, Apply the following steps: - - 1. Let primValue be ? ToPrimitive(argument, hint Number). - 2. Return ? ToNumber(primValue). - - 7.1.1 ToPrimitive ( input [ , PreferredType ] ) - - ... - 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). - 5. If exoticToPrim is not undefined, then - a. Let result be ? Call(exoticToPrim, input, « hint »). - b. If Type(result) is not Object, return result. - c. Throw a TypeError exception. - ... - 7. Return ? OrdinaryToPrimitive(input, hint). - - OrdinaryToPrimitive - - ... - 5. For each name in methodNames in List order, do - a. Let method be ? Get(O, name). - b. If IsCallable(method) is true, then - i. Let result be ? Call(method, O). - ii. If Type(result) is not Object, return result. - 6. Throw a TypeError exception. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new Int8Array(1); - var valueOf = 0; - - sample.valueOf = function() { - valueOf++; - throw new Test262Error(); - }; - - assert.throws(Test262Error, function() { - new TA([8, sample]); - }, "abrupt completion from ToNumber(sample)"); - - assert.sameValue(valueOf, 1, "valueOf called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.js deleted file mode 100644 index 93f85dc98..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-property.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from setting property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var obj = { - "2": { - valueOf() { - throw new Test262Error(); - } - }, - length: 4 -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.js deleted file mode 100644 index 42b4a54b8..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-throws-setting-symbol-property.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Return abrupt from setting property -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 8. Repeat, while k < len - ... - b. Let kValue be ? Get(arrayLike, Pk). - c. Perform ? Set(O, Pk, kValue, true). - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var obj = { - "2": Symbol("1"), - length: 4 -}; - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - new TA(obj); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.js deleted file mode 100644 index 36f68493a..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-undefined-newtarget-throws.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 2. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - assert.throws(TypeError, function() { - TA({}); - }); - - assert.throws(TypeError, function() { - TA([]); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js deleted file mode 100644 index bb5754a9c..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-custom-proto-if-object.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Use prototype from new target if it's an Object -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], - NewTarget, "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -function newTarget() {} -var proto = {}; -newTarget.prototype = proto; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [], newTarget); - - assert.sameValue(ta.constructor, Object); - assert.sameValue(Object.getPrototypeOf(ta), proto); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js deleted file mode 100644 index 6aba187c2..000000000 --- a/test/built-ins/TypedArrays/ctors/object-arg/object-arg-use-default-proto-if-custom-proto-is-not-object.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-object -description: > - Use prototype from %TypedArray% if newTarget's prototype is not an Object -info: | - 22.2.4.4 TypedArray ( object ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] - internal slot. - - ... - 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], - NewTarget, "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -function newTarget() {} -newTarget.prototype = null; -var o = []; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [o], newTarget); - - assert.sameValue(ta.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/object-arg/proto-from-ctor-realm.js new file mode 100644 index 000000000..a92ceee00 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/proto-from-ctor-realm.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-object +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + [...] + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testTypedArray.js] +features: [cross-realm, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [{}], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/returns.js b/test/built-ins/TypedArrays/ctors/object-arg/returns.js new file mode 100644 index 000000000..57eec9720 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/returns.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-object +description: > + Return typedArray from object argument +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var obj = { + "0": null, + "2": 42, + "3": "7", + "4": NaN, + "5": Symbol("1"), + length: 5 +}; + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(obj); + assert.sameValue(typedArray.length, 5); + assert.sameValue(typedArray[0], 0); + assert.sameValue(typedArray[2], 42); + assert.sameValue(typedArray[3], 7); + assert.sameValue(typedArray[5], undefined); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); + + if (TA === Float32Array || TA === Float64Array) { + assert.sameValue(typedArray[1], NaN); + assert.sameValue(typedArray[4], NaN); + } else { + assert.sameValue(typedArray[1], 0); + assert.sameValue(typedArray[4], 0); + } +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-from-property.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-from-property.js new file mode 100644 index 000000000..f9d384b5c --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-from-property.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-object +description: > + Return abrupt from getting object property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + length: 4 +}; + +Object.defineProperty(obj, "2", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.js new file mode 100644 index 000000000..215bf75fc --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive-typeerror.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-object +description: > + Throw TypeError from @@toPrimitive returning an Object when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.toPrimitive, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var toPrimitive = 0; + var valueOf = 0; + + sample[Symbol.toPrimitive] = function() { + toPrimitive++; + return {}; + }; + + sample.valueOf = function() { + valueOf++; + }; + + assert.throws(TypeError, function() { + new TA([8, sample]); + }, "abrupt completion from sample @@toPrimitive"); + + assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); + assert.sameValue(valueOf, 0, "sample.valueOf is not called"); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive.js new file mode 100644 index 000000000..7a7170b6f --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-to-primitive.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-object +description: > + Return abrupt from @@toPrimitive when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + ... +includes: [testTypedArray.js] +features: [Symbol.toPrimitive, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var toPrimitive = 0; + var valueOf = 0; + + sample[Symbol.toPrimitive] = function() { + toPrimitive++; + throw new Test262Error(); + }; + + sample.valueOf = function() { + valueOf++; + }; + + assert.throws(Test262Error, function() { + new TA([8, sample]); + }, "abrupt completion from sample @@toPrimitive"); + + assert.sameValue(toPrimitive, 1, "toPrimitive was called once"); + assert.sameValue(valueOf, 0, "it does not call sample.valueOf"); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-tostring.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-tostring.js new file mode 100644 index 000000000..482e11595 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-tostring.js @@ -0,0 +1,88 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-typedarray-object +description: > + Return abrupt from toString() when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... + 7. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive + + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var valueOf = 0; + var toString = 0; + + sample.valueOf = function() { + valueOf++; + return {}; + }; + + sample.toString = function() { + toString++; + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + new TA([8, sample]); + }, "abrupt completion from ToNumber(sample)"); + + assert.sameValue(valueOf, 1, "valueOf called once"); + assert.sameValue(toString, 1, "toString called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof-typeerror.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof-typeerror.js new file mode 100644 index 000000000..767dd2182 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof-typeerror.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-object +description: > + Throw TypeError from OrdinaryToPrimitive when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... + 7. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive + + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var valueOf = 0; + var toString = 0; + + sample.valueOf = function() { + valueOf++; + return {}; + }; + + sample.toString = function() { + toString++; + return {}; + }; + + assert.throws(TypeError, function() { + new TA([8, sample]); + }, "abrupt completion from ToNumber(sample)"); + + assert.sameValue(valueOf, 1, "valueOf called once"); + assert.sameValue(toString, 1, "toString called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof.js new file mode 100644 index 000000000..f9baf7758 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-obj-valueof.js @@ -0,0 +1,82 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-typedarray-object +description: > + Return abrupt from valueOf() when setting a property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... + + 9.4.5.5 [[Set]] ( P, V, Receiver) + + ... + 2. If Type(P) is String and if SameValue(O, Receiver) is true, then + a. Let numericIndex be ! CanonicalNumericIndexString(P). + b. If numericIndex is not undefined, then + i. Return ? IntegerIndexedElementSet(O, numericIndex, V). + ... + + 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) + + ... + 3. Let numValue be ? ToNumber(value). + ... + + 7.1.3 ToNumber ( argument ) + + Object, Apply the following steps: + + 1. Let primValue be ? ToPrimitive(argument, hint Number). + 2. Return ? ToNumber(primValue). + + 7.1.1 ToPrimitive ( input [ , PreferredType ] ) + + ... + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. + ... + 7. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive + + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new Int8Array(1); + var valueOf = 0; + + sample.valueOf = function() { + valueOf++; + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + new TA([8, sample]); + }, "abrupt completion from ToNumber(sample)"); + + assert.sameValue(valueOf, 1, "valueOf called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-property.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-property.js new file mode 100644 index 000000000..93f85dc98 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-property.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-object +description: > + Return abrupt from setting property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + "2": { + valueOf() { + throw new Test262Error(); + } + }, + length: 4 +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-symbol-property.js b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-symbol-property.js new file mode 100644 index 000000000..42b4a54b8 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/throws-setting-symbol-property.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-object +description: > + Return abrupt from setting property +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var obj = { + "2": Symbol("1"), + length: 4 +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/object-arg/undefined-newtarget-throws.js new file mode 100644 index 000000000..36f68493a --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/undefined-newtarget-throws.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-object +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA({}); + }); + + assert.throws(TypeError, function() { + TA([]); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/object-arg/use-custom-proto-if-object.js new file mode 100644 index 000000000..bb5754a9c --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/use-custom-proto-if-object.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-object +description: > + Use prototype from new target if it's an Object +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], newTarget); + + assert.sameValue(ta.constructor, Object); + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.js new file mode 100644 index 000000000..6aba187c2 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/object-arg/use-default-proto-if-custom-proto-is-not-object.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-object +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: | + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +function newTarget() {} +newTarget.prototype = null; +var o = []; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [o], newTarget); + + assert.sameValue(ta.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/custom-proto-access-throws.js new file mode 100644 index 000000000..281d09353 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/custom-proto-access-throws.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-typedarray +description: > + Return abrupt completion getting newTarget's prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +var sample = new Int8Array(); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [sample], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js new file mode 100644 index 000000000..8ee2fba54 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-different-type.js @@ -0,0 +1,61 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray-typedarray +description: > + When a TypedArray is created from another TypedArray with a different element-type + and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still + executed. +info: | + 22.2.4.3 TypedArray ( typedArray ) + + ... + 16. If IsSharedArrayBuffer(srcData) is false, then + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + 18. If SameValue(elementType, srcType) is true, then + ... + 19. Else, + a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", + « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray, Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var speciesCallCount = 0; + var bufferConstructor = Object.defineProperty({}, Symbol.species, { + get: function() { + speciesCallCount += 1; + $DETACHBUFFER(ta.buffer); + return speciesConstructor; + } + }); + + var prototypeCallCount = 0; + var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { + get: function() { + prototypeCallCount += 1; + return null; + } + }); + + var ta = new TA(0); + ta.buffer.constructor = bufferConstructor; + + assert.throws(TypeError, function() { + var targetType = TA !== Int32Array ? Int32Array : Uint32Array; + new targetType(ta); + }, "TypeError thrown for detached source buffer"); + + assert.sameValue(speciesCallCount, 1, "@@species getter called once"); + assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js new file mode 100644 index 000000000..978f42af6 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/detached-when-species-retrieved-same-type.js @@ -0,0 +1,64 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-typedarray-typedarray +description: > + When a TypedArray is created from another TypedArray with the same element-type + and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still + executed. +info: | + 22.2.4.3 TypedArray ( typedArray ) + + ... + 16. If IsSharedArrayBuffer(srcData) is false, then + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + 18. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, byteLength, bufferConstructor). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength, cloneConstructor ) + + ... + 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). + 4. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", + « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray, Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var speciesCallCount = 0; + var bufferConstructor = Object.defineProperty({}, Symbol.species, { + get: function() { + speciesCallCount += 1; + $DETACHBUFFER(ta.buffer); + return speciesConstructor; + } + }); + + var prototypeCallCount = 0; + var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { + get: function() { + prototypeCallCount += 1; + return null; + } + }); + + var ta = new TA(0); + ta.buffer.constructor = bufferConstructor; + + assert.throws(TypeError, function() { + new TA(ta); + }, "TypeError thrown for detached source buffer"); + + assert.sameValue(speciesCallCount, 1, "@@species getter called once"); + assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/new-instance-extensibility.js new file mode 100644 index 000000000..d29848bf8 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/new-instance-extensibility.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-typedarray +description: > + The new typedArray instance from a typedArray argument is extensible +info: | + 22.2.4.3 TypedArray ( typedArray ) + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + ... + 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 11. Set the [[Extensible]] internal slot of A to true. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var typedArraySample1 = new Int8Array(); +var typedArraySample2 = new Int8Array(); +Object.preventExtensions(typedArraySample2); + +testWithTypedArrayConstructors(function(TA) { + var sample1 = new TA(typedArraySample1); + + assert(Object.isExtensible(sample1), "new instance is extensible"); + + var sample2 = new TA(typedArraySample2); + assert( + Object.isExtensible(sample2), + "new instance does not inherit extensibility from typedarray argument" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-access-throws.js new file mode 100644 index 000000000..b8976d696 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-access-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-typedarray +description: > + Return abrupt completion from getting typedArray argument's buffer.constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; + var sample = new OtherCtor(); + + Object.defineProperty(sample.buffer, "constructor", { + get() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js new file mode 100644 index 000000000..03860d1a7 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.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-typedarray +description: > + Derive the ArrayBuffer prototype from the realm of the species constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 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. + ... + + 9.1.14 GetPrototypeFromConstructor + + ... + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + ... +includes: [testTypedArray.js] +features: [cross-realm, Symbol.species, TypedArray] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = C; + + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype + ); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.js new file mode 100644 index 000000000..a510d7806 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-custom-species.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 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. + ... + +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + var called = 0; + var custom = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() { + called++; + }; + + ctor[Symbol.species].prototype = custom; + + var typedArray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.js new file mode 100644 index 000000000..cfb79f1a9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-not-object-throws.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-typedarray +description: > + Return abrupt completion from typedArray argument's buffer.constructor's value +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + + sample.buffer.constructor = 1; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = true; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = ""; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = null; + assert.throws(TypeError, function() { + new TA(sample); + }); + + var s = Symbol("1"); + sample.buffer.constructor = s; + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-access-throws.js new file mode 100644 index 000000000..4b0b19aca --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-access-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-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + + sample.buffer.constructor = ctor; + Object.defineProperty(ctor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.js new file mode 100644 index 000000000..c485cae13 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-not-ctor-throws.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 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] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +var ctor = function() { + throw new Test262Error(); +}; +var m = { m() {} }.m; +ctor[Symbol.species] = m; + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + + sample.buffer.constructor = ctor; + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-null.js new file mode 100644 index 000000000..96ba9009d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-null.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-typedarray +description: > + Use default ArrayBuffer constructor on null buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 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 OtherCtor = TA === Int8Array ? Int16Array : Int8Array; + var sample = new OtherCtor(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = null; + var typedArray = new TA(sample); + + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is null" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.js new file mode 100644 index 000000000..135634646 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-prototype-throws.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 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. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + ... + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, + "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + var called = 0; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() {called++;}.bind(null); + Object.defineProperty(ctor[Symbol.species], "prototype", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-undefined.js new file mode 100644 index 000000000..32e78a37d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-buffer-ctor-species-undefined.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 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 OtherCtor = TA === Int8Array ? Int16Array : Int8Array; + var sample = new OtherCtor(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = undefined; + var a = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(a.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is undefined" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-returns-new-typedarray.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-returns-new-typedarray.js new file mode 100644 index 000000000..411248ffd --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/other-ctor-returns-new-typedarray.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-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var sample1 = new Int8Array(7); +var sample2 = new Int16Array(7); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var typedArray = new TA(sample); + + assert.sameValue(typedArray.length, 7); + assert.notSameValue(typedArray, sample); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/proto-from-ctor-realm.js new file mode 100644 index 000000000..6e58746cd --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/proto-from-ctor-realm.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-typedarray +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + "%TypedArrayPrototype%"). + [...] + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +includes: [testTypedArray.js] +features: [cross-realm, Reflect, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [new TA()], C); + + assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/returns-new-instance.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/returns-new-instance.js new file mode 100644 index 000000000..357730df5 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/returns-new-instance.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-typedarray +description: > + Return a TypedArray object +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 20. Return O. + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var len = 10; +var typedArraySample = new Int8Array(len); + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(typedArraySample); + + assert.notSameValue(typedArray, typedArraySample); + assert.sameValue(typedArray.length, len); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-access-throws.js new file mode 100644 index 000000000..f8e75d209 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-access-throws.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-typedarray +description: > + Return abrupt completion from getting typedArray argument's buffer.constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js new file mode 100644 index 000000000..43743b956 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.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-typedarray +description: > + Derive the ArrayBuffer prototype from the realm of the species constructor +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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. + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... + + 9.1.14 GetPrototypeFromConstructor + + ... + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + ... +includes: [testTypedArray.js] +features: [cross-realm, Symbol.species, TypedArray] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = C; + + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype + ); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.js new file mode 100644 index 000000000..7ed3aca0d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-custom.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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. + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + var called = 0; + var custom = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() { + called++; + }; + + ctor[Symbol.species].prototype = custom; + + var typedArray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.js new file mode 100644 index 000000000..2072aa96d --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-not-ctor.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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(); + var ctor = {}; + var m = { m() {} }; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = m; + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.js new file mode 100644 index 000000000..e42780610 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-null.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-typedarray +description: > + Use default ArrayBuffer constructor on null buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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(4); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = null; + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is null" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.js new file mode 100644 index 000000000..b171826cf --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-prototype-throws.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-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... + + 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. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + ... + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, + "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function(){}.bind(null); + Object.defineProperty(ctor[Symbol.species], "prototype", { + get() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-throws.js new file mode 100644 index 000000000..ec2aaf3c1 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-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-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + Object.defineProperty(ctor, Symbol.species, { + get() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.js new file mode 100644 index 000000000..339d3041b --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-species-undefined.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-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 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(4); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = undefined; + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is undefined" + ); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-throws.js new file mode 100644 index 000000000..ef9709749 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-buffer-ctor-value-not-obj-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-typedarray +description: > + Return abrupt completion from typedArray argument's buffer.constructor's value +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + + sample.buffer.constructor = 1; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = true; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = ''; + assert.throws(TypeError, function() { + new TA(sample); + }); + + sample.buffer.constructor = null; + assert.throws(TypeError, function() { + new TA(sample); + }); + + var s = Symbol('1'); + sample.buffer.constructor = s; + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.js new file mode 100644 index 000000000..4d9b442c9 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/same-ctor-returns-new-cloned-typedarray.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-typedarray +description: > + Same typedArray ctor argument returns a new cloned typedArray +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + 23. Return O. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(7); + var typedArray = new TA(sample); + + assert.sameValue(typedArray.length, 7); + assert.notSameValue(typedArray, sample); + assert.notSameValue(typedArray.buffer, sample.buffer); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-custom-proto-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-custom-proto-access-throws.js deleted file mode 100644 index 281d09353..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-custom-proto-access-throws.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion getting newTarget's prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - ... - - 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) - - ... - 3. Let proto be ? Get(constructor, "prototype"). - ... -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -var newTarget = function() {}.bind(null); -Object.defineProperty(newTarget, "prototype", { - get() { - throw new Test262Error(); - } -}); - -var sample = new Int8Array(); - -testWithTypedArrayConstructors(function(TA) { - assert.throws(Test262Error, function() { - Reflect.construct(TA, [sample], newTarget); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js deleted file mode 100644 index 8ee2fba54..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-different-type.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with a different element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - ... - 19. Else, - a. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testTypedArray.js, detachArrayBuffer.js] -features: [TypedArray, Symbol.species] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - var targetType = TA !== Int32Array ? Int32Array : Uint32Array; - new targetType(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js deleted file mode 100644 index 978f42af6..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-detached-when-species-retrieved-same-type.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2017 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-typedarray-typedarray -description: > - When a TypedArray is created from another TypedArray with the same element-type - and SpeciesConstructor detaches the source buffer, AllocateArrayBuffer is still - executed. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 16. If IsSharedArrayBuffer(srcData) is false, then - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - 18. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, byteLength, bufferConstructor). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset, srcLength, cloneConstructor ) - - ... - 3. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, srcLength). - 4. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%ArrayBufferPrototype%", - « [[ArrayBufferData]], [[ArrayBufferByteLength]] »). - ... -includes: [testTypedArray.js, detachArrayBuffer.js] -features: [TypedArray, Symbol.species] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var speciesCallCount = 0; - var bufferConstructor = Object.defineProperty({}, Symbol.species, { - get: function() { - speciesCallCount += 1; - $DETACHBUFFER(ta.buffer); - return speciesConstructor; - } - }); - - var prototypeCallCount = 0; - var speciesConstructor = Object.defineProperty(function(){}.bind(), "prototype", { - get: function() { - prototypeCallCount += 1; - return null; - } - }); - - var ta = new TA(0); - ta.buffer.constructor = bufferConstructor; - - assert.throws(TypeError, function() { - new TA(ta); - }, "TypeError thrown for detached source buffer"); - - assert.sameValue(speciesCallCount, 1, "@@species getter called once"); - assert.sameValue(prototypeCallCount, 1, "prototype getter called once"); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-new-instance-extensibility.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-new-instance-extensibility.js deleted file mode 100644 index d29848bf8..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-new-instance-extensibility.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - The new typedArray instance from a typedArray argument is extensible -info: | - 22.2.4.3 TypedArray ( typedArray ) - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - ... - 2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 11. Set the [[Extensible]] internal slot of A to true. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var typedArraySample1 = new Int8Array(); -var typedArraySample2 = new Int8Array(); -Object.preventExtensions(typedArraySample2); - -testWithTypedArrayConstructors(function(TA) { - var sample1 = new TA(typedArraySample1); - - assert(Object.isExtensible(sample1), "new instance is extensible"); - - var sample2 = new TA(typedArraySample2); - assert( - Object.isExtensible(sample2), - "new instance does not inherit extensibility from typedarray argument" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index b8976d696..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; - var sample = new OtherCtor(); - - Object.defineProperty(sample.buffer, "constructor", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js deleted file mode 100644 index 03860d1a7..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species-proto-from-ctor-realm.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 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. - ... - - 9.1.14 GetPrototypeFromConstructor - - ... - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - ... -includes: [testTypedArray.js] -features: [cross-realm, Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js deleted file mode 100644 index a510d7806..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-custom-species.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 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. - ... - -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js deleted file mode 100644 index cfb79f1a9..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 4. If Type(C) is not Object, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ""; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol("1"); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js deleted file mode 100644 index 4b0b19aca..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js deleted file mode 100644 index c485cae13..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 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] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -var ctor = function() { - throw new Test262Error(); -}; -var m = { m() {} }.m; -ctor[Symbol.species] = m; - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - - sample.buffer.constructor = ctor; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js deleted file mode 100644 index 96ba9009d..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-null.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on null buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 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 OtherCtor = TA === Int8Array ? Int16Array : Int8Array; - var sample = new OtherCtor(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = null; - var typedArray = new TA(sample); - - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is null" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index 135634646..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). - ... - - 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. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -var sample1 = new Int8Array(); -var sample2 = new Int16Array(); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - var called = 0; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() {called++;}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js deleted file mode 100644 index 32e78a37d..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 18. Else, - a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). - ... - - 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 OtherCtor = TA === Int8Array ? Int16Array : Int8Array; - var sample = new OtherCtor(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = undefined; - var a = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(a.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is undefined" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js deleted file mode 100644 index 411248ffd..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-other-ctor-returns-new-typedarray.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var sample1 = new Int8Array(7); -var sample2 = new Int16Array(7); - -testWithTypedArrayConstructors(function(TA) { - var sample = TA === Int8Array ? sample2 : sample1; - var typedArray = new TA(sample); - - assert.sameValue(typedArray.length, 7); - assert.notSameValue(typedArray, sample); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js deleted file mode 100644 index 6e58746cd..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-proto-from-ctor-realm.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: Default [[Prototype]] value derived from realm of the newTarget -info: | - [...] - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - "%TypedArrayPrototype%"). - [...] - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - [...] - - 9.1.14 GetPrototypeFromConstructor - - [...] - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - 5. Return proto. -includes: [testTypedArray.js] -features: [cross-realm, Reflect, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [new TA()], C); - - assert.sameValue(Object.getPrototypeOf(ta), other[TA.name].prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-returns-new-instance.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-returns-new-instance.js deleted file mode 100644 index 357730df5..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-returns-new-instance.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return a TypedArray object -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 20. Return O. - -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -var len = 10; -var typedArraySample = new Int8Array(len); - -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(typedArraySample); - - assert.notSameValue(typedArray, typedArraySample); - assert.sameValue(typedArray.length, len); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js deleted file mode 100644 index f8e75d209..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-access-throws.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from getting typedArray argument's buffer.constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js deleted file mode 100644 index 43743b956..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom-proto-from-ctor-realm.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Derive the ArrayBuffer prototype from the realm of the species constructor -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 9.1.14 GetPrototypeFromConstructor - - ... - 3. Let proto be ? Get(constructor, "prototype"). - 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). - b. Let proto be realm's intrinsic object named intrinsicDefaultProto. - ... -includes: [testTypedArray.js] -features: [cross-realm, Symbol.species, TypedArray] ----*/ - -var other = $262.createRealm().global; -var C = new other.Function(); -C.prototype = null; - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = C; - - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), other.ArrayBuffer.prototype - ); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js deleted file mode 100644 index 7ed3aca0d..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-custom.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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. - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - var called = 0; - var custom = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function() { - called++; - }; - - ctor[Symbol.species].prototype = custom; - - var typedArray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); - assert.sameValue(called, 0); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js deleted file mode 100644 index 2072aa96d..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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(); - var ctor = {}; - var m = { m() {} }; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = m; - - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js deleted file mode 100644 index e42780610..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-null.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on null buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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(4); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = null; - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is null" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js deleted file mode 100644 index b171826cf..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from buffer.constructor.@@species.prototype -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). - ... - - 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. - ... - - 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) - - ... - 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, - "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = function(){}.bind(null); - Object.defineProperty(ctor[Symbol.species], "prototype", { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js deleted file mode 100644 index ec2aaf3c1..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-throws.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt from getting typedArray argument's buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 5. Let S be ? Get(C, @@species). - ... -includes: [testTypedArray.js] -features: [Symbol.species, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - var ctor = {}; - - sample.buffer.constructor = ctor; - Object.defineProperty(ctor, Symbol.species, { - get() { - throw new Test262Error(); - } - }); - - assert.throws(Test262Error, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js deleted file mode 100644 index 339d3041b..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use default ArrayBuffer constructor on undefined buffer.constructor.@@species -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 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(4); - var ctor = {}; - - sample.buffer.constructor = ctor; - - ctor[Symbol.species] = undefined; - var typedArray = new TA(sample); - assert.sameValue( - Object.getPrototypeOf(typedArray.buffer), - ArrayBuffer.prototype, - "buffer ctor is not called when species is undefined" - ); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js deleted file mode 100644 index ef9709749..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Return abrupt completion from typedArray argument's buffer.constructor's value -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - - 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) - - ... - 2. If cloneConstructor is not present, then - a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). - ... - - 7.3.20 SpeciesConstructor ( O, defaultConstructor ) - - ... - 2. Let C be ? Get(O, "constructor"). - ... - 4. If Type(C) is not Object, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [Symbol, TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(); - - sample.buffer.constructor = 1; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = true; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = ''; - assert.throws(TypeError, function() { - new TA(sample); - }); - - sample.buffer.constructor = null; - assert.throws(TypeError, function() { - new TA(sample); - }); - - var s = Symbol('1'); - sample.buffer.constructor = s; - assert.throws(TypeError, function() { - new TA(sample); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js deleted file mode 100644 index 4d9b442c9..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Same typedArray ctor argument returns a new cloned typedArray -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 17. If SameValue(elementType, srcType) is true, then - a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). - ... - 23. Return O. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var sample = new TA(7); - var typedArray = new TA(sample); - - assert.sameValue(typedArray.length, 7); - assert.notSameValue(typedArray, sample); - assert.notSameValue(typedArray.buffer, sample.buffer); - assert.sameValue(typedArray.constructor, TA); - assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js deleted file mode 100644 index 12839b2d7..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-undefined-newtarget-throws.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Throws a TypeError if NewTarget is undefined. -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 2. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -testWithTypedArrayConstructors(function(TA) { - var typedArray = new TA(4); - - assert.throws(TypeError, function() { - TA(typedArray); - }); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-custom-proto-if-object.js deleted file mode 100644 index 8af612edc..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-custom-proto-if-object.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use prototype from new target if it's an Object -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [Reflect, TypedArray] ----*/ - -function newTarget() {} -var proto = {}; -newTarget.prototype = proto; - -var sample = new Int8Array(8); - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [sample], newTarget); - - assert.sameValue(ta.constructor, Object); - assert.sameValue(Object.getPrototypeOf(ta), proto); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js deleted file mode 100644 index b31bd96e4..000000000 --- a/test/built-ins/TypedArrays/ctors/typedarray-arg/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-typedarray-typedarray -description: > - Use prototype from %TypedArray% if newTarget's prototype is not an Object -info: | - 22.2.4.3 TypedArray ( typedArray ) - - This description applies only if the TypedArray function is called with at - least one argument and the Type of the first argument is Object and that - object has a [[TypedArrayName]] internal slot. - - ... - 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, - %TypedArrayPrototype%). - ... - - 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, - defaultProto [ , length ]) - - 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). - 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], - [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). - ... - - 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) - - ... - 10. Set the [[Prototype]] internal slot of A to prototype. - ... - 12. Return A. -includes: [testTypedArray.js] -features: [TypedArray] ----*/ - -function newTarget() {} -newTarget.prototype = null; - -var sample = new Int8Array(8); - -testWithTypedArrayConstructors(function(TA) { - var ta = Reflect.construct(TA, [sample], newTarget); - - assert.sameValue(ta.constructor, TA); - assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); -}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/undefined-newtarget-throws.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/undefined-newtarget-throws.js new file mode 100644 index 000000000..12839b2d7 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/undefined-newtarget-throws.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-typedarray +description: > + Throws a TypeError if NewTarget is undefined. +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(4); + + assert.throws(TypeError, function() { + TA(typedArray); + }); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/use-custom-proto-if-object.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/use-custom-proto-if-object.js new file mode 100644 index 000000000..8af612edc --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/use-custom-proto-if-object.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-typedarray +description: > + Use prototype from new target if it's an Object +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [Reflect, TypedArray] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +var sample = new Int8Array(8); + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [sample], newTarget); + + assert.sameValue(ta.constructor, Object); + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.js b/test/built-ins/TypedArrays/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.js new file mode 100644 index 000000000..b31bd96e4 --- /dev/null +++ b/test/built-ins/TypedArrays/ctors/typedarray-arg/use-default-proto-if-custom-proto-is-not-object.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-typedarray +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: | + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +function newTarget() {} +newTarget.prototype = null; + +var sample = new Int8Array(8); + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [sample], newTarget); + + assert.sameValue(ta.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); -- cgit v1.2.1