diff --git a/test/built-ins/DataView/prototype/getBigUint64/detached-buffer-after-toindex-byteoffset.js b/test/built-ins/DataView/prototype/getBigUint64/detached-buffer-after-toindex-byteoffset.js new file mode 100644 index 0000000000..a96d8c9c5c --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/detached-buffer-after-toindex-byteoffset.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Detached buffer is only checked after ToIndex(requestIndex) +includes: [detachArrayBuffer.js] +features: [DataView, ArrayBuffer, BigInt, arrow-function] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); + +assert.throws(RangeError, () => sample.getBigUint64(Infinity), + "DataView access at index Infinity should throw"); + +assert.throws(RangeError, () => sample.getBigUint64(-1), + "DataView access at index -1 should throw"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/detached-buffer-before-outofrange-byteoffset.js b/test/built-ins/DataView/prototype/getBigUint64/detached-buffer-before-outofrange-byteoffset.js new file mode 100644 index 0000000000..9b0fb3d272 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/detached-buffer-before-outofrange-byteoffset.js @@ -0,0 +1,20 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Detached buffer is checked before out of range byteOffset's value +includes: [detachArrayBuffer.js] +features: [DataView, ArrayBuffer, BigInt, arrow-function] +---*/ + +var sample; +var buffer = new ArrayBuffer(12); + +sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); + +assert.throws(TypeError, () => sample.getBigUint64(13), + "detached DataView access should throw"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/detached-buffer.js b/test/built-ins/DataView/prototype/getBigUint64/detached-buffer.js new file mode 100644 index 0000000000..b3fdb8b29d --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/detached-buffer.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Throws a TypeError if buffer is detached +includes: [detachArrayBuffer.js] +features: [DataView, ArrayBuffer, BigInt, arrow-function] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +$DETACHBUFFER(buffer); +assert.throws(TypeError, () => sample.getBigUint64(0), + "detached DataView access should throw"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/index-is-out-of-range.js b/test/built-ins/DataView/prototype/getBigUint64/index-is-out-of-range.js new file mode 100644 index 0000000000..88f38cb64a --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/index-is-out-of-range.js @@ -0,0 +1,59 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Throws a RangeError if getIndex + elementSize > viewSize +features: [DataView, ArrayBuffer, BigInt, arrow-function] +---*/ + +var sample; +var buffer = new ArrayBuffer(12); + +sample = new DataView(buffer, 0); + +assert.throws(RangeError, () => sample.getBigUint64(Infinity), + "DataView access at index Infinity should throw"); + +assert.throws(RangeError, () => sample.getBigUint64(13), "13 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(12), "12 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(11), "11 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(10), "10 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(9), "9 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(8), "8 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(7), "7 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(6), "6 + 8 > 12"); + +assert.throws(RangeError, () => sample.getBigUint64(5), "5 + 8 > 12"); + +sample = new DataView(buffer, 8); +assert.throws(RangeError, () => sample.getBigUint64(1), + "1 + 8 > 4 (offset)"); + +sample = new DataView(buffer, 9); +assert.throws(RangeError, () => sample.getBigUint64(0), + "0 + 8 > 3 (offset)"); + +sample = new DataView(buffer, 0, 8); +assert.throws(RangeError, () => sample.getBigUint64(1), + "1 + 8 > 8 (length)"); + +sample = new DataView(buffer, 0, 7); +assert.throws(RangeError, () => sample.getBigUint64(0), + "0 + 8 > 7 (length)"); + +sample = new DataView(buffer, 4, 8); +assert.throws(RangeError, () => sample.getBigUint64(1), + "1 + 8 > 8 (offset+length)"); + +sample = new DataView(buffer, 4, 7); +assert.throws(RangeError, () => sample.getBigUint64(0), + "0 + 8 > 7 (offset+length)"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/length.js b/test/built-ins/DataView/prototype/getBigUint64/length.js new file mode 100644 index 0000000000..9fe7ed6c89 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/length.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: DataView.prototype.getBigUint64.length property descriptor +includes: [propertyHelper.js] +features: [DataView, ArrayBuffer, BigInt] +---*/ + +verifyProperty(DataView.prototype.getBigUint64, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/built-ins/DataView/prototype/getBigUint64/name.js b/test/built-ins/DataView/prototype/getBigUint64/name.js new file mode 100644 index 0000000000..26f0f045bc --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/name.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: DataView.prototype.getBigUint64.name property descriptor +includes: [propertyHelper.js] +features: [DataView, ArrayBuffer, BigInt] +---*/ + +verifyProperty(DataView.prototype.getBigUint64, "name", { + value: "getBigUint64", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/built-ins/DataView/prototype/getBigUint64/negative-byteoffset-throws.js b/test/built-ins/DataView/prototype/getBigUint64/negative-byteoffset-throws.js new file mode 100644 index 0000000000..3216d86c88 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/negative-byteoffset-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Throws a RangeError if getIndex < 0 +features: [DataView, ArrayBuffer, BigInt, arrow-function] +---*/ + +var buffer = new ArrayBuffer(12); +var sample = new DataView(buffer, 0); + +assert.throws(RangeError, () => sample.getBigUint64(-1), + "DataView access at index -1 should throw"); + +assert.throws(RangeError, () => sample.getBigUint64(-Infinity), + "DataView access at index -Infinity should throw"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/return-abrupt-from-tonumber-byteoffset-symbol.js b/test/built-ins/DataView/prototype/getBigUint64/return-abrupt-from-tonumber-byteoffset-symbol.js new file mode 100644 index 0000000000..6755600a5f --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/return-abrupt-from-tonumber-byteoffset-symbol.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Return abrupt from ToNumber(symbol byteOffset) +features: [DataView, ArrayBuffer, Symbol, BigInt, arrow-function] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +var s = Symbol("1"); + +assert.throws(TypeError, () => sample.getBigUint64(s)); diff --git a/test/built-ins/DataView/prototype/getBigUint64/return-abrupt-from-tonumber-byteoffset.js b/test/built-ins/DataView/prototype/getBigUint64/return-abrupt-from-tonumber-byteoffset.js new file mode 100644 index 0000000000..4f7bb95960 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/return-abrupt-from-tonumber-byteoffset.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Return abrupt from ToNumber(byteOffset) +features: [DataView, ArrayBuffer, BigInt, arrow-function] +---*/ + +var buffer = new ArrayBuffer(1); +var sample = new DataView(buffer, 0); + +var bo1 = { valueOf() { throw new Test262Error(); } }; +var bo2 = { toString() { throw new Test262Error(); } }; + +assert.throws(Test262Error, () => sample.getBigUint64(bo1), "valueOf"); + +assert.throws(Test262Error, () => sample.getBigUint64(bo2), "toString"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/return-value-clean-arraybuffer.js b/test/built-ins/DataView/prototype/getBigUint64/return-value-clean-arraybuffer.js new file mode 100644 index 0000000000..25ee7766d2 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/return-value-clean-arraybuffer.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Return value from Buffer using a clean ArrayBuffer +features: [DataView, ArrayBuffer, BigInt] +---*/ + +var buffer = new ArrayBuffer(12); +var sample = new DataView(buffer, 0); + +assert.sameValue(sample.getBigUint64(0, true), 0n, "sample.getBigUint64(0, true)"); +assert.sameValue(sample.getBigUint64(1, true), 0n, "sample.getBigUint64(1, true)"); +assert.sameValue(sample.getBigUint64(2, true), 0n, "sample.getBigUint64(2, true)"); +assert.sameValue(sample.getBigUint64(3, true), 0n, "sample.getBigUint64(3, true)"); +assert.sameValue(sample.getBigUint64(4, true), 0n, "sample.getBigUint64(4, true)"); +assert.sameValue(sample.getBigUint64(0, false), 0n, "sample.getBigUint64(0, false)"); +assert.sameValue(sample.getBigUint64(1, false), 0n, "sample.getBigUint64(1, false)"); +assert.sameValue(sample.getBigUint64(2, false), 0n, "sample.getBigUint64(2, false)"); +assert.sameValue(sample.getBigUint64(3, false), 0n, "sample.getBigUint64(3, false)"); +assert.sameValue(sample.getBigUint64(4, false), 0n, "sample.getBigUint64(4, false)"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/return-values-custom-offset.js b/test/built-ins/DataView/prototype/getBigUint64/return-values-custom-offset.js new file mode 100644 index 0000000000..074c8a2799 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/return-values-custom-offset.js @@ -0,0 +1,43 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Return values from Buffer using a custom offset +features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt] +---*/ + +var buffer = new ArrayBuffer(16); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 0x27); +sample.setUint8(1, 0x02); +sample.setUint8(2, 0x06); +sample.setUint8(3, 0x02); +sample.setUint8(4, 0x80); +sample.setUint8(5, 0x00); +sample.setUint8(6, 0x80); +sample.setUint8(7, 0x01); +sample.setUint8(8, 0x7f); +sample.setUint8(9, 0x00); +sample.setUint8(10, 0x01); +sample.setUint8(11, 0x02); +sample.setUint8(12, 0x80); +sample.setUint8(13, 0x7f); +sample.setUint8(14, 0xff); +sample.setUint8(15, 0x80); + +sample = new DataView(buffer, 4); + +assert.sameValue(sample.getBigUint64(0, false), 0x800080017f000102n, "0, false"); +assert.sameValue(sample.getBigUint64(1, false), 0x80017f00010280n, "1, false"); +assert.sameValue(sample.getBigUint64(2, false), 0x80017f000102807fn, "2, false"); +assert.sameValue(sample.getBigUint64(3, false), 0x17f000102807fffn, "3, false"); +assert.sameValue(sample.getBigUint64(4, false), 0x7f000102807fff80n, "4, false"); + +assert.sameValue(sample.getBigUint64(0, true), 0x201007f01800080n, "0, true"); +assert.sameValue(sample.getBigUint64(1, true), 0x800201007f018000n, "1, true"); +assert.sameValue(sample.getBigUint64(2, true), 0x7f800201007f0180n, "2, true"); +assert.sameValue(sample.getBigUint64(3, true), 0xff7f800201007f01n, "3, true"); +assert.sameValue(sample.getBigUint64(4, true), 0x80ff7f800201007fn, "4, true"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/return-values.js b/test/built-ins/DataView/prototype/getBigUint64/return-values.js new file mode 100644 index 0000000000..7b6b4250b4 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/return-values.js @@ -0,0 +1,49 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Return values from Buffer +features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt] +---*/ + +var buffer = new ArrayBuffer(16); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 0x27); +sample.setUint8(1, 0x02); +sample.setUint8(2, 0x06); +sample.setUint8(3, 0x02); +sample.setUint8(4, 0x80); +sample.setUint8(5, 0x00); +sample.setUint8(6, 0x80); +sample.setUint8(7, 0x01); +sample.setUint8(8, 0x7f); +sample.setUint8(9, 0x00); +sample.setUint8(10, 0x01); +sample.setUint8(11, 0x02); +sample.setUint8(12, 0x80); +sample.setUint8(13, 0x7f); +sample.setUint8(14, 0xff); +sample.setUint8(15, 0x80); + +assert.sameValue(sample.getBigUint64(0, false), 0x2702060280008001n, "0, false"); +assert.sameValue(sample.getBigUint64(1, false), 0x20602800080017fn, "1, false"); +assert.sameValue(sample.getBigUint64(2, false), 0x602800080017f00n, "2, false"); +assert.sameValue(sample.getBigUint64(3, false), 0x2800080017f0001n, "3, false"); +assert.sameValue(sample.getBigUint64(4, false), 0x800080017f000102n, "4, false"); +assert.sameValue(sample.getBigUint64(5, false), 0x80017f00010280n, "5, false"); +assert.sameValue(sample.getBigUint64(6, false), 0x80017f000102807fn, "6, false"); +assert.sameValue(sample.getBigUint64(7, false), 0x17f000102807fffn, "7, false"); +assert.sameValue(sample.getBigUint64(8, false), 0x7f000102807fff80n, "8, false"); + +assert.sameValue(sample.getBigUint64(0, true), 0x180008002060227n, "0, true"); +assert.sameValue(sample.getBigUint64(1, true), 0x7f01800080020602n, "1, true"); +assert.sameValue(sample.getBigUint64(2, true), 0x7f018000800206n, "2, true"); +assert.sameValue(sample.getBigUint64(3, true), 0x1007f0180008002n, "3, true"); +assert.sameValue(sample.getBigUint64(4, true), 0x201007f01800080n, "4, true"); +assert.sameValue(sample.getBigUint64(5, true), 0x800201007F018000n, "5, true"); +assert.sameValue(sample.getBigUint64(6, true), 0x7f800201007f0180n, "6, true"); +assert.sameValue(sample.getBigUint64(7, true), 0xff7f800201007f01n, "7, true"); +assert.sameValue(sample.getBigUint64(8, true), 0x80ff7f800201007fn, "8, true"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/this-has-no-dataview-internal.js b/test/built-ins/DataView/prototype/getBigUint64/this-has-no-dataview-internal.js new file mode 100644 index 0000000000..c3eb1c2785 --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/this-has-no-dataview-internal.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Throws a TypeError if this does not have a [[DataView]] internal slot +features: [DataView, ArrayBuffer, Int8Array, BigInt, arrow-function] +---*/ + +var getBigUint64 = DataView.prototype.getBigUint64; + +assert.throws(TypeError, () => getBigUint64.call({}), "{}"); + +assert.throws(TypeError, () => getBigUint64.call([]), "[]"); + +var ab = new ArrayBuffer(1); +assert.throws(TypeError, () => getBigUint64.call(ab), "ArrayBuffer"); + +var ta = new Int8Array(); +assert.throws(TypeError, () => getBigUint64.call(ta), "TypedArray"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/this-is-not-object.js b/test/built-ins/DataView/prototype/getBigUint64/this-is-not-object.js new file mode 100644 index 0000000000..a60b3cca3e --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/this-is-not-object.js @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: Throws a TypeError if this is not Object +features: [DataView, ArrayBuffer, Symbol, BigInt, arrow-function] +---*/ + +var getBigUint64 = DataView.prototype.getBigUint64; + +assert.throws(TypeError, () => getBigUint64.call(undefined), + "undefined"); + +assert.throws(TypeError, () => getBigUint64.call(null), "null"); + +assert.throws(TypeError, () => getBigUint64.call(1), "1"); + +assert.throws(TypeError, () => getBigUint64.call("string"), "string"); + +assert.throws(TypeError, () => getBigUint64.call(true), "true"); + +assert.throws(TypeError, () => getBigUint64.call(false), "false"); + +var s = Symbol("1"); +assert.throws(TypeError, () => getBigUint64.call(s), "symbol"); diff --git a/test/built-ins/DataView/prototype/getBigUint64/to-boolean-littleendian.js b/test/built-ins/DataView/prototype/getBigUint64/to-boolean-littleendian.js new file mode 100644 index 0000000000..9063484abf --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/to-boolean-littleendian.js @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + Boolean littleEndian argument coerced in ToBoolean +includes: [typeCoercion.js] +features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt, Symbol, Symbol.toPrimitive] +---*/ + +var buffer = new ArrayBuffer(8); +var sample = new DataView(buffer, 0); + +sample.setUint8(7, 0xff); + +// False +assert.sameValue(sample.getBigUint64(0), 0xffn, "no argument"); +testCoercibleToBooleanFalse(function (x) { + assert.sameValue(sample.getBigUint64(0, x), 0xffn); +}); + +// True +testCoercibleToBooleanTrue(function (x) { + assert.sameValue(sample.getBigUint64(0, x), 0xff00000000000000n); +}); diff --git a/test/built-ins/DataView/prototype/getBigUint64/toindex-byteoffset.js b/test/built-ins/DataView/prototype/getBigUint64/toindex-byteoffset.js new file mode 100644 index 0000000000..b79b92b5ce --- /dev/null +++ b/test/built-ins/DataView/prototype/getBigUint64/toindex-byteoffset.js @@ -0,0 +1,42 @@ +// Copyright (C) 2017 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-dataview.prototype.getbiguint64 +description: > + ToIndex conversions on byteOffset +includes: [typeCoercion.js] +features: [DataView, ArrayBuffer, DataView.prototype.setUint8, BigInt, Symbol, Symbol.toPrimitive] +---*/ + +var buffer = new ArrayBuffer(12); +var sample = new DataView(buffer, 0); + +sample.setUint8(0, 0x27); +sample.setUint8(1, 0x02); +sample.setUint8(2, 0x06); +sample.setUint8(3, 0x02); +sample.setUint8(4, 0x80); +sample.setUint8(5, 0x00); +sample.setUint8(6, 0x80); +sample.setUint8(7, 0x01); +sample.setUint8(8, 0x7f); +sample.setUint8(9, 0x00); +sample.setUint8(10, 0x01); +sample.setUint8(11, 0x02); + +testCoercibleToIndexZero(function (x) { + assert.sameValue(sample.getBigUint64(x), 0x2702060280008001n); +}); + +testCoercibleToIndexOne(function (x) { + assert.sameValue(sample.getBigUint64(x), 0x20602800080017fn); +}); + +testCoercibleToIndexFromIndex(2, function (x) { + assert.sameValue(sample.getBigUint64(x), 0x602800080017F00n); +}); + +testCoercibleToIndexFromIndex(3, function (x) { + assert.sameValue(sample.getBigUint64(x), 0x2800080017F0001n); +});