summaryrefslogtreecommitdiff
path: root/test/built-ins
diff options
context:
space:
mode:
authorShu-yu Guo <shu@rfrn.org>2017-02-07 08:17:31 -0800
committerLeo Balter <leonardo.balter@gmail.com>2017-02-07 11:17:31 -0500
commita72ee6d91275aa6524e84a9b7070103411ef2689 (patch)
treea1d9c9ce58036edff2e278b716d7947bcf43e416 /test/built-ins
parent204266794c93dc917008c9db68e34cb9f94db1d2 (diff)
downloadqtdeclarative-testsuites-a72ee6d91275aa6524e84a9b7070103411ef2689.tar.gz
SharedArrayBuffer and Atomics tests (#839)
Diffstat (limited to 'test/built-ins')
-rw-r--r--test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js16
-rw-r--r--test/built-ins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js13
-rw-r--r--test/built-ins/Atomics/Symbol.toStringTag.js20
-rw-r--r--test/built-ins/Atomics/add/bad-range.js19
-rw-r--r--test/built-ins/Atomics/add/descriptor.js12
-rw-r--r--test/built-ins/Atomics/add/good-views.js53
-rw-r--r--test/built-ins/Atomics/add/length.js29
-rw-r--r--test/built-ins/Atomics/add/name.js15
-rw-r--r--test/built-ins/Atomics/add/non-views.js12
-rw-r--r--test/built-ins/Atomics/add/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/add/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/and/bad-range.js19
-rw-r--r--test/built-ins/Atomics/and/descriptor.js12
-rw-r--r--test/built-ins/Atomics/and/good-views.js60
-rw-r--r--test/built-ins/Atomics/and/length.js29
-rw-r--r--test/built-ins/Atomics/and/name.js15
-rw-r--r--test/built-ins/Atomics/and/non-views.js12
-rw-r--r--test/built-ins/Atomics/and/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/and/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/compareExchange/bad-range.js19
-rw-r--r--test/built-ins/Atomics/compareExchange/descriptor.js12
-rw-r--r--test/built-ins/Atomics/compareExchange/good-views.js72
-rw-r--r--test/built-ins/Atomics/compareExchange/length.js29
-rw-r--r--test/built-ins/Atomics/compareExchange/name.js15
-rw-r--r--test/built-ins/Atomics/compareExchange/non-views.js12
-rw-r--r--test/built-ins/Atomics/compareExchange/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/compareExchange/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/exchange/bad-range.js19
-rw-r--r--test/built-ins/Atomics/exchange/descriptor.js12
-rw-r--r--test/built-ins/Atomics/exchange/good-views.js54
-rw-r--r--test/built-ins/Atomics/exchange/length.js29
-rw-r--r--test/built-ins/Atomics/exchange/name.js15
-rw-r--r--test/built-ins/Atomics/exchange/non-views.js12
-rw-r--r--test/built-ins/Atomics/exchange/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/exchange/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/isLockFree/corner-cases.js29
-rw-r--r--test/built-ins/Atomics/isLockFree/descriptor.js12
-rw-r--r--test/built-ins/Atomics/isLockFree/length.js29
-rw-r--r--test/built-ins/Atomics/isLockFree/name.js15
-rw-r--r--test/built-ins/Atomics/isLockFree/value.js46
-rw-r--r--test/built-ins/Atomics/load/bad-range.js19
-rw-r--r--test/built-ins/Atomics/load/descriptor.js12
-rw-r--r--test/built-ins/Atomics/load/good-views.js44
-rw-r--r--test/built-ins/Atomics/load/length.js29
-rw-r--r--test/built-ins/Atomics/load/name.js15
-rw-r--r--test/built-ins/Atomics/load/non-views.js12
-rw-r--r--test/built-ins/Atomics/load/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/load/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/or/bad-range.js19
-rw-r--r--test/built-ins/Atomics/or/descriptor.js12
-rw-r--r--test/built-ins/Atomics/or/good-views.js59
-rw-r--r--test/built-ins/Atomics/or/length.js29
-rw-r--r--test/built-ins/Atomics/or/name.js15
-rw-r--r--test/built-ins/Atomics/or/non-views.js12
-rw-r--r--test/built-ins/Atomics/or/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/or/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/prop-desc.js31
-rw-r--r--test/built-ins/Atomics/proto.js16
-rw-r--r--test/built-ins/Atomics/store/bad-range.js19
-rw-r--r--test/built-ins/Atomics/store/descriptor.js12
-rw-r--r--test/built-ins/Atomics/store/good-views.js54
-rw-r--r--test/built-ins/Atomics/store/length.js29
-rw-r--r--test/built-ins/Atomics/store/name.js15
-rw-r--r--test/built-ins/Atomics/store/non-views.js12
-rw-r--r--test/built-ins/Atomics/store/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/store/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/sub/bad-range.js19
-rw-r--r--test/built-ins/Atomics/sub/descriptor.js12
-rw-r--r--test/built-ins/Atomics/sub/good-views.js53
-rw-r--r--test/built-ins/Atomics/sub/length.js29
-rw-r--r--test/built-ins/Atomics/sub/name.js15
-rw-r--r--test/built-ins/Atomics/sub/non-views.js12
-rw-r--r--test/built-ins/Atomics/sub/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/sub/shared-nonint-views.js18
-rw-r--r--test/built-ins/Atomics/wait/bad-range.js16
-rw-r--r--test/built-ins/Atomics/wait/descriptor.js12
-rw-r--r--test/built-ins/Atomics/wait/did-timeout.js33
-rw-r--r--test/built-ins/Atomics/wait/good-views.js56
-rw-r--r--test/built-ins/Atomics/wait/length.js29
-rw-r--r--test/built-ins/Atomics/wait/name.js15
-rw-r--r--test/built-ins/Atomics/wait/nan-timeout.js31
-rw-r--r--test/built-ins/Atomics/wait/negative-timeout.js28
-rw-r--r--test/built-ins/Atomics/wait/no-spurious-wakeup.js37
-rw-r--r--test/built-ins/Atomics/wait/non-views.js12
-rw-r--r--test/built-ins/Atomics/wait/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/wait/shared-nonint-views.js20
-rw-r--r--test/built-ins/Atomics/wait/was-woken.js31
-rw-r--r--test/built-ins/Atomics/wake/bad-range.js16
-rw-r--r--test/built-ins/Atomics/wake/counts.js17
-rw-r--r--test/built-ins/Atomics/wake/descriptor.js12
-rw-r--r--test/built-ins/Atomics/wake/good-views.js27
-rw-r--r--test/built-ins/Atomics/wake/length.js29
-rw-r--r--test/built-ins/Atomics/wake/name.js15
-rw-r--r--test/built-ins/Atomics/wake/non-views.js12
-rw-r--r--test/built-ins/Atomics/wake/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/wake/shared-nonint-views.js20
-rw-r--r--test/built-ins/Atomics/wake/wake-all-on-loc.js47
-rw-r--r--test/built-ins/Atomics/wake/wake-all.js36
-rw-r--r--test/built-ins/Atomics/wake/wake-in-order.js47
-rw-r--r--test/built-ins/Atomics/wake/wake-nan.js30
-rw-r--r--test/built-ins/Atomics/wake/wake-negative.js30
-rw-r--r--test/built-ins/Atomics/wake/wake-one.js42
-rw-r--r--test/built-ins/Atomics/wake/wake-two.js36
-rw-r--r--test/built-ins/Atomics/wake/wake-zero.js30
-rw-r--r--test/built-ins/Atomics/xor/bad-range.js19
-rw-r--r--test/built-ins/Atomics/xor/descriptor.js12
-rw-r--r--test/built-ins/Atomics/xor/good-views.js60
-rw-r--r--test/built-ins/Atomics/xor/length.js29
-rw-r--r--test/built-ins/Atomics/xor/name.js15
-rw-r--r--test/built-ins/Atomics/xor/non-views.js12
-rw-r--r--test/built-ins/Atomics/xor/nonshared-int-views.js18
-rw-r--r--test/built-ins/Atomics/xor/shared-nonint-views.js18
-rw-r--r--test/built-ins/DataView/buffer-does-not-have-arraybuffer-data-throws-sab.js43
-rw-r--r--test/built-ins/DataView/buffer-reference-sab.js26
-rw-r--r--test/built-ins/DataView/byteoffset-is-negative-throws-sab.js29
-rw-r--r--test/built-ins/DataView/custom-proto-access-throws-sab.js46
-rw-r--r--test/built-ins/DataView/custom-proto-if-not-object-fallbacks-to-default-prototype-sab.js47
-rw-r--r--test/built-ins/DataView/custom-proto-if-object-is-used-sab.js48
-rw-r--r--test/built-ins/DataView/defined-bytelength-and-byteoffset-sab.js61
-rw-r--r--test/built-ins/DataView/defined-byteoffset-sab.js54
-rw-r--r--test/built-ins/DataView/defined-byteoffset-undefined-bytelength-sab.js57
-rw-r--r--test/built-ins/DataView/excessive-bytelength-throws-sab.js56
-rw-r--r--test/built-ins/DataView/excessive-byteoffset-throws-sab.js29
-rw-r--r--test/built-ins/DataView/instance-extensibility-sab.js36
-rw-r--r--test/built-ins/DataView/negative-bytelength-throws-sab.js46
-rw-r--r--test/built-ins/DataView/negative-byteoffset-throws-sab.js35
-rw-r--r--test/built-ins/DataView/newtarget-undefined-throws-sab.js28
-rw-r--r--test/built-ins/DataView/proto-from-ctor-realm-sab.js33
-rw-r--r--test/built-ins/DataView/prototype/buffer/return-buffer-sab.js22
-rw-r--r--test/built-ins/DataView/prototype/buffer/this-has-no-dataview-internal-sab.js41
-rw-r--r--test/built-ins/DataView/prototype/byteLength/return-bytelength-sab.js29
-rw-r--r--test/built-ins/DataView/prototype/byteLength/this-has-no-dataview-internal-sab.js41
-rw-r--r--test/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js31
-rw-r--r--test/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js41
-rw-r--r--test/built-ins/DataView/prototype/getInt32/index-is-out-of-range-sab.js86
-rw-r--r--test/built-ins/DataView/prototype/getInt32/negative-byteoffset-throws-sab.js34
-rw-r--r--test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-sab.js46
-rw-r--r--test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-symbol-sab.js32
-rw-r--r--test/built-ins/DataView/prototype/getInt32/return-value-clean-arraybuffer-sab.js45
-rw-r--r--test/built-ins/DataView/prototype/getInt32/return-values-custom-offset-sab.js59
-rw-r--r--test/built-ins/DataView/prototype/getInt32/return-values-sab.js67
-rw-r--r--test/built-ins/DataView/prototype/getInt32/this-has-no-dataview-internal-sab.js44
-rw-r--r--test/built-ins/DataView/prototype/getInt32/to-boolean-littleendian-sab.js52
-rw-r--r--test/built-ins/DataView/prototype/getInt32/toindex-byteoffset-sab.js65
-rw-r--r--test/built-ins/DataView/return-abrupt-tonumber-bytelength-sab.js42
-rw-r--r--test/built-ins/DataView/return-abrupt-tonumber-bytelength-symbol-sab.js27
-rw-r--r--test/built-ins/DataView/return-abrupt-tonumber-byteoffset-sab.js29
-rw-r--r--test/built-ins/DataView/return-abrupt-tonumber-byteoffset-symbol-sab.js24
-rw-r--r--test/built-ins/DataView/return-instance-sab.js31
-rw-r--r--test/built-ins/DataView/toindex-bytelength-sab.js95
-rw-r--r--test/built-ins/DataView/toindex-byteoffset-sab.js93
-rw-r--r--test/built-ins/SharedArrayBuffer/allocation-limit.js33
-rw-r--r--test/built-ins/SharedArrayBuffer/data-allocation-after-object-creation.js37
-rw-r--r--test/built-ins/SharedArrayBuffer/init-zero.js21
-rw-r--r--test/built-ins/SharedArrayBuffer/length-is-absent.js19
-rw-r--r--test/built-ins/SharedArrayBuffer/length-is-too-large-throws.js32
-rw-r--r--test/built-ins/SharedArrayBuffer/negative-length-throws.js35
-rw-r--r--test/built-ins/SharedArrayBuffer/newtarget-prototype-is-not-object.js48
-rw-r--r--test/built-ins/SharedArrayBuffer/proto-from-ctor-realm.js29
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype-from-newtarget.js34
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/Symbol.toStringTag.js21
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-accessor.js11
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-func.js14
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/byteLength/length.js17
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/name.js22
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/prop-desc.js16
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/return-bytelength.js12
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js31
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-arraybuffer.js16
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-not-object.js39
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/constructor.js15
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js17
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-object.js34
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/descriptor.js20
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-absent.js17
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-undefined.js17
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/end-exceeds-length.js25
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/extensible.js16
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/length.js29
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/name.js26
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/negative-end.js25
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/negative-start.js25
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/nonconstructor.js20
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/number-conversion.js30
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-not-object.js30
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-undefined.js16
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-constructor.js25
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-object.js31
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-is-null.js21
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-is-undefined.js21
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js23
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js24
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js24
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js24
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/species.js25
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-absent.js16
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-undefined.js16
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-end.js17
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-length.js22
-rw-r--r--test/built-ins/SharedArrayBuffer/prototype/slice/this-is-arraybuffer.js13
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-end.js19
-rwxr-xr-xtest/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-start.js19
-rw-r--r--test/built-ins/SharedArrayBuffer/return-abrupt-from-length-symbol.js22
-rw-r--r--test/built-ins/SharedArrayBuffer/return-abrupt-from-length.js25
-rw-r--r--test/built-ins/SharedArrayBuffer/toindex-length.js88
-rw-r--r--test/built-ins/SharedArrayBuffer/undefined-newtarget-throws.js24
-rw-r--r--test/built-ins/SharedArrayBuffer/zero-length.js24
-rw-r--r--test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js51
-rw-r--r--test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js107
-rw-r--r--test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js107
-rw-r--r--test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js51
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js38
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-throws-sab.js32
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-zero-sab.js23
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-byteoffset-is-symbol-throws-sab.js29
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js33
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-byteoffset-to-number-throws-sab.js33
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-custom-proto-access-throws-sab.js48
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-defined-length-and-offset-sab.js33
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-defined-length-sab.js35
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-defined-negative-length-sab.js29
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-defined-offset-sab.js33
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-excessive-length-throws-sab.js32
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-excessive-offset-throws-sab.js36
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-invoked-with-undefined-newtarget-sab.js27
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-is-referenced-sab.js33
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-length-access-throws-sab.js34
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-length-is-symbol-throws-sab.js30
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-new-instance-extensibility-sab.js38
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-proto-from-ctor-realm-sab.js39
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-returns-new-instance-sab.js34
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-toindex-bytelength-sab.js73
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-toindex-byteoffset-sab.js87
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-typedarray-backed-by-sharedarraybuffer.js23
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-use-custom-proto-if-object-sab.js50
-rw-r--r--test/built-ins/TypedArrays/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js48
-rw-r--r--test/built-ins/TypedArrays/internals/Get/indexed-value-sab.js26
237 files changed, 7059 insertions, 0 deletions
diff --git a/test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js b/test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js
new file mode 100644
index 000000000..7cbf278cc
--- /dev/null
+++ b/test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-arraybuffer.prototype.bytelength
+description: Throws a TypeError exception when `this` is a SharedArrayBuffer
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ ArrayBuffer.prototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ var sab = new SharedArrayBuffer(4);
+ getter.call(sab);
+}, "`this` cannot be a SharedArrayBuffer");
diff --git a/test/built-ins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js b/test/built-ins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js
new file mode 100644
index 000000000..3e9fe66cb
--- /dev/null
+++ b/test/built-ins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js
@@ -0,0 +1,13 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-arraybuffer.prototype.slice
+description: >
+ Throws a TypeError if `this` is a SharedArrayBuffer
+---*/
+
+assert.throws(TypeError, function() {
+ var sab = new SharedArrayBuffer(0);
+ ArrayBuffer.prototype.slice.call(sab);
+}, "`this` value cannot be a SharedArrayBuffer");
diff --git a/test/built-ins/Atomics/Symbol.toStringTag.js b/test/built-ins/Atomics/Symbol.toStringTag.js
new file mode 100644
index 000000000..647c657e7
--- /dev/null
+++ b/test/built-ins/Atomics/Symbol.toStringTag.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: >
+ `Symbol.toStringTag` property descriptor on Atomics
+info: >
+ The initial value of the @@toStringTag property is the String value
+ "Atomics".
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]:
+ false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Symbol.toStringTag]
+---*/
+
+assert.sameValue(Atomics[Symbol.toStringTag], 'Atomics');
+
+verifyNotEnumerable(Atomics, Symbol.toStringTag);
+verifyNotWritable(Atomics, Symbol.toStringTag);
+verifyConfigurable(Atomics, Symbol.toStringTag);
diff --git a/test/built-ins/Atomics/add/bad-range.js b/test/built-ins/Atomics/add/bad-range.js
new file mode 100644
index 000000000..e7b061de7
--- /dev/null
+++ b/test/built-ins/Atomics/add/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.add on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.add(view, Idx, 10));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/add/descriptor.js b/test/built-ins/Atomics/add/descriptor.js
new file mode 100644
index 000000000..822696aff
--- /dev/null
+++ b/test/built-ins/Atomics/add/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.add
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "add");
+verifyNotEnumerable(Atomics, "add");
+verifyConfigurable(Atomics, "add");
diff --git a/test/built-ins/Atomics/add/good-views.js b/test/built-ins/Atomics/add/good-views.js
new file mode 100644
index 000000000..6dda8b488
--- /dev/null
+++ b/test/built-ins/Atomics/add/good-views.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.add on arrays that allow atomic operations.
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ // Add positive number
+ view[8] = 0;
+ assert.sameValue(Atomics.add(view, 8, 10), 0);
+ assert.sameValue(view[8], 10);
+
+ // Add negative number
+ assert.sameValue(Atomics.add(view, 8, -5), 10);
+ assert.sameValue(view[8], 5);
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.add(view, 3, 0), control[0],
+ "Result is negative and subject to coercion");
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.add(view, 3, 0), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.add(view, 3, 0), control[0],
+ "Result is subject to chopping");
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.add(view, Idx, 0), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/add/length.js b/test/built-ins/Atomics/add/length.js
new file mode 100644
index 000000000..34bf294f5
--- /dev/null
+++ b/test/built-ins/Atomics/add/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.add.length is 3.
+info: >
+ Atomics.add ( ia, index, val )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.add.length, 3);
+
+verifyNotEnumerable(Atomics.add, "length");
+verifyNotWritable(Atomics.add, "length");
+verifyConfigurable(Atomics.add, "length");
diff --git a/test/built-ins/Atomics/add/name.js b/test/built-ins/Atomics/add/name.js
new file mode 100644
index 000000000..0280526c6
--- /dev/null
+++ b/test/built-ins/Atomics/add/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.add.name is "add".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.add.name, "add");
+
+verifyNotEnumerable(Atomics.add, "name");
+verifyNotWritable(Atomics.add, "name");
+verifyConfigurable(Atomics.add, "name");
diff --git a/test/built-ins/Atomics/add/non-views.js b/test/built-ins/Atomics/add/non-views.js
new file mode 100644
index 000000000..baa6ada0f
--- /dev/null
+++ b/test/built-ins/Atomics/add/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.add on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/add/nonshared-int-views.js b/test/built-ins/Atomics/add/nonshared-int-views.js
new file mode 100644
index 000000000..c385fc304
--- /dev/null
+++ b/test/built-ins/Atomics/add/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.add on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/add/shared-nonint-views.js b/test/built-ins/Atomics/add/shared-nonint-views.js
new file mode 100644
index 000000000..b643c14e1
--- /dev/null
+++ b/test/built-ins/Atomics/add/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.add on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.add(view, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/and/bad-range.js b/test/built-ins/Atomics/and/bad-range.js
new file mode 100644
index 000000000..4e3342231
--- /dev/null
+++ b/test/built-ins/Atomics/and/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.and on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.and(view, Idx, 10));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/and/descriptor.js b/test/built-ins/Atomics/and/descriptor.js
new file mode 100644
index 000000000..113970c38
--- /dev/null
+++ b/test/built-ins/Atomics/and/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.and
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "and");
+verifyNotEnumerable(Atomics, "and");
+verifyConfigurable(Atomics, "and");
diff --git a/test/built-ins/Atomics/and/good-views.js b/test/built-ins/Atomics/and/good-views.js
new file mode 100644
index 000000000..269c495ae
--- /dev/null
+++ b/test/built-ins/Atomics/and/good-views.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.and on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ view[8] = 0x33333333;
+ control[0] = 0x33333333;
+ assert.sameValue(Atomics.and(view, 8, 0x55555555), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 0x11111111;
+ assert.sameValue(view[8], control[0]);
+ assert.sameValue(Atomics.and(view, 8, 0xF0F0F0F0), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 0x10101010;
+ assert.sameValue(view[8], control[0]);
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.and(view, 3, 0), control[0],
+ "Result is negative and subject to coercion");
+ assert.sameValue(view[3], 0);
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.and(view, 3, 0), control[0],
+ "Result is subjective to chopping");
+ assert.sameValue(view[3], 0);
+
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.and(view, 3, 0), control[0],
+ "Result is subjective to chopping");
+ assert.sameValue(view[3], 0);
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.and(view, Idx, 0), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/and/length.js b/test/built-ins/Atomics/and/length.js
new file mode 100644
index 000000000..207f60566
--- /dev/null
+++ b/test/built-ins/Atomics/and/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.and.length is 3.
+info: >
+ Atomics.and ( ia, index, val )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.and.length, 3);
+
+verifyNotEnumerable(Atomics.and, "length");
+verifyNotWritable(Atomics.and, "length");
+verifyConfigurable(Atomics.and, "length");
diff --git a/test/built-ins/Atomics/and/name.js b/test/built-ins/Atomics/and/name.js
new file mode 100644
index 000000000..f9dd0ead8
--- /dev/null
+++ b/test/built-ins/Atomics/and/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.and.name is "and".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.and.name, "and");
+
+verifyNotEnumerable(Atomics.and, "name");
+verifyNotWritable(Atomics.and, "name");
+verifyConfigurable(Atomics.and, "name");
diff --git a/test/built-ins/Atomics/and/non-views.js b/test/built-ins/Atomics/and/non-views.js
new file mode 100644
index 000000000..c7e528ca8
--- /dev/null
+++ b/test/built-ins/Atomics/and/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.and on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/and/nonshared-int-views.js b/test/built-ins/Atomics/and/nonshared-int-views.js
new file mode 100644
index 000000000..5c7967c0f
--- /dev/null
+++ b/test/built-ins/Atomics/and/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.and on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/and/shared-nonint-views.js b/test/built-ins/Atomics/and/shared-nonint-views.js
new file mode 100644
index 000000000..317f20333
--- /dev/null
+++ b/test/built-ins/Atomics/and/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.and on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.and(view, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/compareExchange/bad-range.js b/test/built-ins/Atomics/compareExchange/bad-range.js
new file mode 100644
index 000000000..920e90bc3
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.compareExchange on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.compareExchange(view, Idx, 10, 0));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/compareExchange/descriptor.js b/test/built-ins/Atomics/compareExchange/descriptor.js
new file mode 100644
index 000000000..4acadc454
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.compareExchange
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "compareExchange");
+verifyNotEnumerable(Atomics, "compareExchange");
+verifyConfigurable(Atomics, "compareExchange");
diff --git a/test/built-ins/Atomics/compareExchange/good-views.js b/test/built-ins/Atomics/compareExchange/good-views.js
new file mode 100644
index 000000000..cda3c655e
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/good-views.js
@@ -0,0 +1,72 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.compareExchange on arrays that allow atomic operations.
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+var good_indices = [ (view) => 0/-1, // -0
+ (view) => '-0',
+ (view) => view.length - 1,
+ (view) => ({ valueOf: () => 0 }),
+ (view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
+ ];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ // Performs the exchange
+ view[8] = 0;
+ assert.sameValue(Atomics.compareExchange(view, 8, 0, 10), 0);
+ assert.sameValue(view[8], 10);
+
+ view[8] = 0;
+ assert.sameValue(Atomics.compareExchange(view, 8, 1, 10), 0,
+ "Does not perform the exchange");
+ assert.sameValue(view[8], 0);
+
+ view[8] = 0;
+ assert.sameValue(Atomics.compareExchange(view, 8, 0, -5), 0,
+ "Performs the exchange, coercing the value being stored");
+ control[0] = -5;
+ assert.sameValue(view[8], control[0]);
+
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.compareExchange(view, 3, -5, 0), control[0],
+ "Performs the exchange, coercing the value being tested");
+ assert.sameValue(view[3], 0);
+
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.compareExchange(view, 3, 12345, 0), control[0],
+ "Performs the exchange, chopping the value being tested");
+ assert.sameValue(view[3], 0);
+
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.compareExchange(view, 3, 123456789, 0), control[0],
+ "Performs the exchange, chopping the value being tested");
+ assert.sameValue(view[3], 0);
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.compareExchange(view, Idx, 37, 0), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/compareExchange/length.js b/test/built-ins/Atomics/compareExchange/length.js
new file mode 100644
index 000000000..fdb318f7f
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.compareExchange.length is 4.
+info: >
+ Atomics.compareExchange ( ia, index, expect, replace )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.compareExchange.length, 4);
+
+verifyNotEnumerable(Atomics.compareExchange, "length");
+verifyNotWritable(Atomics.compareExchange, "length");
+verifyConfigurable(Atomics.compareExchange, "length");
diff --git a/test/built-ins/Atomics/compareExchange/name.js b/test/built-ins/Atomics/compareExchange/name.js
new file mode 100644
index 000000000..f179b8c49
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.compareExchange.name is "compareExchange".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.compareExchange.name, "compareExchange");
+
+verifyNotEnumerable(Atomics.compareExchange, "name");
+verifyNotWritable(Atomics.compareExchange, "name");
+verifyConfigurable(Atomics.compareExchange, "name");
diff --git a/test/built-ins/Atomics/compareExchange/non-views.js b/test/built-ins/Atomics/compareExchange/non-views.js
new file mode 100644
index 000000000..c0e6475df
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.compareExchange on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/compareExchange/nonshared-int-views.js b/test/built-ins/Atomics/compareExchange/nonshared-int-views.js
new file mode 100644
index 000000000..94d18b666
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.compareExchange on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/compareExchange/shared-nonint-views.js b/test/built-ins/Atomics/compareExchange/shared-nonint-views.js
new file mode 100644
index 000000000..78e12e34d
--- /dev/null
+++ b/test/built-ins/Atomics/compareExchange/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.compareExchange on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.compareExchange(view, 0, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/exchange/bad-range.js b/test/built-ins/Atomics/exchange/bad-range.js
new file mode 100644
index 000000000..c8be9be25
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.exchange on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.exchange(view, Idx, 10, 0));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/exchange/descriptor.js b/test/built-ins/Atomics/exchange/descriptor.js
new file mode 100644
index 000000000..395712cf0
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.exchange
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "exchange");
+verifyNotEnumerable(Atomics, "exchange");
+verifyConfigurable(Atomics, "exchange");
diff --git a/test/built-ins/Atomics/exchange/good-views.js b/test/built-ins/Atomics/exchange/good-views.js
new file mode 100644
index 000000000..2961133d8
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/good-views.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.exchange on arrays that allow atomic operations.
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ view[8] = 0;
+ assert.sameValue(Atomics.exchange(view, 8, 10), 0,
+ "Exchange returns the value previously in the array");
+ assert.sameValue(view[8], 10);
+
+ assert.sameValue(Atomics.exchange(view, 8, -5), 10,
+ "Exchange returns the value previously in the array");
+ control[0] = -5;
+ assert.sameValue(view[8], control[0]);
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
+ "Result is subject to coercion");
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.exchange(view, 3, 0), control[0],
+ "Result is subject to chopping");
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.exchange(view, Idx, 0), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/exchange/length.js b/test/built-ins/Atomics/exchange/length.js
new file mode 100644
index 000000000..92b424ad6
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.exchange.length is 3.
+info: >
+ Atomics.exchange ( ia, index, val )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.exchange.length, 3);
+
+verifyNotEnumerable(Atomics.exchange, "length");
+verifyNotWritable(Atomics.exchange, "length");
+verifyConfigurable(Atomics.exchange, "length");
diff --git a/test/built-ins/Atomics/exchange/name.js b/test/built-ins/Atomics/exchange/name.js
new file mode 100644
index 000000000..f1b291616
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.exchange.name is "exchange".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.exchange.name, "exchange");
+
+verifyNotEnumerable(Atomics.exchange, "name");
+verifyNotWritable(Atomics.exchange, "name");
+verifyConfigurable(Atomics.exchange, "name");
diff --git a/test/built-ins/Atomics/exchange/non-views.js b/test/built-ins/Atomics/exchange/non-views.js
new file mode 100644
index 000000000..570102625
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.exchange on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/exchange/nonshared-int-views.js b/test/built-ins/Atomics/exchange/nonshared-int-views.js
new file mode 100644
index 000000000..fa07e5fea
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.exchange on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/exchange/shared-nonint-views.js b/test/built-ins/Atomics/exchange/shared-nonint-views.js
new file mode 100644
index 000000000..68f70e204
--- /dev/null
+++ b/test/built-ins/Atomics/exchange/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.exchange on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.exchange(view, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/isLockFree/corner-cases.js b/test/built-ins/Atomics/isLockFree/corner-cases.js
new file mode 100644
index 000000000..283338ba5
--- /dev/null
+++ b/test/built-ins/Atomics/isLockFree/corner-cases.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test isLockFree on various non-intuitive arguments
+---*/
+
+assert.sameValue(false, Atomics.isLockFree(hide(3, Number.NaN)));
+assert.sameValue(false, Atomics.isLockFree(hide(3, -1)));
+assert.sameValue(false, Atomics.isLockFree(hide(3, 3.14)));
+assert.sameValue(false, Atomics.isLockFree(hide(3, 0)));
+
+assert.sameValue(Atomics.isLockFree('1'), Atomics.isLockFree(1));
+assert.sameValue(Atomics.isLockFree('3'), Atomics.isLockFree(3));
+
+assert.sameValue(Atomics.isLockFree(true), Atomics.isLockFree(1));
+
+assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({valueOf: () => 1}));
+assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({valueOf: () => 3}));
+assert.sameValue(Atomics.isLockFree(1), Atomics.isLockFree({toString: () => '1'}));
+assert.sameValue(Atomics.isLockFree(3), Atomics.isLockFree({toString: () => '3'}));
+
+function hide(k, x) {
+ if (k)
+ return hide(k-3, x) + x;
+ return 0;
+}
+
diff --git a/test/built-ins/Atomics/isLockFree/descriptor.js b/test/built-ins/Atomics/isLockFree/descriptor.js
new file mode 100644
index 000000000..822696aff
--- /dev/null
+++ b/test/built-ins/Atomics/isLockFree/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.add
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "add");
+verifyNotEnumerable(Atomics, "add");
+verifyConfigurable(Atomics, "add");
diff --git a/test/built-ins/Atomics/isLockFree/length.js b/test/built-ins/Atomics/isLockFree/length.js
new file mode 100644
index 000000000..4dc1e6de6
--- /dev/null
+++ b/test/built-ins/Atomics/isLockFree/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.isLockFree.length is 1.
+info: >
+ Atomics.isLockFree ( x )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.isLockFree.length, 1);
+
+verifyNotEnumerable(Atomics.isLockFree, "length");
+verifyNotWritable(Atomics.isLockFree, "length");
+verifyConfigurable(Atomics.isLockFree, "length");
diff --git a/test/built-ins/Atomics/isLockFree/name.js b/test/built-ins/Atomics/isLockFree/name.js
new file mode 100644
index 000000000..e7926b450
--- /dev/null
+++ b/test/built-ins/Atomics/isLockFree/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.isLockFree.name is "isLockFree".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.isLockFree.name, "isLockFree");
+
+verifyNotEnumerable(Atomics.isLockFree, "name");
+verifyNotWritable(Atomics.isLockFree, "name");
+verifyConfigurable(Atomics.isLockFree, "name");
diff --git a/test/built-ins/Atomics/isLockFree/value.js b/test/built-ins/Atomics/isLockFree/value.js
new file mode 100644
index 000000000..93b6bee2b
--- /dev/null
+++ b/test/built-ins/Atomics/isLockFree/value.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test isLockFree on nonnegative integer arguments
+---*/
+
+var sizes = [ 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12];
+var answers = [ {}, {}, false, true, false, false, false, false,
+ false, false, false, false];
+
+function testIsLockFree() {
+ var saved = {};
+
+ // This should defeat most optimizations.
+
+ for ( var i=0 ; i < sizes.length ; i++ ) {
+ var v = Atomics.isLockFree(sizes[i]);
+ var a = answers[i];
+ assert.sameValue(typeof v, 'boolean');
+ if (typeof a == 'boolean')
+ assert.sameValue(v, a);
+ else
+ saved[sizes[i]] = v;
+ }
+
+ // This ought to be optimizable. Make sure the answers are the same
+ // as for the unoptimized case.
+
+ assert.sameValue(Atomics.isLockFree(1), saved[1]);
+ assert.sameValue(Atomics.isLockFree(2), saved[2]);
+ assert.sameValue(Atomics.isLockFree(3), false);
+ assert.sameValue(Atomics.isLockFree(4), true);
+ assert.sameValue(Atomics.isLockFree(5), false);
+ assert.sameValue(Atomics.isLockFree(6), false);
+ assert.sameValue(Atomics.isLockFree(7), false);
+ assert.sameValue(Atomics.isLockFree(8), false);
+ assert.sameValue(Atomics.isLockFree(9), false);
+ assert.sameValue(Atomics.isLockFree(10), false);
+ assert.sameValue(Atomics.isLockFree(11), false);
+ assert.sameValue(Atomics.isLockFree(12), false);
+}
+
+testIsLockFree();
diff --git a/test/built-ins/Atomics/load/bad-range.js b/test/built-ins/Atomics/load/bad-range.js
new file mode 100644
index 000000000..9f5071780
--- /dev/null
+++ b/test/built-ins/Atomics/load/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.load on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.load(view, Idx));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/load/descriptor.js b/test/built-ins/Atomics/load/descriptor.js
new file mode 100644
index 000000000..033a2e893
--- /dev/null
+++ b/test/built-ins/Atomics/load/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.load
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "load");
+verifyNotEnumerable(Atomics, "load");
+verifyConfigurable(Atomics, "load");
diff --git a/test/built-ins/Atomics/load/good-views.js b/test/built-ins/Atomics/load/good-views.js
new file mode 100644
index 000000000..cc8e0a15a
--- /dev/null
+++ b/test/built-ins/Atomics/load/good-views.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.load on arrays that allow atomic operations.
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.load(view, 3), control[0],
+ "Result is subject to coercion");
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.load(view, 3), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.load(view, 3), control[0],
+ "Result is subject to chopping");
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.load(view, Idx), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/load/length.js b/test/built-ins/Atomics/load/length.js
new file mode 100644
index 000000000..f85c87818
--- /dev/null
+++ b/test/built-ins/Atomics/load/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.load.length is 2.
+info: >
+ Atomics.load ( ia, index )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.load.length, 2);
+
+verifyNotEnumerable(Atomics.load, "length");
+verifyNotWritable(Atomics.load, "length");
+verifyConfigurable(Atomics.load, "length");
diff --git a/test/built-ins/Atomics/load/name.js b/test/built-ins/Atomics/load/name.js
new file mode 100644
index 000000000..ab212ff12
--- /dev/null
+++ b/test/built-ins/Atomics/load/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.load.name is "load".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.load.name, "load");
+
+verifyNotEnumerable(Atomics.load, "name");
+verifyNotWritable(Atomics.load, "name");
+verifyConfigurable(Atomics.load, "name");
diff --git a/test/built-ins/Atomics/load/non-views.js b/test/built-ins/Atomics/load/non-views.js
new file mode 100644
index 000000000..96dcb1562
--- /dev/null
+++ b/test/built-ins/Atomics/load/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.load on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.load(view, 0)));
+});
diff --git a/test/built-ins/Atomics/load/nonshared-int-views.js b/test/built-ins/Atomics/load/nonshared-int-views.js
new file mode 100644
index 000000000..1d722c414
--- /dev/null
+++ b/test/built-ins/Atomics/load/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.load on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.load(view, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/load/shared-nonint-views.js b/test/built-ins/Atomics/load/shared-nonint-views.js
new file mode 100644
index 000000000..4384170dd
--- /dev/null
+++ b/test/built-ins/Atomics/load/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.load on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.load(view, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/or/bad-range.js b/test/built-ins/Atomics/or/bad-range.js
new file mode 100644
index 000000000..f4b1feb5a
--- /dev/null
+++ b/test/built-ins/Atomics/or/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.or on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.or(view, Idx, 10));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/or/descriptor.js b/test/built-ins/Atomics/or/descriptor.js
new file mode 100644
index 000000000..9e8db569f
--- /dev/null
+++ b/test/built-ins/Atomics/or/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.or
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "or");
+verifyNotEnumerable(Atomics, "or");
+verifyConfigurable(Atomics, "or");
diff --git a/test/built-ins/Atomics/or/good-views.js b/test/built-ins/Atomics/or/good-views.js
new file mode 100644
index 000000000..9e5da28ec
--- /dev/null
+++ b/test/built-ins/Atomics/or/good-views.js
@@ -0,0 +1,59 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.or on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ view[8] = 0x33333333;
+ control[0] = 0x33333333;
+ assert.sameValue(Atomics.or(view, 8, 0x55555555), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 0x77777777;
+ assert.sameValue(view[8], control[0]);
+ assert.sameValue(Atomics.or(view, 8, 0xF0F0F0F0), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 0xF7F7F7F7;
+ assert.sameValue(view[8], control[0]);
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.or(view, 3, 0), control[0],
+ "Result is negative and subject to coercion");
+ assert.sameValue(view[3], control[0]);
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.or(view, 3, 0), control[0],
+ "Result is subject to chopping");
+ assert.sameValue(view[3], control[0]);
+
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.or(view, 3, 0), control[0],
+ "Result is subject to chopping");
+ assert.sameValue(view[3], control[0]);
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.or(view, Idx, 0), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/or/length.js b/test/built-ins/Atomics/or/length.js
new file mode 100644
index 000000000..4dce3049c
--- /dev/null
+++ b/test/built-ins/Atomics/or/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.or.length is 3.
+info: >
+ Atomics.or ( ia, index, val )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.or.length, 3);
+
+verifyNotEnumerable(Atomics.or, "length");
+verifyNotWritable(Atomics.or, "length");
+verifyConfigurable(Atomics.or, "length");
diff --git a/test/built-ins/Atomics/or/name.js b/test/built-ins/Atomics/or/name.js
new file mode 100644
index 000000000..588177705
--- /dev/null
+++ b/test/built-ins/Atomics/or/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.or.name is "or".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.or.name, "or");
+
+verifyNotEnumerable(Atomics.or, "name");
+verifyNotWritable(Atomics.or, "name");
+verifyConfigurable(Atomics.or, "name");
diff --git a/test/built-ins/Atomics/or/non-views.js b/test/built-ins/Atomics/or/non-views.js
new file mode 100644
index 000000000..ad0b82042
--- /dev/null
+++ b/test/built-ins/Atomics/or/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.or on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/or/nonshared-int-views.js b/test/built-ins/Atomics/or/nonshared-int-views.js
new file mode 100644
index 000000000..ae11cf4aa
--- /dev/null
+++ b/test/built-ins/Atomics/or/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.or on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/or/shared-nonint-views.js b/test/built-ins/Atomics/or/shared-nonint-views.js
new file mode 100644
index 000000000..2b7fdb1b0
--- /dev/null
+++ b/test/built-ins/Atomics/or/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.or on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.or(view, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/prop-desc.js b/test/built-ins/Atomics/prop-desc.js
new file mode 100644
index 000000000..220433d02
--- /dev/null
+++ b/test/built-ins/Atomics/prop-desc.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.
+
+/*---
+description: >
+ Property descriptor of Atomics
+info: |
+ The Atomics Object
+
+ [...]
+ The Atomics object is not a function object. It does not have a [[Construct]]
+ internal method; it is not possible to use the Atomics object as a constructor
+ with the new operator. The Atomics object also does not have a [[Call]] internal
+ method; it is not possible to invoke the Atomics object as a function.
+
+ 17 ECMAScript Standard Built-in Objects:
+
+ Every other data property described in clauses 18 through 26 and in Annex B.2
+ has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(typeof Atomics, "object", "no [[Call]]");
+assert.throws(TypeError, function() {
+ new Atomics();
+}, "no [[Construct]]");
+
+verifyNotEnumerable(this, "Atomics");
+verifyWritable(this, "Atomics");
+verifyConfigurable(this, "Atomics");
diff --git a/test/built-ins/Atomics/proto.js b/test/built-ins/Atomics/proto.js
new file mode 100644
index 000000000..47e96ec28
--- /dev/null
+++ b/test/built-ins/Atomics/proto.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2016 The V8 Project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The prototype of Atomics is Object.prototype
+info: |
+ The Atomics Object
+
+ The value of the [[Prototype]] internal slot of the Atomics object is the
+ intrinsic object %ObjectPrototype%.
+---*/
+
+var proto = Object.getPrototypeOf(Atomics);
+
+assert.sameValue(proto, Object.prototype);
diff --git a/test/built-ins/Atomics/store/bad-range.js b/test/built-ins/Atomics/store/bad-range.js
new file mode 100644
index 000000000..90cd3d2cd
--- /dev/null
+++ b/test/built-ins/Atomics/store/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.store on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.store(view, Idx, 10));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/store/descriptor.js b/test/built-ins/Atomics/store/descriptor.js
new file mode 100644
index 000000000..df883fa8c
--- /dev/null
+++ b/test/built-ins/Atomics/store/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.store
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "store");
+verifyNotEnumerable(Atomics, "store");
+verifyConfigurable(Atomics, "store");
diff --git a/test/built-ins/Atomics/store/good-views.js b/test/built-ins/Atomics/store/good-views.js
new file mode 100644
index 000000000..511493e17
--- /dev/null
+++ b/test/built-ins/Atomics/store/good-views.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.store on arrays that allow atomic operations.
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ for ( let val of [10,
+ -5,
+ 12345,
+ 123456789,
+ Math.PI,
+ "33",
+ { valueOf: () => 33 },
+ undefined] )
+ {
+ assert.sameValue(Atomics.store(view, 3, val), ToInteger(val),
+ "Atomics.store returns its third argument (" + val + ") converted to Integer, not the input value nor the value that was stored");
+
+ control[0] = val;
+ assert.sameValue(view[3], control[0]);
+ }
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.load(view, Idx), 37);
+ });
+}, int_views);
+
+function ToInteger(v) {
+ v = +v;
+ if (isNaN(v))
+ return 0;
+ if (v == 0 || !isFinite(v))
+ return v;
+ if (v < 0)
+ return -Math.floor(Math.abs(v));
+ return Math.floor(v);
+}
diff --git a/test/built-ins/Atomics/store/length.js b/test/built-ins/Atomics/store/length.js
new file mode 100644
index 000000000..871ef0a2b
--- /dev/null
+++ b/test/built-ins/Atomics/store/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.store.length is 3.
+info: >
+ Atomics.store ( ia, index, val )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.store.length, 3);
+
+verifyNotEnumerable(Atomics.store, "length");
+verifyNotWritable(Atomics.store, "length");
+verifyConfigurable(Atomics.store, "length");
diff --git a/test/built-ins/Atomics/store/name.js b/test/built-ins/Atomics/store/name.js
new file mode 100644
index 000000000..442ecc58a
--- /dev/null
+++ b/test/built-ins/Atomics/store/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.store.name is "store".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.store.name, "store");
+
+verifyNotEnumerable(Atomics.store, "name");
+verifyNotWritable(Atomics.store, "name");
+verifyConfigurable(Atomics.store, "name");
diff --git a/test/built-ins/Atomics/store/non-views.js b/test/built-ins/Atomics/store/non-views.js
new file mode 100644
index 000000000..ec1fd7b39
--- /dev/null
+++ b/test/built-ins/Atomics/store/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.store on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/store/nonshared-int-views.js b/test/built-ins/Atomics/store/nonshared-int-views.js
new file mode 100644
index 000000000..a71b57dde
--- /dev/null
+++ b/test/built-ins/Atomics/store/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.store on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/store/shared-nonint-views.js b/test/built-ins/Atomics/store/shared-nonint-views.js
new file mode 100644
index 000000000..81a4c7ae4
--- /dev/null
+++ b/test/built-ins/Atomics/store/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.store on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.store(view, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/sub/bad-range.js b/test/built-ins/Atomics/sub/bad-range.js
new file mode 100644
index 000000000..902bb2174
--- /dev/null
+++ b/test/built-ins/Atomics/sub/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.sub on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.sub(view, Idx, 10));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/sub/descriptor.js b/test/built-ins/Atomics/sub/descriptor.js
new file mode 100644
index 000000000..e9ca6f927
--- /dev/null
+++ b/test/built-ins/Atomics/sub/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.sub
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "sub");
+verifyNotEnumerable(Atomics, "sub");
+verifyConfigurable(Atomics, "sub");
diff --git a/test/built-ins/Atomics/sub/good-views.js b/test/built-ins/Atomics/sub/good-views.js
new file mode 100644
index 000000000..cdbe4b22c
--- /dev/null
+++ b/test/built-ins/Atomics/sub/good-views.js
@@ -0,0 +1,53 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.sub on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ view[8] = 100;
+ assert.sameValue(Atomics.sub(view, 8, 10), 100,
+ "Subtract positive number");
+ assert.sameValue(view[8], 90);
+
+ assert.sameValue(Atomics.sub(view, 8, -5), 90,
+ "Subtract negative number, though result remains positive");
+ assert.sameValue(view[8], 95);
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.sub(view, 3, 0), control[0],
+ "Result is negative and subject to coercion");
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.sub(view, 3, 0), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.sub(view, 3, 0), control[0],
+ "Result is subject to chopping");
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.sub(view, Idx, 0), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/sub/length.js b/test/built-ins/Atomics/sub/length.js
new file mode 100644
index 000000000..12e070c13
--- /dev/null
+++ b/test/built-ins/Atomics/sub/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.sub.length is 3.
+info: >
+ Atomics.sub ( ia, index, val )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.sub.length, 3);
+
+verifyNotEnumerable(Atomics.sub, "length");
+verifyNotWritable(Atomics.sub, "length");
+verifyConfigurable(Atomics.sub, "length");
diff --git a/test/built-ins/Atomics/sub/name.js b/test/built-ins/Atomics/sub/name.js
new file mode 100644
index 000000000..665a6e0ae
--- /dev/null
+++ b/test/built-ins/Atomics/sub/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.sub.name is "sub".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.sub.name, "sub");
+
+verifyNotEnumerable(Atomics.sub, "name");
+verifyNotWritable(Atomics.sub, "name");
+verifyConfigurable(Atomics.sub, "name");
diff --git a/test/built-ins/Atomics/sub/non-views.js b/test/built-ins/Atomics/sub/non-views.js
new file mode 100644
index 000000000..700074f9c
--- /dev/null
+++ b/test/built-ins/Atomics/sub/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.sub on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/sub/nonshared-int-views.js b/test/built-ins/Atomics/sub/nonshared-int-views.js
new file mode 100644
index 000000000..f73d0469d
--- /dev/null
+++ b/test/built-ins/Atomics/sub/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.sub on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/sub/shared-nonint-views.js b/test/built-ins/Atomics/sub/shared-nonint-views.js
new file mode 100644
index 000000000..da38d5bfd
--- /dev/null
+++ b/test/built-ins/Atomics/sub/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.sub on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.sub(view, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/wait/bad-range.js b/test/built-ins/Atomics/wait/bad-range.js
new file mode 100644
index 000000000..cd75b2836
--- /dev/null
+++ b/test/built-ins/Atomics/wait/bad-range.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.wait on arrays that allow atomic operations
+includes: [testAtomics.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var view = new Int32Array(sab);
+
+testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.wait(view, Idx, 10, 0)); // Even with zero timeout
+});
diff --git a/test/built-ins/Atomics/wait/descriptor.js b/test/built-ins/Atomics/wait/descriptor.js
new file mode 100644
index 000000000..c01712cbe
--- /dev/null
+++ b/test/built-ins/Atomics/wait/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.wait
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "wait");
+verifyNotEnumerable(Atomics, "wait");
+verifyConfigurable(Atomics, "wait");
diff --git a/test/built-ins/Atomics/wait/did-timeout.js b/test/built-ins/Atomics/wait/did-timeout.js
new file mode 100644
index 000000000..b642ee8e1
--- /dev/null
+++ b/test/built-ins/Atomics/wait/did-timeout.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wait returns the right result when it timed out and that
+ the time to time out is reasonable.
+includes: [atomicsHelper.js]
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab, id) {
+ var ia = new Int32Array(sab);
+ var then = Date.now();
+ $.agent.report(Atomics.wait(ia, 0, 0, 500)); // Timeout 500ms
+ $.agent.report(Date.now() - then);
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+assert.sameValue(getReport(), "timed-out");
+assert.sameValue(Math.abs((getReport()|0) - 500) < $ATOMICS_MAX_TIME_EPSILON, true);
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wait/good-views.js b/test/built-ins/Atomics/wait/good-views.js
new file mode 100644
index 000000000..9776b67b8
--- /dev/null
+++ b/test/built-ins/Atomics/wait/good-views.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wait on arrays that allow atomic operations,
+ in an Agent that is allowed to wait.
+---*/
+
+// Let's assume 'wait' is not allowed on the main thread,
+// even in the shell.
+
+$.agent.start(
+`
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+
+var good_indices = [ (view) => 0/-1, // -0
+ (view) => '-0',
+ (view) => view.length - 1,
+ (view) => ({ valueOf: () => 0 }),
+ (view) => ({ toString: () => '0', valueOf: false }) // non-callable valueOf triggers invocation of toString
+ ];
+
+var view = new Int32Array(sab, 32, 20);
+
+view[0] = 0;
+$.agent.report("A " + Atomics.wait(view, 0, 0, 0))
+$.agent.report("B " + Atomics.wait(view, 0, 37, 0));
+
+// In-bounds boundary cases for indexing
+for ( let IdxGen of good_indices ) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ $.agent.report("C " + Atomics.wait(view, Idx, 0));
+}
+
+$.agent.report("done");
+$.agent.leaving();
+`)
+
+assert.sameValue(getReport(), "A timed-out");
+assert.sameValue(getReport(), "B not-equal"); // Even with zero timeout
+var r;
+while ((r = getReport()) != "done")
+ assert.sameValue(r, "C not-equal");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wait/length.js b/test/built-ins/Atomics/wait/length.js
new file mode 100644
index 000000000..00a26d53d
--- /dev/null
+++ b/test/built-ins/Atomics/wait/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.wait.length is 4.
+info: >
+ Atomics.wait ( ia, index, expect, timeout )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.wait.length, 4);
+
+verifyNotEnumerable(Atomics.wait, "length");
+verifyNotWritable(Atomics.wait, "length");
+verifyConfigurable(Atomics.wait, "length");
diff --git a/test/built-ins/Atomics/wait/name.js b/test/built-ins/Atomics/wait/name.js
new file mode 100644
index 000000000..0fd9d30c9
--- /dev/null
+++ b/test/built-ins/Atomics/wait/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.wait.name is "wait".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.wait.name, "wait");
+
+verifyNotEnumerable(Atomics.wait, "name");
+verifyNotWritable(Atomics.wait, "name");
+verifyConfigurable(Atomics.wait, "name");
diff --git a/test/built-ins/Atomics/wait/nan-timeout.js b/test/built-ins/Atomics/wait/nan-timeout.js
new file mode 100644
index 000000000..1e3f6e4aa
--- /dev/null
+++ b/test/built-ins/Atomics/wait/nan-timeout.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wait does not time out with a NaN timeout
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab, id) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, NaN)); // NaN => Infinity
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Ample time
+assert.sameValue($.agent.getReport(), null);
+Atomics.wake(ia, 0);
+assert.sameValue(getReport(), "ok");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wait/negative-timeout.js b/test/built-ins/Atomics/wait/negative-timeout.js
new file mode 100644
index 000000000..521c22440
--- /dev/null
+++ b/test/built-ins/Atomics/wait/negative-timeout.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wait times out with a negative timeout
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab, id) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, -5)); // -5 => 0
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+assert.sameValue(getReport(), "timed-out");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wait/no-spurious-wakeup.js b/test/built-ins/Atomics/wait/no-spurious-wakeup.js
new file mode 100644
index 000000000..a8cd0cb2e
--- /dev/null
+++ b/test/built-ins/Atomics/wait/no-spurious-wakeup.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wait actually waits and does not spuriously wake
+ up when the memory value is changed.
+includes: [atomicsHelper.js]
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab, id) {
+ var ia = new Int32Array(sab);
+ var then = Date.now();
+ Atomics.wait(ia, 0, 0);
+ var diff = Date.now() - then; // Should be about 1000 ms
+ $.agent.report(diff);
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agent a chance to wait
+Atomics.store(ia, 0, 1); // Change the value, should not wake the agent
+$.agent.sleep(500); // Wait some more so that we can tell
+Atomics.wake(ia, 0); // Really wake it up
+assert.sameValue(Math.abs((getReport()|0) - 1000) < $ATOMICS_MAX_TIME_EPSILON, true);
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wait/non-views.js b/test/built-ins/Atomics/wait/non-views.js
new file mode 100644
index 000000000..22504528a
--- /dev/null
+++ b/test/built-ins/Atomics/wait/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wait on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0))); // Even with zero timeout
+});
diff --git a/test/built-ins/Atomics/wait/nonshared-int-views.js b/test/built-ins/Atomics/wait/nonshared-int-views.js
new file mode 100644
index 000000000..e058d9efc
--- /dev/null
+++ b/test/built-ins/Atomics/wait/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wait on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0))); // Should fail even if waiting 0ms
+}, int_views);
diff --git a/test/built-ins/Atomics/wait/shared-nonint-views.js b/test/built-ins/Atomics/wait/shared-nonint-views.js
new file mode 100644
index 000000000..bfc9b34a0
--- /dev/null
+++ b/test/built-ins/Atomics/wait/shared-nonint-views.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wait on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
+ Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ // Even with timout zero this should fail
+ assert.throws(TypeError, (() => Atomics.wait(view, 0, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/Atomics/wait/was-woken.js b/test/built-ins/Atomics/wait/was-woken.js
new file mode 100644
index 000000000..b424aec5a
--- /dev/null
+++ b/test/built-ins/Atomics/wait/was-woken.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wait returns the right result when it was awoken.
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab, id) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0)); // No timeout => Infinity
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agent a chance to wait
+Atomics.wake(ia, 0);
+assert.sameValue(getReport(), "ok");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
+
diff --git a/test/built-ins/Atomics/wake/bad-range.js b/test/built-ins/Atomics/wake/bad-range.js
new file mode 100644
index 000000000..a8085f29e
--- /dev/null
+++ b/test/built-ins/Atomics/wake/bad-range.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.wake on arrays that allow atomic operations
+includes: [testAtomics.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var view = new Int32Array(sab);
+
+testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.wake(view, Idx, 0)); // Even with waking zero
+});
diff --git a/test/built-ins/Atomics/wake/counts.js b/test/built-ins/Atomics/wake/counts.js
new file mode 100644
index 000000000..732fa92d9
--- /dev/null
+++ b/test/built-ins/Atomics/wake/counts.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Allowed boundary cases of the third 'count' argument to Atomics.wake
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var view = new Int32Array(sab);
+
+assert.sameValue(Atomics.wake(view, 0, -3), 0);
+assert.sameValue(Atomics.wake(view, 0, Number.POSITIVE_INFINITY), 0);
+assert.sameValue(Atomics.wake(view, 0, undefined), 0);
+assert.sameValue(Atomics.wake(view, 0, "33"), 0);
+assert.sameValue(Atomics.wake(view, 0, { valueOf: 8 }), 0);
+assert.sameValue(Atomics.wake(view, 0), 0);
diff --git a/test/built-ins/Atomics/wake/descriptor.js b/test/built-ins/Atomics/wake/descriptor.js
new file mode 100644
index 000000000..006433b09
--- /dev/null
+++ b/test/built-ins/Atomics/wake/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.wake
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "wake");
+verifyNotEnumerable(Atomics, "wake");
+verifyConfigurable(Atomics, "wake");
diff --git a/test/built-ins/Atomics/wake/good-views.js b/test/built-ins/Atomics/wake/good-views.js
new file mode 100644
index 000000000..cb051c4ee
--- /dev/null
+++ b/test/built-ins/Atomics/wake/good-views.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wait on arrays that allow atomic operations,
+ in an Agent that is allowed to wait. There is only the one Agent.
+includes: [testAtomics.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+var int_views = [Int32Array];
+var view = new Int32Array(sab, 32, 20);
+
+view[0] = 0;
+assert.sameValue(Atomics.wake(view, 0, 1), 0);
+
+// In-bounds boundary cases for indexing
+testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.wake(view, Idx, 1), 0);
+});
diff --git a/test/built-ins/Atomics/wake/length.js b/test/built-ins/Atomics/wake/length.js
new file mode 100644
index 000000000..9706bec1a
--- /dev/null
+++ b/test/built-ins/Atomics/wake/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.wake.length is 3.
+info: >
+ Atomics.wake ( ia, index, count )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.wake.length, 3);
+
+verifyNotEnumerable(Atomics.wake, "length");
+verifyNotWritable(Atomics.wake, "length");
+verifyConfigurable(Atomics.wake, "length");
diff --git a/test/built-ins/Atomics/wake/name.js b/test/built-ins/Atomics/wake/name.js
new file mode 100644
index 000000000..8a875a5fa
--- /dev/null
+++ b/test/built-ins/Atomics/wake/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.wake.name is "wake".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.wake.name, "wake");
+
+verifyNotEnumerable(Atomics.wake, "name");
+verifyNotWritable(Atomics.wake, "name");
+verifyConfigurable(Atomics.wake, "name");
diff --git a/test/built-ins/Atomics/wake/non-views.js b/test/built-ins/Atomics/wake/non-views.js
new file mode 100644
index 000000000..be17dda26
--- /dev/null
+++ b/test/built-ins/Atomics/wake/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wake on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Even with count == 0
+});
diff --git a/test/built-ins/Atomics/wake/nonshared-int-views.js b/test/built-ins/Atomics/wake/nonshared-int-views.js
new file mode 100644
index 000000000..51fea5db4
--- /dev/null
+++ b/test/built-ins/Atomics/wake/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wake on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Should fail even if waking zero waiters
+}, int_views);
diff --git a/test/built-ins/Atomics/wake/shared-nonint-views.js b/test/built-ins/Atomics/wake/shared-nonint-views.js
new file mode 100644
index 000000000..02b2074c5
--- /dev/null
+++ b/test/built-ins/Atomics/wake/shared-nonint-views.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.wake on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array,
+ Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ // Even with timout zero this should fail
+ assert.throws(TypeError, (() => Atomics.wake(view, 0, 0))); // Even with 0 to wake this should fail
+}, other_views);
diff --git a/test/built-ins/Atomics/wake/wake-all-on-loc.js b/test/built-ins/Atomics/wake/wake-all-on-loc.js
new file mode 100644
index 000000000..e403df152
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-all-on-loc.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes all waiters on a location, but does not
+ wake waiters on other locations.
+---*/
+
+for ( var i=0 ; i < 3 ; i++ ) {
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report("A " + Atomics.wait(ia, 0, 0));
+ $.agent.leaving();
+})
+`);
+}
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report("B " + Atomics.wait(ia, 1, 0, 1000)); // We will timeout eventually
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(2*Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agents a chance to wait
+assert.sameValue(Atomics.wake(ia, 0), 3); // Wake all on location 0
+var rs = [getReport(), getReport(), getReport(), getReport()];
+// Do not sort the array -- B should timeout much after the others are woken
+assert.sameValue(rs[0], "A ok");
+assert.sameValue(rs[1], "A ok");
+assert.sameValue(rs[2], "A ok");
+assert.sameValue(rs[3], "B timed-out");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wake/wake-all.js b/test/built-ins/Atomics/wake/wake-all.js
new file mode 100644
index 000000000..d08d49be0
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-all.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes all waiters if that's what the count is.
+---*/
+
+for ( var i=0 ; i < 3 ; i++ ) {
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We may timeout eventually
+ $.agent.leaving();
+})
+`);
+}
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agents a chance to wait
+assert.sameValue(Atomics.wake(ia, 0), 3); // Wake all
+var rs = [getReport(), getReport(), getReport()];
+rs.sort();
+assert.sameValue(rs[0], "ok");
+assert.sameValue(rs[1], "ok");
+assert.sameValue(rs[2], "ok");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wake/wake-in-order.js b/test/built-ins/Atomics/wake/wake-in-order.js
new file mode 100644
index 000000000..92025633f
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-in-order.js
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes agents in the order they are waiting.
+---*/
+
+// Create workers and start them all spinning. We set atomic slots to make
+// them go into a wait, thus controlling the waiting order. Then we wake them
+// one by one and observe the wakeup order.
+
+for ( var i=0 ; i < 3 ; i++ ) {
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ while (Atomics.load(ia, ${i+1}) == 0);
+ $.agent.report(${i} + Atomics.wait(ia, 0, 0));
+ $.agent.leaving();
+})
+`);
+}
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT*4));
+$.agent.broadcast(ia.buffer);
+
+// Make them sleep in order 0 1 2 on ia[0]
+for ( var i=0 ; i < 3 ; i++ ) {
+ Atomics.store(ia, i+1, 1);
+ $.agent.sleep(500);
+}
+
+// Wake them up one at a time and check the order is 0 1 2
+for ( var i=0 ; i < 3 ; i++ ) {
+ assert.sameValue(Atomics.wake(ia, 0, 1), 1);
+ assert.sameValue(getReport(), i + "ok");
+}
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
+
+
diff --git a/test/built-ins/Atomics/wake/wake-nan.js b/test/built-ins/Atomics/wake/wake-nan.js
new file mode 100644
index 000000000..945f503ff
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-nan.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes zero waiters if the count is NaN
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We will timeout eventually
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agent a chance to wait
+assert.sameValue(Atomics.wake(ia, 0, NaN), 0); // Don't actually wake it
+assert.sameValue(getReport(), "timed-out");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wake/wake-negative.js b/test/built-ins/Atomics/wake/wake-negative.js
new file mode 100644
index 000000000..56755aece
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-negative.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes zero waiters if the count is negative
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We will timeout eventually
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agent a chance to wait
+assert.sameValue(Atomics.wake(ia, 0, -1), 0); // Don't actually wake it
+assert.sameValue(getReport(), "timed-out");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wake/wake-one.js b/test/built-ins/Atomics/wake/wake-one.js
new file mode 100644
index 000000000..1b4ab094b
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-one.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes one waiter if that's what the count is.
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We may timeout eventually
+ $.agent.leaving();
+})
+`);
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We may timeout eventually
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agents a chance to wait
+assert.sameValue(Atomics.wake(ia, 0, 1), 1); // Wake one
+var rs = [getReport(), getReport()];
+rs.sort();
+assert.sameValue(rs[0], "ok");
+assert.sameValue(rs[1], "timed-out");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wake/wake-two.js b/test/built-ins/Atomics/wake/wake-two.js
new file mode 100644
index 000000000..b7d970f27
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-two.js
@@ -0,0 +1,36 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes two waiters if that's what the count is.
+---*/
+
+for ( var i=0 ; i < 3 ; i++ ) {
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We may timeout eventually
+ $.agent.leaving();
+})
+`);
+}
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agents a chance to wait
+assert.sameValue(Atomics.wake(ia, 0, 2), 2); // Wake two
+var rs = [getReport(), getReport(), getReport()];
+rs.sort();
+assert.sameValue(rs[0], "ok");
+assert.sameValue(rs[1], "ok");
+assert.sameValue(rs[2], "timed-out");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/wake/wake-zero.js b/test/built-ins/Atomics/wake/wake-zero.js
new file mode 100644
index 000000000..6b00dd2a4
--- /dev/null
+++ b/test/built-ins/Atomics/wake/wake-zero.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test that Atomics.wake wakes zero waiters if that's what the count is.
+---*/
+
+$.agent.start(
+`
+$.agent.receiveBroadcast(function (sab) {
+ var ia = new Int32Array(sab);
+ $.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We will timeout eventually
+ $.agent.leaving();
+})
+`);
+
+var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
+
+$.agent.broadcast(ia.buffer);
+$.agent.sleep(500); // Give the agent a chance to wait
+assert.sameValue(Atomics.wake(ia, 0, 0), 0); // Don't actually wake it
+assert.sameValue(getReport(), "timed-out");
+
+function getReport() {
+ var r;
+ while ((r = $.agent.getReport()) == null)
+ $.agent.sleep(100);
+ return r;
+}
diff --git a/test/built-ins/Atomics/xor/bad-range.js b/test/built-ins/Atomics/xor/bad-range.js
new file mode 100644
index 000000000..ed19315b9
--- /dev/null
+++ b/test/built-ins/Atomics/xor/bad-range.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test range checking of Atomics.xor on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(4);
+var views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ let view = new View(sab);
+ testWithAtomicsOutOfBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ assert.throws(RangeError, () => Atomics.xor(view, Idx, 0));
+ });
+}, views);
diff --git a/test/built-ins/Atomics/xor/descriptor.js b/test/built-ins/Atomics/xor/descriptor.js
new file mode 100644
index 000000000..8bd1aaa8b
--- /dev/null
+++ b/test/built-ins/Atomics/xor/descriptor.js
@@ -0,0 +1,12 @@
+// Copyright 2015 Microsoft Corporation. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/*---
+description: Testing descriptor property of Atomics.xor
+includes: [propertyHelper.js]
+---*/
+
+verifyWritable(Atomics, "xor");
+verifyNotEnumerable(Atomics, "xor");
+verifyConfigurable(Atomics, "xor");
diff --git a/test/built-ins/Atomics/xor/good-views.js b/test/built-ins/Atomics/xor/good-views.js
new file mode 100644
index 000000000..3e10d25a8
--- /dev/null
+++ b/test/built-ins/Atomics/xor/good-views.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Test Atomics.xor on arrays that allow atomic operations
+includes: [testAtomics.js, testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+var ab = new ArrayBuffer(16);
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ // Make it interesting - use non-zero byteOffsets and non-zero indexes.
+
+ var view = new View(sab, 32, 20);
+ var control = new View(ab, 0, 2);
+
+ view[8] = 0x33333333;
+ control[0] = 0x33333333;
+ assert.sameValue(Atomics.xor(view, 8, 0x55555555), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 0x66666666;
+ assert.sameValue(view[8], control[0]);
+ assert.sameValue(Atomics.xor(view, 8, 0xF0F0F0F0), control[0],
+ "Result is subject to chopping");
+
+ control[0] = 0x96969696;
+ assert.sameValue(view[8], control[0]);
+
+ view[3] = -5;
+ control[0] = -5;
+ assert.sameValue(Atomics.xor(view, 3, 0), control[0],
+ "Result is negative and subject to coercion");
+ assert.sameValue(view[3], control[0]);
+
+ control[0] = 12345;
+ view[3] = 12345;
+ assert.sameValue(Atomics.xor(view, 3, 0), control[0],
+ "Result is subject to chopping");
+ assert.sameValue(view[3], control[0]);
+
+ // And again
+ control[0] = 123456789;
+ view[3] = 123456789;
+ assert.sameValue(Atomics.xor(view, 3, 0), control[0],
+ "Result is subject to chopping");
+ assert.sameValue(view[3], control[0]);
+
+ // In-bounds boundary cases for indexing
+ testWithAtomicsInBoundsIndices(function(IdxGen) {
+ let Idx = IdxGen(view);
+ view.fill(0);
+ // Atomics.store() computes an index from Idx in the same way as other
+ // Atomics operations, not quite like view[Idx].
+ Atomics.store(view, Idx, 37);
+ assert.sameValue(Atomics.xor(view, Idx, 0), 37);
+ });
+}, int_views);
diff --git a/test/built-ins/Atomics/xor/length.js b/test/built-ins/Atomics/xor/length.js
new file mode 100644
index 000000000..65bf3df88
--- /dev/null
+++ b/test/built-ins/Atomics/xor/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.xor.length is 3.
+info: >
+ Atomics.xor ( ia, index, val )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.xor.length, 3);
+
+verifyNotEnumerable(Atomics.xor, "length");
+verifyNotWritable(Atomics.xor, "length");
+verifyConfigurable(Atomics.xor, "length");
diff --git a/test/built-ins/Atomics/xor/name.js b/test/built-ins/Atomics/xor/name.js
new file mode 100644
index 000000000..720f5ac7d
--- /dev/null
+++ b/test/built-ins/Atomics/xor/name.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Atomics.xor.name is "xor".
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Atomics.xor.name, "xor");
+
+verifyNotEnumerable(Atomics.xor, "name");
+verifyNotWritable(Atomics.xor, "name");
+verifyConfigurable(Atomics.xor, "name");
diff --git a/test/built-ins/Atomics/xor/non-views.js b/test/built-ins/Atomics/xor/non-views.js
new file mode 100644
index 000000000..59293b75b
--- /dev/null
+++ b/test/built-ins/Atomics/xor/non-views.js
@@ -0,0 +1,12 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.xor on view values other than TypedArrays
+includes: [testAtomics.js]
+---*/
+
+testWithAtomicsNonViewValues(function(view) {
+ assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
+});
diff --git a/test/built-ins/Atomics/xor/nonshared-int-views.js b/test/built-ins/Atomics/xor/nonshared-int-views.js
new file mode 100644
index 000000000..a3652b229
--- /dev/null
+++ b/test/built-ins/Atomics/xor/nonshared-int-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.xor on non-shared integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var ab = new ArrayBuffer(16);
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(ab);
+
+ assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
+}, int_views);
diff --git a/test/built-ins/Atomics/xor/shared-nonint-views.js b/test/built-ins/Atomics/xor/shared-nonint-views.js
new file mode 100644
index 000000000..af5d8910a
--- /dev/null
+++ b/test/built-ins/Atomics/xor/shared-nonint-views.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Test Atomics.xor on shared non-integer TypedArrays
+includes: [testTypedArray.js]
+---*/
+
+var sab = new SharedArrayBuffer(1024);
+
+var other_views = [Uint8ClampedArray, Float32Array, Float64Array];
+
+testWithTypedArrayConstructors(function(View) {
+ var view = new View(sab);
+
+ assert.throws(TypeError, (() => Atomics.xor(view, 0, 0)));
+}, other_views);
diff --git a/test/built-ins/DataView/buffer-does-not-have-arraybuffer-data-throws-sab.js b/test/built-ins/DataView/buffer-does-not-have-arraybuffer-data-throws-sab.js
new file mode 100644
index 000000000..0edf058f6
--- /dev/null
+++ b/test/built-ins/DataView/buffer-does-not-have-arraybuffer-data-throws-sab.js
@@ -0,0 +1,43 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Throws a TypeError if buffer does not have [[ArrayBufferData]]
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 2. If Type(buffer) is not Object, throw a TypeError exception.
+ 3. If buffer does not have an [[ArrayBufferData]] internal slot, throw a
+ TypeError exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error("buffer should be verified before byteOffset");
+ }
+};
+
+assert.throws(TypeError, function() {
+ new DataView({}, obj);
+}, "{}");
+
+assert.throws(TypeError, function() {
+ new DataView([], obj);
+}, "[]");
+
+var ta = new Int8Array();
+assert.throws(TypeError, function() {
+ new DataView(ta, obj);
+}, "typedArray instance");
+
+var other = new DataView(new SharedArrayBuffer(1), 0);
+assert.throws(TypeError, function() {
+ new DataView(other, obj);
+}, "dataView instance");
diff --git a/test/built-ins/DataView/buffer-reference-sab.js b/test/built-ins/DataView/buffer-reference-sab.js
new file mode 100644
index 000000000..e1b8b3855
--- /dev/null
+++ b/test/built-ins/DataView/buffer-reference-sab.js
@@ -0,0 +1,26 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Reuse buffer argument instead of making a new clone
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 14. Set O's [[ViewedArrayBuffer]] internal slot to buffer.
+ ...
+ 17. Return O.
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+var dv1 = new DataView(buffer, 0);
+var dv2 = new DataView(buffer, 0);
+
+assert.sameValue(dv1.buffer, buffer);
+assert.sameValue(dv2.buffer, buffer);
diff --git a/test/built-ins/DataView/byteoffset-is-negative-throws-sab.js b/test/built-ins/DataView/byteoffset-is-negative-throws-sab.js
new file mode 100644
index 000000000..98dc9faa5
--- /dev/null
+++ b/test/built-ins/DataView/byteoffset-is-negative-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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Throws a RangeError if ToInteger(byteOffset) < 0
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 4. Let numberOffset be ? ToNumber(byteOffset).
+ 5. Let offset be ToInteger(numberOffset).
+ 6. If numberOffset ≠ offset or offset < 0, throw a RangeError exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var ab = new SharedArrayBuffer(42);
+
+assert.throws(RangeError, function() {
+ new DataView(ab, -1);
+}, "-1");
+
+assert.throws(RangeError, function() {
+ new DataView(ab, -Infinity);
+}, "-Infinity");
diff --git a/test/built-ins/DataView/custom-proto-access-throws-sab.js b/test/built-ins/DataView/custom-proto-access-throws-sab.js
new file mode 100644
index 000000000..fca677f51
--- /dev/null
+++ b/test/built-ins/DataView/custom-proto-access-throws-sab.js
@@ -0,0 +1,46 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return abrupt from newTarget's custom constructor prototype
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataViewPrototype%",
+ « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
+ ...
+ 17. Return O.
+
+ 9.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ ,
+ internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor,
+ intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 3. Let proto be ? Get(constructor, "prototype").
+ ...
+features: [Reflect.construct, SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+var newTarget = function() {}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ Reflect.construct(DataView, [buffer, 0], newTarget);
+});
diff --git a/test/built-ins/DataView/custom-proto-if-not-object-fallbacks-to-default-prototype-sab.js b/test/built-ins/DataView/custom-proto-if-not-object-fallbacks-to-default-prototype-sab.js
new file mode 100644
index 000000000..accdd4125
--- /dev/null
+++ b/test/built-ins/DataView/custom-proto-if-not-object-fallbacks-to-default-prototype-sab.js
@@ -0,0 +1,47 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Use DataView.prototype if newTarget's prototype is not an Object
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataViewPrototype%",
+ « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
+ ...
+ 17. Return O.
+
+ 9.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ ,
+ internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor,
+ intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 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.
+ ...
+features: [Reflect.construct, SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+function newTarget() {}
+newTarget.prototype = null;
+
+var sample = Reflect.construct(DataView, [buffer, 0], newTarget);
+
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
diff --git a/test/built-ins/DataView/custom-proto-if-object-is-used-sab.js b/test/built-ins/DataView/custom-proto-if-object-is-used-sab.js
new file mode 100644
index 000000000..732cdc8fa
--- /dev/null
+++ b/test/built-ins/DataView/custom-proto-if-object-is-used-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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Use newTarget's custom constructor prototype if Object
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataViewPrototype%",
+ « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
+ ...
+ 17. Return O.
+
+ 9.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ ,
+ internalSlotsList ] )
+
+ ...
+ 2. Let proto be ? GetPrototypeFromConstructor(constructor,
+ intrinsicDefaultProto).
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
+
+ ...
+ 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.
+ ...
+features: [Reflect.construct, SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+function newTarget() {}
+var proto = {};
+newTarget.prototype = proto;
+
+var sample = Reflect.construct(DataView, [buffer, 0], newTarget);
+
+assert.sameValue(sample.constructor, Object);
+assert.sameValue(Object.getPrototypeOf(sample), proto);
diff --git a/test/built-ins/DataView/defined-bytelength-and-byteoffset-sab.js b/test/built-ins/DataView/defined-bytelength-and-byteoffset-sab.js
new file mode 100644
index 000000000..1e5dc9a83
--- /dev/null
+++ b/test/built-ins/DataView/defined-bytelength-and-byteoffset-sab.js
@@ -0,0 +1,61 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return new instance from defined length and offset
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 17. Return O.
+features: [SharedArrayBuffer]
+---*/
+
+var sample;
+var buffer = new SharedArrayBuffer(3);
+
+sample = new DataView(buffer, 1, 2);
+assert.sameValue(sample.byteLength, 2, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 1, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer, "sample.buffer");
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 1, 0);
+assert.sameValue(sample.byteLength, 0, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 1, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer, "sample.buffer");
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 0, 3);
+assert.sameValue(sample.byteLength, 3, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 0, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer, "sample.buffer");
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 3, 0);
+assert.sameValue(sample.byteLength, 0, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 3, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer, "sample.buffer");
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 0, 1);
+assert.sameValue(sample.byteLength, 1, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 0, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer, "sample.buffer");
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 0, 2);
+assert.sameValue(sample.byteLength, 2, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 0, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer, "sample.buffer");
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
diff --git a/test/built-ins/DataView/defined-byteoffset-sab.js b/test/built-ins/DataView/defined-byteoffset-sab.js
new file mode 100644
index 000000000..b15aa54e8
--- /dev/null
+++ b/test/built-ins/DataView/defined-byteoffset-sab.js
@@ -0,0 +1,54 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return new instance from defined offset
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 17. Return O.
+features: [SharedArrayBuffer]
+---*/
+
+var sample;
+var buffer = new SharedArrayBuffer(4);
+
+sample = new DataView(buffer, 0);
+assert.sameValue(sample.byteLength, 4, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 0, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 1);
+assert.sameValue(sample.byteLength, 3, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 1, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 2);
+assert.sameValue(sample.byteLength, 2, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 2, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 3);
+assert.sameValue(sample.byteLength, 1, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 3, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 4);
+assert.sameValue(sample.byteLength, 0, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 4, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
diff --git a/test/built-ins/DataView/defined-byteoffset-undefined-bytelength-sab.js b/test/built-ins/DataView/defined-byteoffset-undefined-bytelength-sab.js
new file mode 100644
index 000000000..1fd6f27f0
--- /dev/null
+++ b/test/built-ins/DataView/defined-byteoffset-undefined-bytelength-sab.js
@@ -0,0 +1,57 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return new instance from defined byteoffset and undefined bytelength
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 8. If byteLength is either not present or undefined, then
+ a. Let viewByteLength be bufferByteLength - offset.
+ ...
+ 17. Return O.
+features: [SharedArrayBuffer]
+---*/
+
+var sample;
+var buffer = new SharedArrayBuffer(4);
+
+sample = new DataView(buffer, 0, undefined);
+assert.sameValue(sample.byteLength, 4, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 0, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 1, undefined);
+assert.sameValue(sample.byteLength, 3, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 1, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 2, undefined);
+assert.sameValue(sample.byteLength, 2, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 2, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 3, undefined);
+assert.sameValue(sample.byteLength, 1, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 3, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+sample = new DataView(buffer, 4, undefined);
+assert.sameValue(sample.byteLength, 0, "sample.byteLength");
+assert.sameValue(sample.byteOffset, 4, "sample.byteOffset");
+assert.sameValue(sample.buffer, buffer);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
diff --git a/test/built-ins/DataView/excessive-bytelength-throws-sab.js b/test/built-ins/DataView/excessive-bytelength-throws-sab.js
new file mode 100644
index 000000000..c0d4f6f8b
--- /dev/null
+++ b/test/built-ins/DataView/excessive-bytelength-throws-sab.js
@@ -0,0 +1,56 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Throws RangeError if offset + viewByteLength > bufferByteLength
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 10. If byteLength is undefined, then
+ ...
+ 11. Else,
+ a. Let viewByteLength be ? ToLength(byteLength).
+ b. If offset+viewByteLength > bufferByteLength, throw a RangeError
+ exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(3);
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 0, 4);
+}, "offset: 0, length 4");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 1, 3);
+}, "offset: 1, length: 3");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 2, 2);
+}, "offset: 2, length: 2");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 3, 1);
+}, "offset: 3, length: 1");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 4, 0);
+}, "offset: 4, length: 0");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 4, -1);
+}, "offset: 4, length: -1");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 4, -Infinity);
+}, "offset: 4, length: -Infinity");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 0, Infinity);
+}, "offset: 0, length: Infinity");
diff --git a/test/built-ins/DataView/excessive-byteoffset-throws-sab.js b/test/built-ins/DataView/excessive-byteoffset-throws-sab.js
new file mode 100644
index 000000000..e66bb7e3e
--- /dev/null
+++ b/test/built-ins/DataView/excessive-byteoffset-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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Throws a RangeError if offset > bufferByteLength
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 8. Let bufferByteLength be the value of buffer's [[ArrayBufferByteLength]]
+ internal slot.
+ 9. If offset > bufferByteLength, throw a RangeError exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var ab = new SharedArrayBuffer(1);
+
+assert.throws(RangeError, function() {
+ new DataView(ab, 2);
+}, "2");
+
+assert.throws(RangeError, function() {
+ new DataView(ab, Infinity);
+}, "Infinity");
diff --git a/test/built-ins/DataView/instance-extensibility-sab.js b/test/built-ins/DataView/instance-extensibility-sab.js
new file mode 100644
index 000000000..1c583ac96
--- /dev/null
+++ b/test/built-ins/DataView/instance-extensibility-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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ The new instance is extensible
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataViewPrototype%",
+ « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
+ ...
+ 17. Return O.
+
+ 9.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ ,
+ internalSlotsList ] )
+
+ ...
+ 3. Return ObjectCreate(proto, internalSlotsList).
+
+ 9.1.12 ObjectCreate (proto [ , internalSlotsList ])
+
+ ...
+ 5. Set the [[Extensible]] internal slot of obj to true.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var sample = new DataView(buffer, 0);
+
+assert(Object.isExtensible(sample));
diff --git a/test/built-ins/DataView/negative-bytelength-throws-sab.js b/test/built-ins/DataView/negative-bytelength-throws-sab.js
new file mode 100644
index 000000000..52dadc6c1
--- /dev/null
+++ b/test/built-ins/DataView/negative-bytelength-throws-sab.js
@@ -0,0 +1,46 @@
+// 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-dataview-buffer-byteoffset-bytelength
+description: >
+ Throws a RangeError if ToInteger(byteLength) < 0
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 8. If byteLength is either not present or undefined, then
+ a. Let viewByteLength be bufferByteLength - offset.
+ 9. Else,
+ a. Let viewByteLength be ? ToIndex(byteLength).
+ ...
+
+ ToIndex ( value )
+
+ 1. If value is undefined, then
+ a. Let index be 0.
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(2);
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 0, -1);
+}, "new DataView(buffer, 0, -1);");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 0, -Infinity);
+}, "new DataView(buffer, 0, -Infinity);");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 1, -1);
+}, "new DataView(buffer, 1, -1);");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, 2, -Infinity);
+}, "new DataView(buffer, 2, -Infinity);");
diff --git a/test/built-ins/DataView/negative-byteoffset-throws-sab.js b/test/built-ins/DataView/negative-byteoffset-throws-sab.js
new file mode 100644
index 000000000..65b1eda87
--- /dev/null
+++ b/test/built-ins/DataView/negative-byteoffset-throws-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-dataview-buffer-byteoffset-bytelength
+description: >
+ Throws a RangeError if ToInteger(byteOffset) < 0
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 4. Let offset be ? ToIndex(byteOffset).
+ ...
+
+ ToIndex ( value )
+
+ 1. If value is undefined, then
+ a. Let index be 0.
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(2);
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, -1);
+}, "new DataView(buffer, -1);");
+
+assert.throws(RangeError, function() {
+ new DataView(buffer, -Infinity);
+}, "new DataView(buffer, -Infinity);");
diff --git a/test/built-ins/DataView/newtarget-undefined-throws-sab.js b/test/built-ins/DataView/newtarget-undefined-throws-sab.js
new file mode 100644
index 000000000..cc7d4593f
--- /dev/null
+++ b/test/built-ins/DataView/newtarget-undefined-throws-sab.js
@@ -0,0 +1,28 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Throws a TypeError if NewTarget is undefined.
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error("NewTarget should be verified before byteOffset");
+ }
+};
+
+var buffer = new SharedArrayBuffer(1);
+
+assert.throws(TypeError, function() {
+ DataView(buffer, obj);
+});
diff --git a/test/built-ins/DataView/proto-from-ctor-realm-sab.js b/test/built-ins/DataView/proto-from-ctor-realm-sab.js
new file mode 100644
index 000000000..81166659c
--- /dev/null
+++ b/test/built-ins/DataView/proto-from-ctor-realm-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-dataview-buffer-byteoffset-bytelength
+es6id: 24.2.2.1
+description: Default [[Prototype]] value derived from realm of the newTarget
+info: |
+ [...]
+ 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget,
+ "%DataViewPrototype%", « [[DataView]], [[ViewedArrayBuffer]],
+ [[ByteLength]], [[ByteOffset]] »).
+ [...]
+
+ 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.
+ [...]
+features: [Reflect, SharedArrayBuffer]
+---*/
+
+var other = $.createRealm().global;
+var C = new other.Function();
+C.prototype = null;
+var buffer = new SharedArrayBuffer(0);
+
+var o = Reflect.construct(DataView, [buffer, 0], C);
+
+assert.sameValue(Object.getPrototypeOf(o), other.DataView.prototype);
diff --git a/test/built-ins/DataView/prototype/buffer/return-buffer-sab.js b/test/built-ins/DataView/prototype/buffer/return-buffer-sab.js
new file mode 100644
index 000000000..9e11cd930
--- /dev/null
+++ b/test/built-ins/DataView/prototype/buffer/return-buffer-sab.js
@@ -0,0 +1,22 @@
+// 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-get-dataview.prototype.buffer
+es6id: 24.2.4.1
+description: >
+ Return buffer from [[ViewedArrayBuffer]] internal slot
+info: |
+ 24.2.4.1 get DataView.prototype.buffer
+
+ ...
+ 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
+ 6. Return buffer.
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(1);
+var dv = new DataView(buffer, 0);
+
+assert.sameValue(dv.buffer, buffer);
diff --git a/test/built-ins/DataView/prototype/buffer/this-has-no-dataview-internal-sab.js b/test/built-ins/DataView/prototype/buffer/this-has-no-dataview-internal-sab.js
new file mode 100644
index 000000000..4f3c79b56
--- /dev/null
+++ b/test/built-ins/DataView/prototype/buffer/this-has-no-dataview-internal-sab.js
@@ -0,0 +1,41 @@
+// 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-get-dataview.prototype.buffer
+description: >
+ Throws a TypeError exception when `this` does not have a [[DataView]] internal
+ slot
+info: |
+ 24.2.4.1 get DataView.prototype.buffer
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "buffer"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+}, "{}");
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+}, "[]");
+
+var ab = new SharedArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+}, "ArrayBuffer");
+
+var ta = new Int8Array();
+assert.throws(TypeError, function() {
+ getter.call(ta);
+}, "TypedArray");
diff --git a/test/built-ins/DataView/prototype/byteLength/return-bytelength-sab.js b/test/built-ins/DataView/prototype/byteLength/return-bytelength-sab.js
new file mode 100644
index 000000000..200c6dbbd
--- /dev/null
+++ b/test/built-ins/DataView/prototype/byteLength/return-bytelength-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-get-dataview.prototype.bytelength
+es6id: 24.2.4.2
+description: >
+ Return value from [[ByteLength]] internal slot
+info: |
+ 24.2.4.2 get DataView.prototype.byteLength
+
+ ...
+ 7. Let size be the value of O's [[ByteLength]] internal slot.
+ 8. Return size.
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(12);
+
+var sample1 = new DataView(buffer, 0);
+var sample2 = new DataView(buffer, 4);
+var sample3 = new DataView(buffer, 6, 4);
+var sample4 = new DataView(buffer, 12);
+
+assert.sameValue(sample1.byteLength, 12);
+assert.sameValue(sample2.byteLength, 8);
+assert.sameValue(sample3.byteLength, 4);
+assert.sameValue(sample4.byteLength, 0);
diff --git a/test/built-ins/DataView/prototype/byteLength/this-has-no-dataview-internal-sab.js b/test/built-ins/DataView/prototype/byteLength/this-has-no-dataview-internal-sab.js
new file mode 100644
index 000000000..dd5335260
--- /dev/null
+++ b/test/built-ins/DataView/prototype/byteLength/this-has-no-dataview-internal-sab.js
@@ -0,0 +1,41 @@
+// 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-get-dataview.prototype.bytelength
+description: >
+ Throws a TypeError exception when `this` does not have a [[DataView]] internal
+ slot
+info: |
+ 24.2.4.2 get DataView.prototype.byteLength
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+}, "{}");
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+}, "[]");
+
+var ab = new SharedArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+}, "ArrayBuffer");
+
+var ta = new Int8Array();
+assert.throws(TypeError, function() {
+ getter.call(ta);
+}, "TypedArray");
diff --git a/test/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js b/test/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js
new file mode 100644
index 000000000..b4fb8cfc7
--- /dev/null
+++ b/test/built-ins/DataView/prototype/byteOffset/return-byteoffset-sab.js
@@ -0,0 +1,31 @@
+// 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-get-dataview.prototype.byteoffset
+es6id: 24.2.4.3
+description: >
+ Return value from [[ByteOffset]] internal slot
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ ...
+ 7. Let offset be the value of O's [[ByteOffset]] internal slot.
+ 8. Return offset.
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(12);
+
+var sample1 = new DataView(buffer, 0);
+var sample2 = new DataView(buffer, 4);
+var sample3 = new DataView(buffer, 6, 4);
+var sample4 = new DataView(buffer, 12);
+var sample5 = new DataView(buffer, 0, 2);
+
+assert.sameValue(sample1.byteOffset, 0);
+assert.sameValue(sample2.byteOffset, 4);
+assert.sameValue(sample3.byteOffset, 6);
+assert.sameValue(sample4.byteOffset, 12);
+assert.sameValue(sample5.byteOffset, 0);
diff --git a/test/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js b/test/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js
new file mode 100644
index 000000000..6fb275721
--- /dev/null
+++ b/test/built-ins/DataView/prototype/byteOffset/this-has-no-dataview-internal-sab.js
@@ -0,0 +1,41 @@
+// 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-get-dataview.prototype.byteoffset
+description: >
+ Throws a TypeError exception when `this` does not have a [[DataView]] internal
+ slot
+info: |
+ 24.2.4.3 get DataView.prototype.byteOffset
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If O does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ DataView.prototype, "byteOffset"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+}, "{}");
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+}, "[]");
+
+var ab = new SharedArrayBuffer(8);
+assert.throws(TypeError, function() {
+ getter.call(ab);
+}, "ArrayBuffer");
+
+var ta = new Int8Array();
+assert.throws(TypeError, function() {
+ getter.call(ta);
+}, "TypedArray");
diff --git a/test/built-ins/DataView/prototype/getInt32/index-is-out-of-range-sab.js b/test/built-ins/DataView/prototype/getInt32/index-is-out-of-range-sab.js
new file mode 100644
index 000000000..d70aa75a4
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/index-is-out-of-range-sab.js
@@ -0,0 +1,86 @@
+// 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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Throws a RangeError if getIndex + elementSize > viewSize
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 10. Let viewOffset be the value of view's [[ByteOffset]] internal slot.
+ 11. Let viewSize be the value of view's [[ByteLength]] internal slot.
+ 12. Let elementSize be the Number value of the Element Size value specified in
+ Table 50 for Element Type type.
+ 13. If getIndex + elementSize > viewSize, throw a RangeError exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var sample;
+var buffer = new SharedArrayBuffer(12);
+
+sample = new DataView(buffer, 0);
+
+assert.throws(RangeError, function() {
+ sample.getInt32(Infinity);
+}, "getIndex == Infinity");
+
+assert.throws(RangeError, function() {
+ sample.getInt32(13);
+}, "13 + 4 > 12");
+
+assert.throws(RangeError, function() {
+ sample.getInt32(12);
+}, "12 + 4 > 12");
+
+assert.throws(RangeError, function() {
+ sample.getInt32(11);
+}, "11 + 4 > 12");
+
+assert.throws(RangeError, function() {
+ sample.getInt32(10);
+}, "10 + 4 > 12");
+
+assert.throws(RangeError, function() {
+ sample.getInt32(9);
+}, "9 + 4 > 12");
+
+sample = new DataView(buffer, 8);
+assert.throws(RangeError, function() {
+ sample.getInt32(1);
+}, "1 + 4 > 4 (offset)");
+
+sample = new DataView(buffer, 9);
+assert.throws(RangeError, function() {
+ sample.getInt32(0);
+}, "0 + 4 > 3 (offset)");
+
+sample = new DataView(buffer, 0, 4);
+assert.throws(RangeError, function() {
+ sample.getInt32(1);
+}, "1 + 4 > 4 (length)");
+
+sample = new DataView(buffer, 0, 3);
+assert.throws(RangeError, function() {
+ sample.getInt32(0);
+}, "0 + 4 > 3 (length)");
+
+sample = new DataView(buffer, 4, 4);
+assert.throws(RangeError, function() {
+ sample.getInt32(1);
+}, "1 + 4 > 4 (offset+length)");
+
+sample = new DataView(buffer, 4, 3);
+assert.throws(RangeError, function() {
+ sample.getInt32(0);
+}, "0 + 4 > 3 (offset+length)");
diff --git a/test/built-ins/DataView/prototype/getInt32/negative-byteoffset-throws-sab.js b/test/built-ins/DataView/prototype/getInt32/negative-byteoffset-throws-sab.js
new file mode 100644
index 000000000..79fca0de0
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/negative-byteoffset-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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Throws a RangeError if getIndex < 0
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 4. Let getIndex be ? ToIndex(requestIndex).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(12);
+var sample = new DataView(buffer, 0);
+
+assert.throws(RangeError, function() {
+ sample.getInt32(-1);
+}, "-1");
+
+assert.throws(RangeError, function() {
+ sample.getInt32(-Infinity);
+}, "-Infinity");
diff --git a/test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-sab.js b/test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-sab.js
new file mode 100644
index 000000000..2e2786914
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-sab.js
@@ -0,0 +1,46 @@
+// 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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Return abrupt from ToNumber(byteOffset)
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 4. Let numberIndex be ? ToNumber(requestIndex).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(1);
+var sample = new DataView(buffer, 0);
+
+var bo1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var bo2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ sample.getInt32(bo1);
+}, "valueOf");
+
+assert.throws(Test262Error, function() {
+ sample.getInt32(bo2);
+}, "toString");
diff --git a/test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-symbol-sab.js b/test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-symbol-sab.js
new file mode 100644
index 000000000..d87f83f0e
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/return-abrupt-from-tonumber-byteoffset-symbol-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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Return abrupt from ToNumber(symbol byteOffset)
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 4. Let numberIndex be ? ToNumber(requestIndex).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(1);
+var sample = new DataView(buffer, 0);
+
+var s = Symbol("1");
+
+assert.throws(TypeError, function() {
+ sample.getInt32(s);
+});
diff --git a/test/built-ins/DataView/prototype/getInt32/return-value-clean-arraybuffer-sab.js b/test/built-ins/DataView/prototype/getInt32/return-value-clean-arraybuffer-sab.js
new file mode 100644
index 000000000..1f353ccd2
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/return-value-clean-arraybuffer-sab.js
@@ -0,0 +1,45 @@
+// 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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Return value from Buffer using a clean ArrayBuffer
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 14. Let bufferIndex be getIndex + viewOffset.
+ 15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
+ ...
+
+ 24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
+ ] )
+
+ ...
+ 8. If isLittleEndian is false, reverse the order of the elements of rawValue.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var sample = new DataView(buffer, 0);
+
+assert.sameValue(sample.getInt32(0, true), 0, "sample.getInt32(0, true)");
+assert.sameValue(sample.getInt32(1, true), 0, "sample.getInt32(1, true)");
+assert.sameValue(sample.getInt32(2, true), 0, "sample.getInt32(2, true)");
+assert.sameValue(sample.getInt32(3, true), 0, "sample.getInt32(3, true)");
+assert.sameValue(sample.getInt32(4, true), 0, "sample.getInt32(4, true)");
+assert.sameValue(sample.getInt32(0, false), 0, "sample.getInt32(0, false)");
+assert.sameValue(sample.getInt32(1, false), 0, "sample.getInt32(1, false)");
+assert.sameValue(sample.getInt32(2, false), 0, "sample.getInt32(2, false)");
+assert.sameValue(sample.getInt32(3, false), 0, "sample.getInt32(3, false)");
+assert.sameValue(sample.getInt32(4, false), 0, "sample.getInt32(4, false)");
diff --git a/test/built-ins/DataView/prototype/getInt32/return-values-custom-offset-sab.js b/test/built-ins/DataView/prototype/getInt32/return-values-custom-offset-sab.js
new file mode 100644
index 000000000..e2ec73cd1
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/return-values-custom-offset-sab.js
@@ -0,0 +1,59 @@
+// 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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Return values from Buffer using a custom offset
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 14. Let bufferIndex be getIndex + viewOffset.
+ 15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
+ ...
+
+ 24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
+ ] )
+
+ ...
+ 8. If isLittleEndian is false, reverse the order of the elements of rawValue.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(12);
+var sample = new DataView(buffer, 0);
+
+sample.setUint8(0, 39);
+sample.setUint8(1, 2);
+sample.setUint8(2, 6);
+sample.setUint8(3, 2);
+sample.setUint8(4, 128);
+sample.setUint8(5, 0);
+sample.setUint8(6, 128);
+sample.setUint8(7, 1);
+sample.setUint8(8, 127);
+sample.setUint8(9, 0);
+sample.setUint8(10, 127);
+sample.setUint8(11, 1);
+
+sample = new DataView(buffer, 4);
+
+assert.sameValue(sample.getInt32(0, false), -2147450879, "0, false");
+assert.sameValue(sample.getInt32(1, false), 8388991, "1, false");
+assert.sameValue(sample.getInt32(2, false), -2147385600, "2, false");
+assert.sameValue(sample.getInt32(3, false), 25100415, "3, false");
+
+assert.sameValue(sample.getInt32(0, true), 25165952, "0, true");
+assert.sameValue(sample.getInt32(1, true), 2130804736, "1, true");
+assert.sameValue(sample.getInt32(2, true), 8323456, "2, true");
+assert.sameValue(sample.getInt32(3, true), 2130738945, "3, true");
diff --git a/test/built-ins/DataView/prototype/getInt32/return-values-sab.js b/test/built-ins/DataView/prototype/getInt32/return-values-sab.js
new file mode 100644
index 000000000..87e0427bc
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/return-values-sab.js
@@ -0,0 +1,67 @@
+// 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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Return values from Buffer
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 14. Let bufferIndex be getIndex + viewOffset.
+ 15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
+ ...
+
+ 24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
+ ] )
+
+ ...
+ 8. If isLittleEndian is false, reverse the order of the elements of rawValue.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(12);
+var sample = new DataView(buffer, 0);
+
+sample.setUint8(0, 127);
+sample.setUint8(1, 255);
+sample.setUint8(2, 255);
+sample.setUint8(3, 255);
+sample.setUint8(4, 128);
+sample.setUint8(5, 0);
+sample.setUint8(6, 0);
+sample.setUint8(7, 0);
+sample.setUint8(8, 1);
+sample.setUint8(9, 0);
+sample.setUint8(10, 0);
+sample.setUint8(11, 0);
+
+assert.sameValue(sample.getInt32(0, false), 2147483647, "0, false"); // 2**32-1
+assert.sameValue(sample.getInt32(1, false), -128, "1, false");
+assert.sameValue(sample.getInt32(2, false), -32768, "2, false");
+assert.sameValue(sample.getInt32(3, false), -8388608, "3, false");
+assert.sameValue(sample.getInt32(4, false), -2147483648, "4, false");
+assert.sameValue(sample.getInt32(5, false), 1, "5, false");
+assert.sameValue(sample.getInt32(6, false), 256, "6, false");
+assert.sameValue(sample.getInt32(7, false), 65536, "7, false");
+assert.sameValue(sample.getInt32(8, false), 16777216, "8, false");
+
+assert.sameValue(sample.getInt32(0, true), -129, "0, true");
+assert.sameValue(sample.getInt32(1, true), -2130706433, "1, true");
+assert.sameValue(sample.getInt32(2, true), 8454143, "2, true");
+assert.sameValue(sample.getInt32(3, true), 33023, "3, true");
+assert.sameValue(sample.getInt32(4, true), 128, "4, true");
+assert.sameValue(sample.getInt32(5, true), 16777216, "5, true");
+assert.sameValue(sample.getInt32(6, true), 65536, "6, true");
+assert.sameValue(sample.getInt32(7, true), 256, "7, true");
+assert.sameValue(sample.getInt32(8, true), 1, "8, true");
diff --git a/test/built-ins/DataView/prototype/getInt32/this-has-no-dataview-internal-sab.js b/test/built-ins/DataView/prototype/getInt32/this-has-no-dataview-internal-sab.js
new file mode 100644
index 000000000..c9c1339b7
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/this-has-no-dataview-internal-sab.js
@@ -0,0 +1,44 @@
+// 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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Throws a TypeError if this does not have a [[DataView]] internal slot
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ 1. If Type(view) is not Object, throw a TypeError exception.
+ 2. If view does not have a [[DataView]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var getInt32 = DataView.prototype.getInt32;
+
+assert.throws(TypeError, function() {
+ getInt32.call({});
+}, "{}");
+
+assert.throws(TypeError, function() {
+ getInt32.call([]);
+}, "[]");
+
+var ab = new SharedArrayBuffer(1);
+assert.throws(TypeError, function() {
+ getInt32.call(ab);
+}, "ArrayBuffer");
+
+var ta = new Int8Array();
+assert.throws(TypeError, function() {
+ getInt32.call(ta);
+}, "TypedArray");
diff --git a/test/built-ins/DataView/prototype/getInt32/to-boolean-littleendian-sab.js b/test/built-ins/DataView/prototype/getInt32/to-boolean-littleendian-sab.js
new file mode 100644
index 000000000..5e4c3c9ad
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/to-boolean-littleendian-sab.js
@@ -0,0 +1,52 @@
+// 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-dataview.prototype.getint32
+es6id: 24.2.4.9
+description: >
+ Boolean littleEndian argument coerced in ToBoolean
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 14. Let bufferIndex be getIndex + viewOffset.
+ 15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
+ ...
+
+ 24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
+ ] )
+
+ ...
+ 8. If isLittleEndian is false, reverse the order of the elements of rawValue.
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(4);
+var sample = new DataView(buffer, 0);
+
+sample.setUint8(0, 0);
+sample.setUint8(1, 17);
+sample.setUint8(2, 4);
+sample.setUint8(3, 0);
+
+// False
+assert.sameValue(sample.getInt32(0), 1115136, "no arg");
+assert.sameValue(sample.getInt32(0, undefined), 1115136, "undefined");
+assert.sameValue(sample.getInt32(0, null), 1115136, "null");
+assert.sameValue(sample.getInt32(0, 0), 1115136, "0");
+assert.sameValue(sample.getInt32(0, ""), 1115136, "the empty string");
+
+// True
+assert.sameValue(sample.getInt32(0, {}), 266496, "{}");
+assert.sameValue(sample.getInt32(0, Symbol("1")), 266496, "symbol");
+assert.sameValue(sample.getInt32(0, 1), 266496, "1");
+assert.sameValue(sample.getInt32(0, "string"), 266496, "string");
diff --git a/test/built-ins/DataView/prototype/getInt32/toindex-byteoffset-sab.js b/test/built-ins/DataView/prototype/getInt32/toindex-byteoffset-sab.js
new file mode 100644
index 000000000..25d659b23
--- /dev/null
+++ b/test/built-ins/DataView/prototype/getInt32/toindex-byteoffset-sab.js
@@ -0,0 +1,65 @@
+// 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-dataview.prototype.getint32
+description: >
+ ToIndex conversions on byteOffset
+info: |
+ 24.2.4.9 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] )
+
+ 1. Let v be the this value.
+ 2. If littleEndian is not present, let littleEndian be false.
+ 3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int32").
+
+ 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
+
+ ...
+ 4. Let getIndex be ? ToIndex(requestIndex).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var sample = new DataView(buffer, 0);
+
+sample.setUint8(0, 127);
+sample.setUint8(1, 255);
+sample.setUint8(2, 255);
+sample.setUint8(3, 255);
+sample.setUint8(4, 128);
+sample.setUint8(5, 255);
+sample.setUint8(6, 255);
+sample.setUint8(7, 255);
+
+var obj1 = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 3;
+ }
+};
+
+assert.sameValue(sample.getInt32(-0), 2147483647, "-0");
+assert.sameValue(sample.getInt32(obj1), -32513, "object's valueOf");
+assert.sameValue(sample.getInt32(obj2), -8323073, "object's toString");
+assert.sameValue(sample.getInt32(""), 2147483647, "the Empty string");
+assert.sameValue(sample.getInt32("0"), 2147483647, "string '0'");
+assert.sameValue(sample.getInt32("2"), -32513, "string '2'");
+assert.sameValue(sample.getInt32(true), -128, "true");
+assert.sameValue(sample.getInt32(false), 2147483647, "false");
+assert.sameValue(sample.getInt32(NaN), 2147483647, "NaN");
+assert.sameValue(sample.getInt32(null), 2147483647, "null");
+assert.sameValue(sample.getInt32(0.1), 2147483647, "0.1");
+assert.sameValue(sample.getInt32(0.9), 2147483647, "0.9");
+assert.sameValue(sample.getInt32(1.1), -128, "1.1");
+assert.sameValue(sample.getInt32(1.9), -128, "1.9");
+assert.sameValue(sample.getInt32(-0.1), 2147483647, "-0.1");
+assert.sameValue(sample.getInt32(-0.99999), 2147483647, "-0.99999");
+assert.sameValue(sample.getInt32(undefined), 2147483647, "undefined");
+assert.sameValue(sample.getInt32(), 2147483647, "no arg");
diff --git a/test/built-ins/DataView/return-abrupt-tonumber-bytelength-sab.js b/test/built-ins/DataView/return-abrupt-tonumber-bytelength-sab.js
new file mode 100644
index 000000000..241f0b4e1
--- /dev/null
+++ b/test/built-ins/DataView/return-abrupt-tonumber-bytelength-sab.js
@@ -0,0 +1,42 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return abrupt from ToLength(byteLength)
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 10. If byteLength is undefined, then
+ a. Let viewByteLength be bufferByteLength - offset.
+ 11. Else,
+ a. Let viewByteLength be ? ToLength(byteLength).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+var obj1 = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ new DataView(buffer, 0, obj1);
+}, "valueOf");
+
+assert.throws(Test262Error, function() {
+ new DataView(buffer, 0, obj2);
+}, "toString");
diff --git a/test/built-ins/DataView/return-abrupt-tonumber-bytelength-symbol-sab.js b/test/built-ins/DataView/return-abrupt-tonumber-bytelength-symbol-sab.js
new file mode 100644
index 000000000..4c2d3cd9d
--- /dev/null
+++ b/test/built-ins/DataView/return-abrupt-tonumber-bytelength-symbol-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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return abrupt from ToLength(symbol byteLength)
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 10. If byteLength is undefined, then
+ a. Let viewByteLength be bufferByteLength - offset.
+ 11. Else,
+ a. Let viewByteLength be ? ToLength(byteLength).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var length = Symbol("1");
+
+assert.throws(TypeError, function() {
+ new DataView(buffer, 0, length);
+});
diff --git a/test/built-ins/DataView/return-abrupt-tonumber-byteoffset-sab.js b/test/built-ins/DataView/return-abrupt-tonumber-byteoffset-sab.js
new file mode 100644
index 000000000..9b4e85d60
--- /dev/null
+++ b/test/built-ins/DataView/return-abrupt-tonumber-byteoffset-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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return abrupt from ToNumber(byteOffset)
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 4. Let numberOffset be ? ToNumber(byteOffset).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+var ab = new SharedArrayBuffer(0);
+
+assert.throws(Test262Error, function() {
+ new DataView(ab, obj);
+});
diff --git a/test/built-ins/DataView/return-abrupt-tonumber-byteoffset-symbol-sab.js b/test/built-ins/DataView/return-abrupt-tonumber-byteoffset-symbol-sab.js
new file mode 100644
index 000000000..c18eba883
--- /dev/null
+++ b/test/built-ins/DataView/return-abrupt-tonumber-byteoffset-symbol-sab.js
@@ -0,0 +1,24 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Return abrupt from ToNumber(symbol byteOffset)
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 4. Let numberOffset be ? ToNumber(byteOffset).
+ ...
+features: [SharedArrayBuffer]
+---*/
+
+var s = Symbol("1");
+var ab = new SharedArrayBuffer(0);
+
+assert.throws(TypeError, function() {
+ new DataView(ab, s);
+});
diff --git a/test/built-ins/DataView/return-instance-sab.js b/test/built-ins/DataView/return-instance-sab.js
new file mode 100644
index 000000000..b306046e9
--- /dev/null
+++ b/test/built-ins/DataView/return-instance-sab.js
@@ -0,0 +1,31 @@
+// 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.
+
+/*---
+es6id: 24.2.2.1
+esid: sec-dataview-buffer-byteoffset-bytelength
+description: >
+ Returns new instance
+info: |
+ 24.2.2.1 DataView (buffer, byteOffset, byteLength )
+
+ ...
+ 12. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DataViewPrototype%",
+ « [[DataView]], [[ViewedArrayBuffer]], [[ByteLength]], [[ByteOffset]] »).
+ ...
+ 17. Return O.
+features: [SharedArrayBuffer]
+---*/
+
+var ab, sample;
+
+ab = new SharedArrayBuffer(1);
+sample = new DataView(ab, 0);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
+
+ab = new SharedArrayBuffer(1);
+sample = new DataView(ab, 1);
+assert.sameValue(sample.constructor, DataView);
+assert.sameValue(Object.getPrototypeOf(sample), DataView.prototype);
diff --git a/test/built-ins/DataView/toindex-bytelength-sab.js b/test/built-ins/DataView/toindex-bytelength-sab.js
new file mode 100644
index 000000000..627d313da
--- /dev/null
+++ b/test/built-ins/DataView/toindex-bytelength-sab.js
@@ -0,0 +1,95 @@
+// 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-dataview-buffer-byteoffset-bytelength
+description: >
+ ToIndex conversions on byteLength
+info: |
+ 24.2.2.1 DataView ( buffer, byteOffset, byteLength )
+
+ ...
+ 8. If byteLength is either not present or undefined, then
+ a. Let viewByteLength be bufferByteLength - offset.
+ 9. Else,
+ a. Let viewByteLength be ? ToIndex(byteLength).
+ b. If offset + viewByteLength > bufferByteLength, throw a RangeError
+ exception.
+ ...
+
+ ToIndex( value )
+
+ 1. If value is undefined, then
+ a. Let index be 0.
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ c. Let index be ! ToLength(integerIndex).
+ d. If SameValueZero(integerIndex, index) is false, throw a RangeError exception.
+ 3. Return index.
+features: [SharedArrayBuffer]
+---*/
+
+var obj1 = {
+ valueOf: function() {
+ return 3;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 4;
+ }
+};
+
+var sample;
+var ab = new SharedArrayBuffer(42);
+
+sample = new DataView(ab, 0, -0);
+assert.sameValue(sample.byteLength, 0, "-0");
+
+sample = new DataView(ab, 0, obj1);
+assert.sameValue(sample.byteLength, 3, "object's valueOf");
+
+sample = new DataView(ab, 0, obj2);
+assert.sameValue(sample.byteLength, 4, "object's toString");
+
+sample = new DataView(ab, 0, "");
+assert.sameValue(sample.byteLength, 0, "the Empty string");
+
+sample = new DataView(ab, 0, "0");
+assert.sameValue(sample.byteLength, 0, "string '0'");
+
+sample = new DataView(ab, 0, "1");
+assert.sameValue(sample.byteLength, 1, "string '1'");
+
+sample = new DataView(ab, 0, true);
+assert.sameValue(sample.byteLength, 1, "true");
+
+sample = new DataView(ab, 0, false);
+assert.sameValue(sample.byteLength, 0, "false");
+
+sample = new DataView(ab, 0, NaN);
+assert.sameValue(sample.byteLength, 0, "NaN");
+
+sample = new DataView(ab, 0, null);
+assert.sameValue(sample.byteLength, 0, "null");
+
+sample = new DataView(ab, 0, 0.1);
+assert.sameValue(sample.byteLength, 0, "0.1");
+
+sample = new DataView(ab, 0, 0.9);
+assert.sameValue(sample.byteLength, 0, "0.9");
+
+sample = new DataView(ab, 0, 1.1);
+assert.sameValue(sample.byteLength, 1, "1.1");
+
+sample = new DataView(ab, 0, 1.9);
+assert.sameValue(sample.byteLength, 1, "1.9");
+
+sample = new DataView(ab, 0, -0.1);
+assert.sameValue(sample.byteLength, 0, "-0.1");
+
+sample = new DataView(ab, 0, -0.99999);
+assert.sameValue(sample.byteLength, 0, "-0.99999");
diff --git a/test/built-ins/DataView/toindex-byteoffset-sab.js b/test/built-ins/DataView/toindex-byteoffset-sab.js
new file mode 100644
index 000000000..ddbb6420c
--- /dev/null
+++ b/test/built-ins/DataView/toindex-byteoffset-sab.js
@@ -0,0 +1,93 @@
+// 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-dataview-buffer-byteoffset-bytelength
+description: >
+ ToIndex conversions on byteOffset
+info: |
+ 24.2.2.1 DataView ( buffer, byteOffset, byteLength )
+
+ ...
+ 4. Let offset be ? ToIndex(byteOffset).
+ ...
+
+ ToIndex( value )
+
+ 1. If value is undefined, then
+ a. Let index be 0.
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ c. Let index be ! ToLength(integerIndex).
+ d. If SameValueZero(integerIndex, index) is false, throw a RangeError exception.
+ 3. Return index.
+features: [SharedArrayBuffer]
+---*/
+
+var obj1 = {
+ valueOf: function() {
+ return 3;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 4;
+ }
+};
+
+var sample;
+var ab = new SharedArrayBuffer(42);
+
+sample = new DataView(ab, -0);
+assert.sameValue(sample.byteOffset, 0, "-0");
+
+sample = new DataView(ab, obj1);
+assert.sameValue(sample.byteOffset, 3, "object's valueOf");
+
+sample = new DataView(ab, obj2);
+assert.sameValue(sample.byteOffset, 4, "object's toString");
+
+sample = new DataView(ab, "");
+assert.sameValue(sample.byteOffset, 0, "the Empty string");
+
+sample = new DataView(ab, "0");
+assert.sameValue(sample.byteOffset, 0, "string '0'");
+
+sample = new DataView(ab, "1");
+assert.sameValue(sample.byteOffset, 1, "string '1'");
+
+sample = new DataView(ab, true);
+assert.sameValue(sample.byteOffset, 1, "true");
+
+sample = new DataView(ab, false);
+assert.sameValue(sample.byteOffset, 0, "false");
+
+sample = new DataView(ab, NaN);
+assert.sameValue(sample.byteOffset, 0, "NaN");
+
+sample = new DataView(ab, null);
+assert.sameValue(sample.byteOffset, 0, "null");
+
+sample = new DataView(ab, undefined);
+assert.sameValue(sample.byteOffset, 0, "undefined");
+
+sample = new DataView(ab, 0.1);
+assert.sameValue(sample.byteOffset, 0, "0.1");
+
+sample = new DataView(ab, 0.9);
+assert.sameValue(sample.byteOffset, 0, "0.9");
+
+sample = new DataView(ab, 1.1);
+assert.sameValue(sample.byteOffset, 1, "1.1");
+
+sample = new DataView(ab, 1.9);
+assert.sameValue(sample.byteOffset, 1, "1.9");
+
+sample = new DataView(ab, -0.1);
+assert.sameValue(sample.byteOffset, 0, "-0.1");
+
+sample = new DataView(ab, -0.99999);
+assert.sameValue(sample.byteOffset, 0, "-0.99999");
diff --git a/test/built-ins/SharedArrayBuffer/allocation-limit.js b/test/built-ins/SharedArrayBuffer/allocation-limit.js
new file mode 100644
index 000000000..6326b5ba2
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/allocation-limit.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2015 André Bargull. 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-sharedarraybuffer-length
+description: >
+ Throws a RangeError if requested Data Block is too large.
+info: >
+ SharedArrayBuffer( length )
+
+ ...
+ 3. Return AllocateSharedArrayBuffer(NewTarget, byteLength).
+
+ 6.2.7.2 CreateSharedByteDataBlock(size)
+ ...
+ 2. Let db be a new Shared Data Block value consisting of size
+ bytes. If it is impossible to create such a Shared Data Block,
+ throw a RangeError exception.
+ ...
+---*/
+
+assert.throws(RangeError, function() {
+ // Allocating 7 PiB should fail with a RangeError.
+ // Math.pow(1024, 5) = 1125899906842624
+ new SharedArrayBuffer(7 * 1125899906842624);
+}, "`length` parameter is 7 PiB");
+
+assert.throws(RangeError, function() {
+ // Allocating almost 8 PiB should fail with a RangeError.
+ // Math.pow(2, 53) = 9007199254740992
+ new SharedArrayBuffer(9007199254740992 - 1);
+}, "`length` parameter is Math.pow(2, 53) - 1");
diff --git a/test/built-ins/SharedArrayBuffer/data-allocation-after-object-creation.js b/test/built-ins/SharedArrayBuffer/data-allocation-after-object-creation.js
new file mode 100644
index 000000000..a49ff7066
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/data-allocation-after-object-creation.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2015 André Bargull. 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-sharedarraybuffer-length
+description: >
+ The new SharedArrayBuffer instance is created prior to allocating the Data Block.
+info: >
+ SharedArrayBuffer( length )
+
+ ...
+ 3. Return AllocateSharedArrayBuffer(NewTarget, byteLength).
+
+ AllocateSharedArrayBuffer( constructor, byteLength )
+ 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBufferPrototype%",
+ «[[ArrayBufferData]], [[ArrayBufferByteLength]]» ).
+ ...
+ 3. Let block be ? CreateByteDataBlock(byteLength).
+ ...
+features: [Reflect.construct]
+---*/
+
+function DummyError() { }
+
+var newTarget = function(){}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get: function() {
+ throw new DummyError();
+ }
+});
+
+assert.throws(DummyError, function() {
+ // Allocating 7 PiB should fail with a RangeError.
+ // Math.pow(1024, 5) = 1125899906842624
+ Reflect.construct(SharedArrayBuffer, [7 * 1125899906842624], newTarget);
+});
diff --git a/test/built-ins/SharedArrayBuffer/init-zero.js b/test/built-ins/SharedArrayBuffer/init-zero.js
new file mode 100644
index 000000000..22d0d26c4
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/init-zero.js
@@ -0,0 +1,21 @@
+// 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-createsharedbytedatablock
+description: All bytes are initialized to zero
+features: [DataView]
+---*/
+
+var view = new DataView(new SharedArrayBuffer(9));
+
+assert.sameValue(view.getUint8(0), 0, 'index 0');
+assert.sameValue(view.getUint8(1), 0, 'index 1');
+assert.sameValue(view.getUint8(2), 0, 'index 2');
+assert.sameValue(view.getUint8(3), 0, 'index 3');
+assert.sameValue(view.getUint8(4), 0, 'index 4');
+assert.sameValue(view.getUint8(5), 0, 'index 5');
+assert.sameValue(view.getUint8(6), 0, 'index 6');
+assert.sameValue(view.getUint8(7), 0, 'index 7');
+assert.sameValue(view.getUint8(8), 0, 'index 8');
diff --git a/test/built-ins/SharedArrayBuffer/length-is-absent.js b/test/built-ins/SharedArrayBuffer/length-is-absent.js
new file mode 100644
index 000000000..6bf50f21e
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/length-is-absent.js
@@ -0,0 +1,19 @@
+// 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-sharedarraybuffer-length
+description: >
+ Returns an empty instance if length is absent
+info: |
+ SharedArrayBuffer( length )
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 2. Let byteLength be ? ToIndex(length).
+ 3. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength).
+---*/
+
+var buffer = new SharedArrayBuffer();
+
+assert.sameValue(buffer.byteLength, 0);
diff --git a/test/built-ins/SharedArrayBuffer/length-is-too-large-throws.js b/test/built-ins/SharedArrayBuffer/length-is-too-large-throws.js
new file mode 100644
index 000000000..fafea0c87
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/length-is-too-large-throws.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. 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-sharedarraybuffer-length
+description: >
+ Throws a RangeError if length >= 2 ** 53
+info: >
+ SharedArrayBuffer( length )
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 2. Let byteLength be ? ToIndex(length).
+
+ ToIndex( value )
+
+ 1. If value is undefined, then
+ a. Let index be 0.
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ ...
+---*/
+
+assert.throws(RangeError, function() {
+ // Math.pow(2, 53) = 9007199254740992
+ new SharedArrayBuffer(9007199254740992);
+}, "`length` parameter is too large");
+
+assert.throws(RangeError, function() {
+ new SharedArrayBuffer(Infinity);
+}, "`length` parameter is positive Infinity");
diff --git a/test/built-ins/SharedArrayBuffer/negative-length-throws.js b/test/built-ins/SharedArrayBuffer/negative-length-throws.js
new file mode 100644
index 000000000..2793751fb
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/negative-length-throws.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-sharedarraybuffer-length
+description: >
+ Throws a Range Error if length represents an integer < 0
+info: |
+ SharedArrayBuffer( length )
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 2. Let byteLength be ? ToIndex(length).
+
+ ToIndex( value )
+
+ 1. If value is undefined, then
+ a. Let index be 0.
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ ...
+---*/
+
+assert.throws(RangeError, function() {
+ new SharedArrayBuffer(-1);
+});
+
+assert.throws(RangeError, function() {
+ new SharedArrayBuffer(-1.1);
+});
+
+assert.throws(RangeError, function() {
+ new SharedArrayBuffer(-Infinity);
+});
diff --git a/test/built-ins/SharedArrayBuffer/newtarget-prototype-is-not-object.js b/test/built-ins/SharedArrayBuffer/newtarget-prototype-is-not-object.js
new file mode 100644
index 000000000..802b1787c
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/newtarget-prototype-is-not-object.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Foundation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-sharedarraybuffer-length
+description: >
+ [[Prototype]] defaults to %SharedArrayBufferPrototype% if NewTarget.prototype is not an object.
+info: >
+ SharedArrayBuffer( length )
+
+ SharedArrayBuffer called with argument length performs the following steps:
+
+ ...
+ 3. Return AllocateSharedArrayBuffer(NewTarget, byteLength).
+
+ AllocateSharedArrayBuffer( constructor, byteLength )
+ 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBufferPrototype%",
+ «[[ArrayBufferData]], [[ArrayBufferByteLength]]» ).
+ ...
+features: [Reflect.construct]
+---*/
+
+function newTarget() { }
+
+newTarget.prototype = undefined;
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [1], newTarget);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), SharedArrayBuffer.prototype, "newTarget.prototype is undefined");
+
+newTarget.prototype = null;
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [2], newTarget);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), SharedArrayBuffer.prototype, "newTarget.prototype is null");
+
+newTarget.prototype = true;
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [3], newTarget);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), SharedArrayBuffer.prototype, "newTarget.prototype is a Boolean");
+
+newTarget.prototype = "";
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [4], newTarget);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), SharedArrayBuffer.prototype, "newTarget.prototype is a String");
+
+newTarget.prototype = Symbol();
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [5], newTarget);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), SharedArrayBuffer.prototype, "newTarget.prototype is a Symbol");
+
+newTarget.prototype = 1;
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [6], newTarget);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), SharedArrayBuffer.prototype, "newTarget.prototype is a Number");
diff --git a/test/built-ins/SharedArrayBuffer/proto-from-ctor-realm.js b/test/built-ins/SharedArrayBuffer/proto-from-ctor-realm.js
new file mode 100644
index 000000000..9b5195eba
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/proto-from-ctor-realm.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-sharedarraybuffer-length
+description: Default [[Prototype]] value derived from realm of the newTarget
+info: |
+ [...]
+ 3. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength).
+
+ 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.
+ [...]
+features: [Reflect]
+---*/
+
+var other = $.createRealm().global;
+var C = new other.Function();
+C.prototype = null;
+
+var o = Reflect.construct(SharedArrayBuffer, [], C);
+
+assert.sameValue(Object.getPrototypeOf(o), other.SharedArrayBuffer.prototype);
diff --git a/test/built-ins/SharedArrayBuffer/prototype-from-newtarget.js b/test/built-ins/SharedArrayBuffer/prototype-from-newtarget.js
new file mode 100644
index 000000000..3a866cce8
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype-from-newtarget.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. 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-sharedarraybuffer-length
+description: >
+ The [[Prototype]] internal slot is computed from NewTarget.
+info: >
+ SharedArrayBuffer( length )
+
+ SharedArrayBuffer called with argument length performs the following steps:
+
+ ...
+ 3. Return AllocateSharedArrayBuffer(NewTarget, byteLength).
+
+ AllocateSharedArrayBuffer( constructor, byteLength )
+ 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SharedArrayBufferPrototype%",
+ «[[ArrayBufferData]], [[ArrayBufferByteLength]]» ).
+ ...
+features: [Reflect.construct]
+---*/
+
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [8], Object);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), Object.prototype, "NewTarget is built-in Object constructor");
+
+var newTarget = function(){}.bind(null);
+Object.defineProperty(newTarget, "prototype", {
+ get: function() {
+ return Array.prototype;
+ }
+});
+var arrayBuffer = Reflect.construct(SharedArrayBuffer, [16], newTarget);
+assert.sameValue(Object.getPrototypeOf(arrayBuffer), Array.prototype, "NewTarget is BoundFunction with accessor");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/Symbol.toStringTag.js b/test/built-ins/SharedArrayBuffer/prototype/Symbol.toStringTag.js
new file mode 100644
index 000000000..edbe9e4cc
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/Symbol.toStringTag.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2015 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.
+/*---
+description: >
+ `Symbol.toStringTag` property descriptor
+info: >
+ The initial value of the @@toStringTag property is the String value
+ "SharedArrayBuffer".
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]:
+ false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Symbol.toStringTag]
+---*/
+
+assert.sameValue(SharedArrayBuffer.prototype[Symbol.toStringTag], 'SharedArrayBuffer');
+
+verifyNotEnumerable(SharedArrayBuffer.prototype, Symbol.toStringTag);
+verifyNotWritable(SharedArrayBuffer.prototype, Symbol.toStringTag);
+verifyConfigurable(SharedArrayBuffer.prototype, Symbol.toStringTag);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-accessor.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-accessor.js
new file mode 100644
index 000000000..f8a2a1912
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-accessor.js
@@ -0,0 +1,11 @@
+// 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.
+
+/*---
+description: Requires this value to have a [[ArrayBufferData]] internal slot
+---*/
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.byteLength;
+});
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-func.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-func.js
new file mode 100644
index 000000000..7ea7ad638
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/invoked-as-func.js
@@ -0,0 +1,14 @@
+// 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.
+/*---
+description: Throws a TypeError exception when invoked as a function
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ SharedArrayBuffer.prototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ getter();
+});
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/length.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/length.js
new file mode 100755
index 000000000..82ab36db6
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/length.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ get SharedArrayBuffer.prototype.byteLength.length is 0.
+includes: [propertyHelper.js]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength");
+
+assert.sameValue(desc.get.length, 0);
+
+verifyNotEnumerable(desc.get, "length");
+verifyNotWritable(desc.get, "length");
+verifyConfigurable(desc.get, "length");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/name.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/name.js
new file mode 100644
index 000000000..42dface35
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/name.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2015 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.
+/*---
+description: >
+ get SharedArrayBuffer.prototype.byteLength
+
+includes: [propertyHelper.js]
+---*/
+
+var descriptor = Object.getOwnPropertyDescriptor(
+ SharedArrayBuffer.prototype, 'byteLength'
+);
+
+assert.sameValue(
+ descriptor.get.name, 'get byteLength',
+ 'The value of `descriptor.get.name` is `"get byteLength"`'
+);
+
+verifyNotEnumerable(descriptor.get, 'name');
+verifyNotWritable(descriptor.get, 'name');
+verifyConfigurable(descriptor.get, 'name');
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/prop-desc.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/prop-desc.js
new file mode 100644
index 000000000..8266192cf
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/prop-desc.js
@@ -0,0 +1,16 @@
+// 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.
+/*---
+description: >
+ "byteLength" property of SharedArrayBuffer.prototype
+includes: [propertyHelper.js]
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength");
+
+assert.sameValue(desc.set, undefined);
+assert.sameValue(typeof desc.get, "function");
+
+verifyNotEnumerable(SharedArrayBuffer.prototype, "byteLength");
+verifyConfigurable(SharedArrayBuffer.prototype, "byteLength");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/return-bytelength.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/return-bytelength.js
new file mode 100644
index 000000000..66810df9f
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/return-bytelength.js
@@ -0,0 +1,12 @@
+// 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.
+/*---
+description: Return value from [[ByteLength]] internal slot
+---*/
+
+var ab1 = new SharedArrayBuffer(0);
+assert.sameValue(ab1.byteLength, 0);
+
+var ab2 = new SharedArrayBuffer(42);
+assert.sameValue(ab2.byteLength, 42);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js
new file mode 100644
index 000000000..32fee07cf
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js
@@ -0,0 +1,31 @@
+// 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.
+/*---
+description: >
+ Throws a TypeError exception when `this` does not have a [[ArrayBufferData]]
+ internal slot
+features: [DataView, Int8Array]
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ SharedArrayBuffer.prototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call({});
+});
+
+assert.throws(TypeError, function() {
+ getter.call([]);
+});
+
+var ta = new Int8Array(new SharedArrayBuffer(8));
+assert.throws(TypeError, function() {
+ getter.call(ta);
+});
+
+var dv = new DataView(new SharedArrayBuffer(8), 0);
+assert.throws(TypeError, function() {
+ getter.call(dv);
+});
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-arraybuffer.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-arraybuffer.js
new file mode 100644
index 000000000..f3ae27ebe
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-arraybuffer.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-get-sharedarraybuffer.prototype.bytelength
+description: Throws a TypeError exception when `this` is an ArrayBuffer
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ SharedArrayBuffer.prototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ var ab = new ArrayBuffer(4);
+ getter.call(ab);
+}, "`this` cannot be an ArrayBuffer");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-not-object.js b/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-not-object.js
new file mode 100644
index 000000000..79e857b75
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/byteLength/this-is-not-object.js
@@ -0,0 +1,39 @@
+// 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.
+/*---
+description: Throws a TypeError exception when `this` is not Object
+---*/
+
+var getter = Object.getOwnPropertyDescriptor(
+ SharedArrayBuffer.prototype, "byteLength"
+).get;
+
+assert.throws(TypeError, function() {
+ getter.call(undefined);
+}, "this is undefined");
+
+assert.throws(TypeError, function() {
+ getter.call(null);
+}, "this is null");
+
+assert.throws(TypeError, function() {
+ getter.call(42);
+}, "this is 42");
+
+assert.throws(TypeError, function() {
+ getter.call("1");
+}, "this is a string");
+
+assert.throws(TypeError, function() {
+ getter.call(true);
+}, "this is true");
+
+assert.throws(TypeError, function() {
+ getter.call(false);
+}, "this is false");
+
+var s = Symbol("s");
+assert.throws(TypeError, function() {
+ getter.call(s);
+}, "this is a Symbol");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/constructor.js b/test/built-ins/SharedArrayBuffer/prototype/constructor.js
new file mode 100755
index 000000000..49ca70562
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/constructor.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The `SharedArrayBuffer.prototype.constructor` property descriptor.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(SharedArrayBuffer.prototype.constructor, SharedArrayBuffer);
+
+verifyNotEnumerable(SharedArrayBuffer.prototype, "constructor");
+verifyWritable(SharedArrayBuffer.prototype, "constructor");
+verifyConfigurable(SharedArrayBuffer.prototype, "constructor");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js b/test/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js
new file mode 100755
index 000000000..6f20f2528
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a TypeError if `this` does not have an [[ArrayBufferData]] internal slot.
+info: >
+---*/
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call({});
+}, "`this` value is Object");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call([]);
+}, "`this` value is Array");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-object.js b/test/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-object.js
new file mode 100755
index 000000000..ce054180b
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/context-is-not-object.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a TypeError if `this` is not an Object.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+---*/
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call(undefined);
+}, "`this` value is undefined");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call(null);
+}, "`this` value is null");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call(true);
+}, "`this` value is Boolean");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call("");
+}, "`this` value is String");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call(Symbol());
+}, "`this` value is Symbol");
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer.prototype.slice.call(1);
+}, "`this` value is Number");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/descriptor.js b/test/built-ins/SharedArrayBuffer/prototype/slice/descriptor.js
new file mode 100755
index 000000000..3d0455ab1
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/descriptor.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ SharedArrayBuffer.prototype.slice has default data property attributes.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every other data property described in clauses 18 through 26 and in
+ Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+---*/
+
+verifyNotEnumerable(SharedArrayBuffer.prototype, "slice");
+verifyWritable(SharedArrayBuffer.prototype, "slice");
+verifyConfigurable(SharedArrayBuffer.prototype, "slice");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-absent.js b/test/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-absent.js
new file mode 100755
index 000000000..33b3fd41e
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-absent.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The `end` index defaults to [[ArrayBufferByteLength]] if absent.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var start = 6;
+var result = arrayBuffer.slice(start);
+assert.sameValue(result.byteLength, 2);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-undefined.js b/test/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-undefined.js
new file mode 100755
index 000000000..3d92aacd7
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/end-default-if-undefined.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The `end` index defaults to [[ArrayBufferByteLength]] if undefined.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var start = 6, end = undefined;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 2);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/end-exceeds-length.js b/test/built-ins/SharedArrayBuffer/prototype/slice/end-exceeds-length.js
new file mode 100755
index 000000000..b22b1ad37
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/end-exceeds-length.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Large `end` index is clamped to [[ArrayBufferByteLength]].
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var start = 1, end = 12;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 7, "slice(1, 12)");
+
+var start = 2, end = 0x100000000;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 6, "slice(2, 0x100000000)");
+
+var start = 3, end = +Infinity;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 5, "slice(3, Infinity)");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/extensible.js b/test/built-ins/SharedArrayBuffer/prototype/slice/extensible.js
new file mode 100755
index 000000000..00d5c8c5a
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/extensible.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ SharedArrayBuffer.prototype.slice is extensible.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Unless specified otherwise, the [[Extensible]] internal slot
+ of a built-in object initially has the value true.
+---*/
+
+assert(Object.isExtensible(SharedArrayBuffer.prototype.slice));
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/length.js b/test/built-ins/SharedArrayBuffer/prototype/slice/length.js
new file mode 100755
index 000000000..3d0e87725
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ SharedArrayBuffer.prototype.slice.length is 2.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this
+ value is equal to the largest number of named arguments shown in the
+ subclause headings for the function description, including optional
+ parameters. However, rest parameters shown using the form “...name”
+ are not included in the default argument count.
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(SharedArrayBuffer.prototype.slice.length, 2);
+
+verifyNotEnumerable(SharedArrayBuffer.prototype.slice, "length");
+verifyNotWritable(SharedArrayBuffer.prototype.slice, "length");
+verifyConfigurable(SharedArrayBuffer.prototype.slice, "length");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/name.js b/test/built-ins/SharedArrayBuffer/prototype/slice/name.js
new file mode 100755
index 000000000..87438f8d3
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/name.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ SharedArrayBuffer.prototype.slice.name is "slice".
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Every built-in Function object, including constructors, that is not
+ identified as an anonymous function has a name property whose value
+ is a String.
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(SharedArrayBuffer.prototype.slice.name, "slice");
+
+verifyNotEnumerable(SharedArrayBuffer.prototype.slice, "name");
+verifyNotWritable(SharedArrayBuffer.prototype.slice, "name");
+verifyConfigurable(SharedArrayBuffer.prototype.slice, "name");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/negative-end.js b/test/built-ins/SharedArrayBuffer/prototype/slice/negative-end.js
new file mode 100755
index 000000000..ac6690ff1
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/negative-end.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Negative `end` index is relative to [[ArrayBufferByteLength]].
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var start = 2, end = -4;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 2, "slice(2, -4)");
+
+var start = 2, end = -10;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 0, "slice(2, -10)");
+
+var start = 2, end = -Infinity;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 0, "slice(2, -Infinity)");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/negative-start.js b/test/built-ins/SharedArrayBuffer/prototype/slice/negative-start.js
new file mode 100755
index 000000000..6072265e1
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/negative-start.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Negative `start` index is relative to [[ArrayBufferByteLength]].
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var start = -5, end = 6;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 3, "slice(-5, 6)");
+
+var start = -12, end = 6;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 6, "slice(-12, 6)");
+
+var start = -Infinity, end = 6;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 6, "slice(-Infinity, 6)");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/nonconstructor.js b/test/built-ins/SharedArrayBuffer/prototype/slice/nonconstructor.js
new file mode 100755
index 000000000..7b03f743b
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/nonconstructor.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ SharedArrayBuffer.prototype.slice is not a constructor function.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+ 17 ECMAScript Standard Built-in Objects:
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified
+ in the description of a particular function.
+---*/
+
+assert.sameValue(Object.prototype.hasOwnProperty.call(SharedArrayBuffer.prototype.slice, "prototype"), false);
+
+var arrayBuffer = new SharedArrayBuffer(8);
+assert.throws(TypeError, function() { new arrayBuffer.slice(); });
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/number-conversion.js b/test/built-ins/SharedArrayBuffer/prototype/slice/number-conversion.js
new file mode 100755
index 000000000..811776080
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/number-conversion.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ ToInteger(start) is called before ToInteger(end).
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var log = "";
+var start = {
+ valueOf: function() {
+ log += "start-";
+ return 0;
+ }
+};
+var end = {
+ valueOf: function() {
+ log += "end";
+ return 8;
+ }
+};
+
+arrayBuffer.slice(start, end);
+assert.sameValue(log, "start-end");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-not-object.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-not-object.js
new file mode 100755
index 000000000..86212bc65
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-not-object.js
@@ -0,0 +1,30 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws TypeError if `constructor` property is not an object.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+function callSlice() { arrayBuffer.slice(); }
+
+arrayBuffer.constructor = null;
+assert.throws(TypeError, callSlice, "`constructor` value is null");
+
+arrayBuffer.constructor = true;
+assert.throws(TypeError, callSlice, "`constructor` value is Boolean");
+
+arrayBuffer.constructor = "";
+assert.throws(TypeError, callSlice, "`constructor` value is String");
+
+arrayBuffer.constructor = Symbol();
+assert.throws(TypeError, callSlice, "`constructor` value is Symbol");
+
+arrayBuffer.constructor = 1;
+assert.throws(TypeError, callSlice, "`constructor` value is Number");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-undefined.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-undefined.js
new file mode 100755
index 000000000..82fef79d6
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-constructor-is-undefined.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Uses default constructor is `constructor` property is undefined.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = undefined;
+
+var result = arrayBuffer.slice();
+assert.sameValue(Object.getPrototypeOf(result), SharedArrayBuffer.prototype);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-constructor.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-constructor.js
new file mode 100755
index 000000000..257fbacea
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-constructor.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a TypeError if species constructor is not a constructor function.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+function callSlice() { arrayBuffer.slice(); }
+
+speciesConstructor[Symbol.species] = {};
+assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Object");
+
+speciesConstructor[Symbol.species] = Function.prototype;
+assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Function.prototype");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-object.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-object.js
new file mode 100755
index 000000000..8bffd0747
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-not-object.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a TypeError if species constructor is not an object.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+function callSlice() { arrayBuffer.slice(); }
+
+speciesConstructor[Symbol.species] = true;
+assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Boolean");
+
+speciesConstructor[Symbol.species] = "";
+assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is String");
+
+speciesConstructor[Symbol.species] = Symbol();
+assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Symbol");
+
+speciesConstructor[Symbol.species] = 1;
+assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Number");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-null.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-null.js
new file mode 100755
index 000000000..d51c3b94d
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-null.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Uses default constructor is species constructor is null.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+speciesConstructor[Symbol.species] = null;
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+var result = arrayBuffer.slice();
+assert.sameValue(Object.getPrototypeOf(result), SharedArrayBuffer.prototype);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-undefined.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-undefined.js
new file mode 100755
index 000000000..90d37be28
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-is-undefined.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Uses default constructor is species constructor is undefined.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+speciesConstructor[Symbol.species] = undefined;
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+var result = arrayBuffer.slice();
+assert.sameValue(Object.getPrototypeOf(result), SharedArrayBuffer.prototype);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js
new file mode 100755
index 000000000..6b015a86a
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Does not throw TypeError if new SharedArrayBuffer is too large.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+speciesConstructor[Symbol.species] = function(length) {
+ return new SharedArrayBuffer(10);
+};
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+var result = arrayBuffer.slice();
+assert.sameValue(result.byteLength, 10);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js
new file mode 100755
index 000000000..4c7224eaf
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a TypeError if new object is not an SharedArrayBuffer instance.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+speciesConstructor[Symbol.species] = function(length) {
+ return {};
+};
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+assert.throws(TypeError, function() {
+ arrayBuffer.slice();
+});
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js
new file mode 100755
index 000000000..b2fed3bac
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a TypeError if species constructor returns `this` value.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+speciesConstructor[Symbol.species] = function(length) {
+ return arrayBuffer;
+};
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+assert.throws(TypeError, function() {
+ arrayBuffer.slice();
+});
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js
new file mode 100755
index 000000000..9d6c4994b
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Throws a TypeError if new SharedArrayBuffer is too small.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var speciesConstructor = {};
+speciesConstructor[Symbol.species] = function(length) {
+ return new SharedArrayBuffer(4);
+};
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+assert.throws(TypeError, function() {
+ arrayBuffer.slice();
+});
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/species.js b/test/built-ins/SharedArrayBuffer/prototype/slice/species.js
new file mode 100755
index 000000000..fa0cf8b28
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/species.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ New SharedArrayBuffer instance is created from SpeciesConstructor.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+features: [Symbol.species]
+---*/
+
+var resultBuffer;
+
+var speciesConstructor = {};
+speciesConstructor[Symbol.species] = function(length) {
+ return resultBuffer = new SharedArrayBuffer(length);
+};
+
+var arrayBuffer = new SharedArrayBuffer(8);
+arrayBuffer.constructor = speciesConstructor;
+
+var result = arrayBuffer.slice();
+assert.sameValue(result, resultBuffer);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-absent.js b/test/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-absent.js
new file mode 100755
index 000000000..2df219ea4
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-absent.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The `start` index defaults to 0 if absent.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var result = arrayBuffer.slice();
+assert.sameValue(result.byteLength, 8);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-undefined.js b/test/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-undefined.js
new file mode 100755
index 000000000..f491586ff
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/start-default-if-undefined.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The `start` index defaults to 0 if undefined.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var start = undefined, end = 6;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 6);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-end.js b/test/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-end.js
new file mode 100755
index 000000000..38493513a
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-end.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Returns zero-length buffer if `start` index exceeds `end` index.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+
+var start = 5, end = 4;
+var result = arrayBuffer.slice(start, end);
+assert.sameValue(result.byteLength, 0);
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-length.js b/test/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-length.js
new file mode 100755
index 000000000..59d7d9fcb
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/start-exceeds-length.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Large `start` index is clamped to [[ArrayBufferByteLength]].
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+var result;
+
+result = arrayBuffer.slice(10, 8);
+assert.sameValue(result.byteLength, 0, "slice(10, 8)");
+
+result = arrayBuffer.slice(0x100000000, 7);
+assert.sameValue(result.byteLength, 0, "slice(0x100000000, 7)");
+
+result = arrayBuffer.slice(+Infinity, 6);
+assert.sameValue(result.byteLength, 0, "slice(+Infinity, 6)");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/this-is-arraybuffer.js b/test/built-ins/SharedArrayBuffer/prototype/slice/this-is-arraybuffer.js
new file mode 100644
index 000000000..341ea2096
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/this-is-arraybuffer.js
@@ -0,0 +1,13 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-sharedarraybuffer.prototype.slice
+description: >
+ Throws a TypeError if `this` is an ArrayBuffer
+---*/
+
+assert.throws(TypeError, function() {
+ var ab = new ArrayBuffer(0);
+ SharedArrayBuffer.prototype.slice.call(ab);
+}, "`this` value cannot be an ArrayBuffer");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-end.js b/test/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-end.js
new file mode 100755
index 000000000..6421c07ab
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-end.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The `end` index parameter is converted to an integral numeric value.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+var result;
+
+result = arrayBuffer.slice(0, 4.5);
+assert.sameValue(result.byteLength, 4, "slice(0, 4.5)");
+
+result = arrayBuffer.slice(0, NaN);
+assert.sameValue(result.byteLength, 0, "slice(0, NaN)");
diff --git a/test/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-start.js b/test/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-start.js
new file mode 100755
index 000000000..7f25bc54b
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/prototype/slice/tointeger-conversion-start.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The `start` index parameter is converted to an integral numeric value.
+info: >
+ SharedArrayBuffer.prototype.slice ( start, end )
+---*/
+
+var arrayBuffer = new SharedArrayBuffer(8);
+var result;
+
+result = arrayBuffer.slice(4.5, 8);
+assert.sameValue(result.byteLength, 4, "slice(4.5, 8)");
+
+result = arrayBuffer.slice(NaN, 8);
+assert.sameValue(result.byteLength, 8, "slice(NaN, 8)");
diff --git a/test/built-ins/SharedArrayBuffer/return-abrupt-from-length-symbol.js b/test/built-ins/SharedArrayBuffer/return-abrupt-from-length-symbol.js
new file mode 100644
index 000000000..3b5358d8c
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/return-abrupt-from-length-symbol.js
@@ -0,0 +1,22 @@
+// 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-sharedarraybuffer-length
+description: >
+ Throws a TypeError if length is a symbol
+info: |
+ SharedArrayBuffer( length )
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 2. Let byteLength be ? ToIndex(length).
+ ...
+features: [Symbol]
+---*/
+
+var s = Symbol();
+
+assert.throws(TypeError, function() {
+ new SharedArrayBuffer(s);
+}, "`length` parameter is a Symbol");
diff --git a/test/built-ins/SharedArrayBuffer/return-abrupt-from-length.js b/test/built-ins/SharedArrayBuffer/return-abrupt-from-length.js
new file mode 100644
index 000000000..c5d2c8993
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/return-abrupt-from-length.js
@@ -0,0 +1,25 @@
+// 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-sharedarraybuffer-length
+description: >
+ Return abrupt from ToIndex(length)
+info: |
+ SharedArrayBuffer( length )
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 2. Let byteLength be ? ToIndex(length).
+ ...
+---*/
+
+var len = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ new SharedArrayBuffer(len);
+});
diff --git a/test/built-ins/SharedArrayBuffer/toindex-length.js b/test/built-ins/SharedArrayBuffer/toindex-length.js
new file mode 100644
index 000000000..e77883e0a
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/toindex-length.js
@@ -0,0 +1,88 @@
+// Copyright (C) 2016 The V8 Project authors. All rights reserved.
+// Copyright (C) 2016 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-sharedarraybuffer-length
+description: >
+ The `length` parameter is converted to a value numeric index value.
+info: |
+ SharedArrayBuffer( length )
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ 2. Let byteLength be ? ToIndex(length).
+ 3. Return ? AllocateSharedArrayBuffer(NewTarget, byteLength).
+
+ ToIndex( value )
+
+ 1. If value is undefined, then
+ a. Let index be 0.
+ 2. Else,
+ a. Let integerIndex be ? ToInteger(value).
+ b. If integerIndex < 0, throw a RangeError exception.
+ c. Let index be ! ToLength(integerIndex).
+ d. If SameValueZero(integerIndex, index) is false, throw a RangeError exception.
+ 3. Return index.
+---*/
+
+var obj1 = {
+ valueOf: function() {
+ return 42;
+ }
+};
+
+var obj2 = {
+ toString: function() {
+ return 42;
+ }
+};
+
+var buffer;
+
+buffer = new SharedArrayBuffer(obj1);
+assert.sameValue(buffer.byteLength, 42, "object's valueOf");
+
+buffer = new SharedArrayBuffer(obj2);
+assert.sameValue(buffer.byteLength, 42, "object's toString");
+
+buffer = new SharedArrayBuffer("");
+assert.sameValue(buffer.byteLength, 0, "the Empty string");
+
+buffer = new SharedArrayBuffer("0");
+assert.sameValue(buffer.byteLength, 0, "string '0'");
+
+buffer = new SharedArrayBuffer("1");
+assert.sameValue(buffer.byteLength, 1, "string '1'");
+
+buffer = new SharedArrayBuffer(true);
+assert.sameValue(buffer.byteLength, 1, "true");
+
+buffer = new SharedArrayBuffer(false);
+assert.sameValue(buffer.byteLength, 0, "false");
+
+buffer = new SharedArrayBuffer(NaN);
+assert.sameValue(buffer.byteLength, 0, "NaN");
+
+buffer = new SharedArrayBuffer(null);
+assert.sameValue(buffer.byteLength, 0, "null");
+
+buffer = new SharedArrayBuffer(undefined);
+assert.sameValue(buffer.byteLength, 0, "undefined");
+
+buffer = new SharedArrayBuffer(0.1);
+assert.sameValue(buffer.byteLength, 0, "0.1");
+
+buffer = new SharedArrayBuffer(0.9);
+assert.sameValue(buffer.byteLength, 0, "0.9");
+
+buffer = new SharedArrayBuffer(1.1);
+assert.sameValue(buffer.byteLength, 1, "1.1");
+
+buffer = new SharedArrayBuffer(1.9);
+assert.sameValue(buffer.byteLength, 1, "1.9");
+
+buffer = new SharedArrayBuffer(-0.1);
+assert.sameValue(buffer.byteLength, 0, "-0.1");
+
+buffer = new SharedArrayBuffer(-0.99999);
+assert.sameValue(buffer.byteLength, 0, "-0.99999");
diff --git a/test/built-ins/SharedArrayBuffer/undefined-newtarget-throws.js b/test/built-ins/SharedArrayBuffer/undefined-newtarget-throws.js
new file mode 100644
index 000000000..9729cab78
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/undefined-newtarget-throws.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 André Bargull. 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-sharedarraybuffer-length
+description: >
+ Throws a TypeError if SharedArrayBuffer is called as a function.
+info: >
+ SharedArrayBuffer( length )
+
+ SharedArrayBuffer called with argument length performs the following steps:
+
+ 1. If NewTarget is undefined, throw a TypeError exception.
+ ...
+---*/
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer();
+});
+
+assert.throws(TypeError, function() {
+ SharedArrayBuffer(10);
+});
diff --git a/test/built-ins/SharedArrayBuffer/zero-length.js b/test/built-ins/SharedArrayBuffer/zero-length.js
new file mode 100644
index 000000000..dba463b6d
--- /dev/null
+++ b/test/built-ins/SharedArrayBuffer/zero-length.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 André Bargull. 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-sharedarraybuffer-length
+description: >
+ The `length` parameter can be zero.
+info: >
+ SharedArrayBuffer( length )
+
+ ...
+ 2. Let numberLength be ToNumber(length).
+ 3. Let byteLength be ToLength(numberLength).
+ 4. ReturnIfAbrupt(byteLength).
+ 5. If SameValueZero(numberLength, byteLength) is false, throw a RangeError exception.
+ ...
+---*/
+
+var positiveZero = new SharedArrayBuffer(+0);
+assert.sameValue(positiveZero.byteLength, 0);
+
+var negativeZero = new SharedArrayBuffer(-0);
+assert.sameValue(negativeZero.byteLength, 0);
diff --git a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js
new file mode 100644
index 000000000..4960a32d4
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set converted values from different buffer of different types and different type instances
+includes: [byteConversionValues.js, testTypedArray.js]
+features: [SharedArrayBuffer]
+---*/
+
+testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) {
+ if (TA === Float64Array || TA === Float32Array || TA === Uint8ClampedArray) {
+ return;
+ }
+ if (TA === Int32Array) {
+ return;
+ }
+
+ var sab, src, target;
+
+ sab = new SharedArrayBuffer(4);
+ src = new Int32Array(sab);
+ src[0] = value;
+ target = new TA([initial]);
+
+ target.set(src);
+
+ assert.sameValue(target[0], expected, "src is SAB-backed");
+
+ sab = new SharedArrayBuffer(4);
+ src = new Int32Array([value]);
+ target = new TA(sab);
+ target[0] = initial;
+
+ target.set(src);
+
+ assert.sameValue(target[0], expected, "target is SAB-backed");
+
+ var sab1 = new SharedArrayBuffer(4);
+ var sab2 = new SharedArrayBuffer(4);
+ src = new Int32Array(sab1);
+ src[0] = value;
+ target = new TA(sab2);
+ target[0] = initial;
+
+ target.set(src);
+
+ assert.sameValue(target[0], expected, "src and target are SAB-backed");
+});
diff --git a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js
new file mode 100644
index 000000000..28c8a38ce
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js
@@ -0,0 +1,107 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and different
+ type.
+includes: [testTypedArray.js, compareArray.js]
+features: [SharedArrayBuffer]
+---*/
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(TA) {
+ var other = Int32Array;
+ var sab = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT);
+ var src = new other(sab);
+ src[0] = 42;
+ src[1] = 43;
+ var sample, result;
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+
+ src = new other([42, 43]);
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
+ src = new other(sab1);
+ src[0] = 42;
+ src[1] = 43;
+
+ var sab2;
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+}, int_views);
diff --git a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js
new file mode 100644
index 000000000..f21379958
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js
@@ -0,0 +1,107 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the different buffer and same
+ constructor. srcBuffer values are cached.
+includes: [testTypedArray.js, compareArray.js]
+features: [SharedArrayBuffer]
+---*/
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, result;
+
+ var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
+ var src = new TA(sab);
+ src[0] = 42;
+ src[1] = 43;
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sample = new TA([1, 2, 3, 4]);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+
+ src = new TA([42, 43]);
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+
+ var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT);
+ src = new TA(sab1);
+ src[0] = 42;
+ src[1] = 43;
+
+ var sab2;
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab2);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+}, int_views);
diff --git a/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js
new file mode 100644
index 000000000..a16d9f9f9
--- /dev/null
+++ b/test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.prototype.set-typedarray-offset
+description: >
+ Set values from different instances using the same buffer and same
+ constructor. srcBuffer values are cached.
+includes: [testTypedArray.js, compareArray.js]
+features: [SharedArrayBuffer]
+---*/
+
+var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array];
+
+testWithTypedArrayConstructors(function(TA) {
+ var sample, src, result, sab;
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 0);
+ assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 1);
+ assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+
+ sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT);
+ sample = new TA(sab);
+ sample[0] = 1;
+ sample[1] = 2;
+ sample[2] = 3;
+ sample[3] = 4;
+ src = new TA(sample.buffer, 0, 2);
+ result = sample.set(src, 2);
+ assert(compareArray(sample, [1, 2, 1, 2]), "offset: 2, result: " + sample);
+ assert.sameValue(result, undefined, "returns undefined");
+}, int_views);
diff --git a/test/built-ins/TypedArrays/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size-sab.js
new file mode 100644
index 000000000..4e40dfef9
--- /dev/null
+++ b/test/built-ins/TypedArrays/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.
+
+ ...
+ 13. If length is undefined, then
+ a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception.
+ ...
+includes: [testTypedArray.js]
+features: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(1);
+
+testWithTypedArrayConstructors(function(TA) {
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ // Impossible to trigger this step here.
+ return;
+ }
+
+ assert.throws(RangeError, function() {
+ new TA(buffer);
+ });
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 0, undefined);
+ });
+});
diff --git a/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-throws-sab.js
new file mode 100644
index 000000000..3f07c9da5
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-byteoffset-is-negative-zero-sab.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-zero-sab.js
new file mode 100644
index 000000000..06dd9be43
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+testWithTypedArrayConstructors(function(TAConstructor) {
+ var typedArray = new TAConstructor(new SharedArrayBuffer(8), -0);
+ assert.sameValue(typedArray.byteOffset, +0);
+});
diff --git a/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-symbol-throws-sab.js
new file mode 100644
index 000000000..416e5db7d
--- /dev/null
+++ b/test/built-ins/TypedArrays/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: [SharedArrayBuffer]
+---*/
+
+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/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-throws-from-modulo-element-size-sab.js
new file mode 100644
index 000000000..15139fd62
--- /dev/null
+++ b/test/built-ins/TypedArrays/buffer-arg-byteoffset-throws-from-modulo-element-size-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: >
+ 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: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+
+testWithTypedArrayConstructors(function(TA) {
+ if (TA.BYTES_PER_ELEMENT === 1) {
+ // Impossible to trigger this step here.
+ return;
+ }
+
+ assert.throws(RangeError, function() {
+ new TA(buffer, 7);
+ });
+});
diff --git a/test/built-ins/TypedArrays/buffer-arg-byteoffset-to-number-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-to-number-throws-sab.js
new file mode 100644
index 000000000..aca2e5331
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-custom-proto-access-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-custom-proto-access-throws-sab.js
new file mode 100644
index 000000000..0cc7860d5
--- /dev/null
+++ b/test/built-ins/TypedArrays/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").
+ ...
+features: [Reflect, SharedArrayBuffer]
+includes: [testTypedArray.js]
+---*/
+
+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/buffer-arg-defined-length-and-offset-sab.js b/test/built-ins/TypedArrays/buffer-arg-defined-length-and-offset-sab.js
new file mode 100644
index 000000000..f1a71ebec
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-defined-length-sab.js b/test/built-ins/TypedArrays/buffer-arg-defined-length-sab.js
new file mode 100644
index 000000000..0acb7537b
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-defined-negative-length-sab.js b/test/built-ins/TypedArrays/buffer-arg-defined-negative-length-sab.js
new file mode 100644
index 000000000..8ad965c6e
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-defined-offset-sab.js b/test/built-ins/TypedArrays/buffer-arg-defined-offset-sab.js
new file mode 100644
index 000000000..ddcb73e86
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-excessive-length-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-excessive-length-throws-sab.js
new file mode 100644
index 000000000..95936bc44
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-excessive-offset-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-excessive-offset-throws-sab.js
new file mode 100644
index 000000000..0daffb5ad
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-invoked-with-undefined-newtarget-sab.js b/test/built-ins/TypedArrays/buffer-arg-invoked-with-undefined-newtarget-sab.js
new file mode 100644
index 000000000..d6cd3981a
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new SharedArrayBuffer(4);
+ assert.throws(TypeError, function() {
+ TA(buffer);
+ });
+});
diff --git a/test/built-ins/TypedArrays/buffer-arg-is-referenced-sab.js b/test/built-ins/TypedArrays/buffer-arg-is-referenced-sab.js
new file mode 100644
index 000000000..eb119ea96
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-length-access-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-length-access-throws-sab.js
new file mode 100644
index 000000000..d0e19ded1
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var length = {
+ valueOf() {
+ throw new Test262Error();
+ }
+};
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(Test262Error, function() {
+ new TA(buffer, 0, length);
+ });
+});
diff --git a/test/built-ins/TypedArrays/buffer-arg-length-is-symbol-throws-sab.js b/test/built-ins/TypedArrays/buffer-arg-length-is-symbol-throws-sab.js
new file mode 100644
index 000000000..6f28e3077
--- /dev/null
+++ b/test/built-ins/TypedArrays/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: [SharedArrayBuffer]
+---*/
+
+var buffer = new SharedArrayBuffer(8);
+var length = Symbol("1");
+
+testWithTypedArrayConstructors(function(TA) {
+ assert.throws(TypeError, function() {
+ new TA(buffer, 0, length);
+ });
+});
diff --git a/test/built-ins/TypedArrays/buffer-arg-new-instance-extensibility-sab.js b/test/built-ins/TypedArrays/buffer-arg-new-instance-extensibility-sab.js
new file mode 100644
index 000000000..80f506d7f
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+testWithTypedArrayConstructors(function(TA) {
+ var buffer = new SharedArrayBuffer(8);
+ var sample = new TA(buffer);
+
+ assert(Object.isExtensible(sample));
+});
diff --git a/test/built-ins/TypedArrays/buffer-arg-proto-from-ctor-realm-sab.js b/test/built-ins/TypedArrays/buffer-arg-proto-from-ctor-realm-sab.js
new file mode 100644
index 000000000..c7dbc656a
--- /dev/null
+++ b/test/built-ins/TypedArrays/buffer-arg-proto-from-ctor-realm-sab.js
@@ -0,0 +1,39 @@
+// 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: [SharedArrayBuffer]
+features: [Reflect]
+---*/
+
+var other = $.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/buffer-arg-returns-new-instance-sab.js b/test/built-ins/TypedArrays/buffer-arg-returns-new-instance-sab.js
new file mode 100644
index 000000000..e702f6930
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-toindex-bytelength-sab.js b/test/built-ins/TypedArrays/buffer-arg-toindex-bytelength-sab.js
new file mode 100644
index 000000000..e5791798a
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-toindex-byteoffset-sab.js b/test/built-ins/TypedArrays/buffer-arg-toindex-byteoffset-sab.js
new file mode 100644
index 000000000..301172224
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-typedarray-backed-by-sharedarraybuffer.js b/test/built-ins/TypedArrays/buffer-arg-typedarray-backed-by-sharedarraybuffer.js
new file mode 100644
index 000000000..eecbe5edd
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/buffer-arg-use-custom-proto-if-object-sab.js b/test/built-ins/TypedArrays/buffer-arg-use-custom-proto-if-object-sab.js
new file mode 100644
index 000000000..678713d72
--- /dev/null
+++ b/test/built-ins/TypedArrays/buffer-arg-use-custom-proto-if-object-sab.js
@@ -0,0 +1,50 @@
+// 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.
+features: [Reflect]
+includes: [testTypedArray.js]
+features: [SharedArrayBuffer]
+---*/
+
+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/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js b/test/built-ins/TypedArrays/buffer-arg-use-default-proto-if-custom-proto-is-not-object-sab.js
new file mode 100644
index 000000000..60b4fcbb6
--- /dev/null
+++ b/test/built-ins/TypedArrays/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]
+---*/
+
+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/internals/Get/indexed-value-sab.js b/test/built-ins/TypedArrays/internals/Get/indexed-value-sab.js
new file mode 100644
index 000000000..2c0ab922a
--- /dev/null
+++ b/test/built-ins/TypedArrays/internals/Get/indexed-value-sab.js
@@ -0,0 +1,26 @@
+// 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.
+/*---
+description: >
+ Return value from valid numeric index, with SharedArrayBuffer
+includes: [testTypedArray.js]
+---*/
+
+var proto = TypedArray.prototype;
+var throwDesc = {
+ get: function() {
+ throw new Test262Error("OrdinaryGet was called! Ref: 9.1.8.1 3.c");
+ }
+};
+Object.defineProperty(proto, "0", throwDesc);
+Object.defineProperty(proto, "1", throwDesc);
+
+testWithTypedArrayConstructors(function(TA) {
+ var sab = new SharedArrayBuffer(TA.BYTES_PER_ELEMENT * 2);
+ var sample = new TA(sab);
+ sample.set([42, 1]);
+
+ assert.sameValue(sample["0"], 42);
+ assert.sameValue(sample["1"], 1);
+});