diff options
Diffstat (limited to 'test/built-ins/TypedArray/prototype/length/BigInt')
9 files changed, 270 insertions, 0 deletions
diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js b/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js new file mode 100644 index 000000000..31ee55484 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/detached-buffer.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.18 get %TypedArray%.prototype.length + + ... + 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 6. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var sample = new TA(42); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.length, 0); +}); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-accessor.js b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-accessor.js new file mode 100644 index 000000000..d67d24370 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-accessor.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + Requires this value to have a [[ViewedArrayBuffer]] internal slot +info: | + 22.2.3.17 get %TypedArray%.prototype.length + + 1. Let O be the this value. + ... + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; + +assert.throws(TypeError, function() { + TypedArrayPrototype.length; +}); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-func.js b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-func.js new file mode 100644 index 000000000..100bf4c55 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/invoked-as-func.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.17 get %TypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, 'length' +).get; + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/length.js b/test/built-ins/TypedArray/prototype/length/BigInt/length.js new file mode 100644 index 000000000..832fba4a9 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + get %TypedArray%.prototype.length.length is 0. +info: | + get %TypedArray%.prototype.length + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js, testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length"); + +assert.sameValue(desc.get.length, 0); + +verifyNotEnumerable(desc.get, "length"); +verifyNotWritable(desc.get, "length"); +verifyConfigurable(desc.get, "length"); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/name.js b/test/built-ins/TypedArray/prototype/length/BigInt/name.js new file mode 100644 index 000000000..f7f29be88 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + get %TypedArray%.prototype.length.name is "get length". +info: | + get %TypedArray%.prototype.length + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js, testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(TypedArray.prototype, "length"); + +assert.sameValue(desc.get.name, "get length"); + +verifyNotEnumerable(desc.get, "name"); +verifyNotWritable(desc.get, "name"); +verifyConfigurable(desc.get, "name"); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/prop-desc.js b/test/built-ins/TypedArray/prototype/length/BigInt/prop-desc.js new file mode 100644 index 000000000..2afd62048 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + "length" property of TypedArrayPrototype +info: | + %TypedArray%.prototype.length is an accessor property whose set accessor + function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "length"); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(TypedArrayPrototype, "length"); +verifyConfigurable(TypedArrayPrototype, "length"); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/return-length.js b/test/built-ins/TypedArray/prototype/length/BigInt/return-length.js new file mode 100644 index 000000000..419acd0f6 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/return-length.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + Return value from the [[ArrayLength]] internal slot +info: | + 22.2.3.18 get %TypedArray%.prototype.length + + ... + 6. Let length be the value of O's [[ArrayLength]] internal slot. + 7. Return length. + + --- + + The current tests on `prop-desc.js` and `length.js` already assert `length` is + not a dynamic property as in regular arrays. +includes: [testBigIntTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.length, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.length, 42); +}); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/this-has-no-typedarrayname-internal.js b/test/built-ins/TypedArray/prototype/length/BigInt/this-has-no-typedarrayname-internal.js new file mode 100644 index 000000000..1dd1d7696 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/this-has-no-typedarrayname-internal.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + Throws a TypeError exception when `this` does not have a [[TypedArrayName]] + internal slot +info: | + 22.2.3.18 get %TypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, DataView, TypedArray] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "length" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); + +var dv = new DataView(new ArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/built-ins/TypedArray/prototype/length/BigInt/this-is-not-object.js b/test/built-ins/TypedArray/prototype/length/BigInt/this-is-not-object.js new file mode 100644 index 000000000..663a6402b --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/BigInt/this-is-not-object.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.18 get %TypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "length" +).get; + + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "number"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "symbol"); |