summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6/typedarray-of.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/es6/typedarray-of.js')
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-of.js46
1 files changed, 25 insertions, 21 deletions
diff --git a/deps/v8/test/mjsunit/es6/typedarray-of.js b/deps/v8/test/mjsunit/es6/typedarray-of.js
index cf57615d12..a6df29a0dd 100644
--- a/deps/v8/test/mjsunit/es6/typedarray-of.js
+++ b/deps/v8/test/mjsunit/es6/typedarray-of.js
@@ -4,6 +4,8 @@
// Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/source/js/src/jit-test/tests/collections
+'use strict';
+
var typedArrayConstructors = [
Uint8Array,
Int8Array,
@@ -51,28 +53,29 @@ function TestTypedArrayOf(constructor) {
assertEquals(aux.length, a.length);
assertArrayEquals(aux, a);
- // %TypedArray%.of can be transplanted to other constructors.
+ // %TypedArray%.of can be called on subclasses of TypedArrays
var hits = 0;
- function Bag(length) {
- assertEquals(arguments.length, 1);
- assertEquals(length, 2);
- this.length = length;
- hits++;
+ class Bag extends constructor {
+ constructor(length) {
+ super(length);
+ assertEquals(arguments.length, 1);
+ assertEquals(length, 2);
+ hits++;
+ }
}
- Bag.of = constructor.of;
hits = 0;
- a = Bag.of("zero", "one");
+ a = Bag.of(5, 6);
assertEquals(1, hits);
assertEquals(2, a.length);
- assertArrayEquals(["zero", "one"], a);
+ assertArrayEquals([5, 6], a);
assertEquals(Bag.prototype, a.__proto__);
hits = 0;
- actual = constructor.of.call(Bag, "zero", "one");
+ var actual = constructor.of.call(Bag, 5, 6);
assertEquals(1, hits);
assertEquals(2, a.length);
- assertArrayEquals(["zero", "one"], a);
+ assertArrayEquals([5, 6], a);
assertEquals(Bag.prototype, a.__proto__);
// %TypedArray%.of does not trigger prototype setters.
@@ -90,26 +93,27 @@ function TestTypedArrayOf(constructor) {
// invoked.
// Setter on the newly created object.
- function Pack() {
- Object.defineProperty(this, "length", {
- set: function (v) { status = "fail"; }
- });
+ class Pack extends constructor {
+ constructor(length) {
+ super(length);
+ Object.defineProperty(this, "length", {
+ set: function (v) { status = "fail"; }
+ });
+ }
}
- Pack.of = constructor.of;
- var pack = Pack.of("wolves", "cards", "cigarettes", "lies");
+ var pack = Pack.of(5, 6, 7, 8);
assertEquals("pass", status);
// when the setter is on the new object's prototype
- function Bevy() {}
+ class Bevy extends constructor {}
Object.defineProperty(Bevy.prototype, "length", {
set: function (v) { status = "fail"; }
});
- Bevy.of = constructor.of;
- var bevy = Bevy.of("quail");
+ var bevy = Bevy.of(3);
assertEquals("pass", status);
// Check superficial features of %TypedArray%.of.
- var desc = Object.getOwnPropertyDescriptor(constructor, "of");
+ var desc = Object.getOwnPropertyDescriptor(constructor.__proto__, "of");
assertEquals(desc.configurable, false);
assertEquals(desc.enumerable, false);