Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1829)

Unified Diff: test/mjsunit/es6/typedarray-of.js

Issue 1574903004: TypedArray and ArrayBuffer support for @@species (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Upload tests and make some code more clear Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/es6/legacy-subclassing.js ('k') | test/mjsunit/harmony/arraybuffer-species.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « test/mjsunit/es6/legacy-subclassing.js ('k') | test/mjsunit/harmony/arraybuffer-species.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698