| Index: test/mjsunit/es6/typedarray-of.js
|
| diff --git a/test/mjsunit/es6/typedarray-of.js b/test/mjsunit/es6/typedarray-of.js
|
| index 2ed550ca42e9f25b000a71245088d4fd3a1423fa..a6df29a0ddc858205a1afd78a9074b7ca2128502 100644
|
| --- a/test/mjsunit/es6/typedarray-of.js
|
| +++ b/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,22 +93,23 @@ 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.
|
|
|