Skip to content
Snippets Groups Projects
Commit 1bac79fb authored by André Bargull's avatar André Bargull
Browse files

Add basic surface tests for TypedArrays

parent 42edfd6e
No related branches found
No related tags found
No related merge requests found
Showing
with 400 additions and 0 deletions
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5.1
description: >
The initial value of Float32Array.BYTES_PER_ELEMENT is 4.
info: >
The value of TypedArray.BYTES_PER_ELEMENT is the Number value of the
Element Size value specified in Table 49 for TypedArray.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Float32Array.BYTES_PER_ELEMENT, 4);
verifyNotEnumerable(Float32Array, "BYTES_PER_ELEMENT");
verifyNotWritable(Float32Array, "BYTES_PER_ELEMENT");
verifyNotConfigurable(Float32Array, "BYTES_PER_ELEMENT");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.4
description: >
Float32Array is a constructor function.
---*/
assert.sameValue(typeof Float32Array, 'function', 'typeof Float32Array is "function"');
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5
description: >
Float32Array.length is 3.
info: >
Besides a length property (whose value is 3), [...].
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(Float32Array.length, 3);
verifyNotEnumerable(Float32Array, "length");
verifyNotWritable(Float32Array, "length");
verifyConfigurable(Float32Array, "length");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5
description: >
Float32Array.name is "Float32Array".
info: >
Each TypedArray constructor has a name property whose value is the
String value of the constructor name specified for it in Table 49.
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(Float32Array.name, "Float32Array");
verifyNotEnumerable(Float32Array, "name");
verifyNotWritable(Float32Array, "name");
verifyConfigurable(Float32Array, "name");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5
description: >
The prototype of Float32Array is %TypedArray%.
info: >
The value of the [[Prototype]] internal slot of each TypedArray constructor is the %TypedArray% intrinsic object (22.2.1).
includes: [testTypedArray.js]
---*/
assert.sameValue(Object.getPrototypeOf(Float32Array), TypedArray);
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5.2
description: >
The initial value of Float32Array.prototype is the Float32Array prototype object.
info: >
The initial value of TypedArray.prototype is the corresponding TypedArray prototype intrinsic object (22.2.6).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Float32Array.prototype, Object.getPrototypeOf(new Float32Array(0)));
verifyNotEnumerable(Float32Array, "prototype");
verifyNotWritable(Float32Array, "prototype");
verifyNotConfigurable(Float32Array, "prototype");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.6.1
description: >
The initial value of Float32Array.prototype.BYTES_PER_ELEMENT is 4.
info: >
The value of TypedArray.prototype.BYTES_PER_ELEMENT is the Number value
of the Element Size value specified in Table 49 for TypedArray.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Float32Array.prototype.BYTES_PER_ELEMENT, 4);
verifyNotEnumerable(Float32Array.prototype, "BYTES_PER_ELEMENT");
verifyNotWritable(Float32Array.prototype, "BYTES_PER_ELEMENT");
verifyNotConfigurable(Float32Array.prototype, "BYTES_PER_ELEMENT");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.6.2
description: >
The initial value of Float32Array.prototype.constructor is the Float32Array object.
info: >
The initial value of Float32Array.prototype.constructor is the intrinsic
object %Float32Array%.
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(Float32Array.prototype.constructor, Float32Array);
verifyNotEnumerable(Float32Array.prototype, "constructor");
verifyWritable(Float32Array.prototype, "constructor");
verifyConfigurable(Float32Array.prototype, "constructor");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.6
description: >
Float64Array.prototype is not a TypedArray instance object.
info: >
A TypedArray prototype object is an ordinary object. It does not have
a [[ViewedArrayBuffer]] or any other of the internal slots that are
specific to TypedArray instance objects.
---*/
assert.throws(TypeError, function() {
Float64Array.prototype.buffer;
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.6
description: >
The prototype of Float32Array.prototype is %TypedArrayPrototype%.
info: >
The value of the [[Prototype]] internal slot of a TypedArray prototype
object is the intrinsic object %TypedArrayPrototype% (22.2.3).
includes: [testTypedArray.js]
---*/
assert.sameValue(Object.getPrototypeOf(Float32Array.prototype), TypedArray.prototype);
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.4.1
description: >
Throws a TypeError if NewTarget is undefined.
info: >
TypedArray( ... argumentsList)
1. If NewTarget is undefined, throw a TypeError exception.
---*/
assert.throws(TypeError, function() {
Float32Array();
}, "Float32Array()");
assert.throws(TypeError, function() {
Float32Array(0);
}, "Float32Array(0)");
assert.throws(TypeError, function() {
Float32Array(new Float32Array(1));
}, "Float32Array(float32Array)");
assert.throws(TypeError, function() {
Float32Array([]);
}, "Float32Array(array)");
assert.throws(TypeError, function() {
Float32Array(new ArrayBuffer(8));
}, "Float32Array(arrayBuffer)");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5.1
description: >
The initial value of Float64Array.BYTES_PER_ELEMENT is 8.
info: >
The value of TypedArray.BYTES_PER_ELEMENT is the Number value of the
Element Size value specified in Table 49 for TypedArray.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Float64Array.BYTES_PER_ELEMENT, 8);
verifyNotEnumerable(Float64Array, "BYTES_PER_ELEMENT");
verifyNotWritable(Float64Array, "BYTES_PER_ELEMENT");
verifyNotConfigurable(Float64Array, "BYTES_PER_ELEMENT");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.4
description: >
Float64Array is a constructor function.
---*/
assert.sameValue(typeof Float64Array, 'function', 'typeof Float64Array is "function"');
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5
description: >
Float64Array.length is 3.
info: >
Besides a length property (whose value is 3), [...].
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(Float64Array.length, 3);
verifyNotEnumerable(Float64Array, "length");
verifyNotWritable(Float64Array, "length");
verifyConfigurable(Float64Array, "length");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5
description: >
Float64Array.name is "Float64Array".
info: >
Each TypedArray constructor has a name property whose value is the
String value of the constructor name specified for it in Table 49.
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(Float64Array.name, "Float64Array");
verifyNotEnumerable(Float64Array, "name");
verifyNotWritable(Float64Array, "name");
verifyConfigurable(Float64Array, "name");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5
description: >
The prototype of Float64Array is %TypedArray%.
info: >
The value of the [[Prototype]] internal slot of each TypedArray constructor is the %TypedArray% intrinsic object (22.2.1).
includes: [testTypedArray.js]
---*/
assert.sameValue(Object.getPrototypeOf(Float64Array), TypedArray);
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.5.2
description: >
The initial value of Float64Array.prototype is the Float64Array prototype object.
info: >
The initial value of TypedArray.prototype is the corresponding TypedArray prototype intrinsic object (22.2.6).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Float64Array.prototype, Object.getPrototypeOf(new Float64Array(0)));
verifyNotEnumerable(Float64Array, "prototype");
verifyNotWritable(Float64Array, "prototype");
verifyNotConfigurable(Float64Array, "prototype");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.6.1
description: >
The initial value of Float64Array.prototype.BYTES_PER_ELEMENT is 8.
info: >
The value of TypedArray.prototype.BYTES_PER_ELEMENT is the Number value
of the Element Size value specified in Table 49 for TypedArray.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
---*/
assert.sameValue(Float64Array.prototype.BYTES_PER_ELEMENT, 8);
verifyNotEnumerable(Float64Array.prototype, "BYTES_PER_ELEMENT");
verifyNotWritable(Float64Array.prototype, "BYTES_PER_ELEMENT");
verifyNotConfigurable(Float64Array.prototype, "BYTES_PER_ELEMENT");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.6.2
description: >
The initial value of Float64Array.prototype.constructor is the Float64Array object.
info: >
The initial value of Float64Array.prototype.constructor is the intrinsic
object %Float64Array%.
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(Float64Array.prototype.constructor, Float64Array);
verifyNotEnumerable(Float64Array.prototype, "constructor");
verifyWritable(Float64Array.prototype, "constructor");
verifyConfigurable(Float64Array.prototype, "constructor");
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.2.6
description: >
Float64Array.prototype is not a TypedArray instance object.
info: >
A TypedArray prototype object is an ordinary object. It does not have
a [[ViewedArrayBuffer]] or any other of the internal slots that are
specific to TypedArray instance objects.
---*/
assert.throws(TypeError, function() {
Float64Array.prototype.buffer;
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment