summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6
diff options
context:
space:
mode:
authorAli Ijaz Sheikh <ofrobots@google.com>2015-08-23 06:09:40 -0700
committerRod Vagg <rod@vagg.org>2015-09-06 21:38:01 +1000
commit9fddd83cf9adf505bce2e2373881df0c4d41b261 (patch)
tree4272ce14c10fea496af2e78fc6debb187d613451 /deps/v8/test/mjsunit/es6
parent46b7d151674d138e7ea4342d5f3ada1208b87ff2 (diff)
downloadnode-new-9fddd83cf9adf505bce2e2373881df0c4d41b261.tar.gz
deps: upgrade V8 to 4.5.103.24
Upgrade to the latest branch-head for V8 4.5. For the full commit log see https://github.com/v8/v8-git-mirror/commits/4.5.103.24 PR-URL: https://github.com/nodejs/node/pull/2509 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/test/mjsunit/es6')
-rw-r--r--deps/v8/test/mjsunit/es6/arguments-iterator.js5
-rw-r--r--deps/v8/test/mjsunit/es6/block-for.js27
-rw-r--r--deps/v8/test/mjsunit/es6/block-non-strict-errors.js2
-rw-r--r--deps/v8/test/mjsunit/es6/class-property-name-eval-arguments.js79
-rw-r--r--deps/v8/test/mjsunit/es6/classes-experimental.js337
-rw-r--r--deps/v8/test/mjsunit/es6/classes-lazy-parsing.js34
-rw-r--r--deps/v8/test/mjsunit/es6/classes-maps.js68
-rw-r--r--deps/v8/test/mjsunit/es6/classes-subclass-arrays.js149
-rw-r--r--deps/v8/test/mjsunit/es6/classes.js948
-rw-r--r--deps/v8/test/mjsunit/es6/debug-blockscopes.js10
-rw-r--r--deps/v8/test/mjsunit/es6/debug-evaluate-blockscopes.js8
-rw-r--r--deps/v8/test/mjsunit/es6/debug-step-into-class-extends.js42
-rw-r--r--deps/v8/test/mjsunit/es6/debug-step-into-constructor.js114
-rw-r--r--deps/v8/test/mjsunit/es6/debug-stepnext-for.js33
-rw-r--r--deps/v8/test/mjsunit/es6/generators-relocation.js6
-rw-r--r--deps/v8/test/mjsunit/es6/generators-runtime.js33
-rw-r--r--deps/v8/test/mjsunit/es6/indexed-integer-exotics.js21
-rw-r--r--deps/v8/test/mjsunit/es6/iterator-prototype.js58
-rw-r--r--deps/v8/test/mjsunit/es6/method-name-eval-arguments.js33
-rw-r--r--deps/v8/test/mjsunit/es6/object-literals-method.js314
-rw-r--r--deps/v8/test/mjsunit/es6/object-literals-property-shorthand.js71
-rw-r--r--deps/v8/test/mjsunit/es6/promise-internal-setter.js17
-rw-r--r--deps/v8/test/mjsunit/es6/regress/regress-2506.js16
-rw-r--r--deps/v8/test/mjsunit/es6/regress/regress-3750.js7
-rw-r--r--deps/v8/test/mjsunit/es6/regress/regress-4097.js37
-rw-r--r--deps/v8/test/mjsunit/es6/regress/regress-455141.js15
-rw-r--r--deps/v8/test/mjsunit/es6/string-html.js42
-rw-r--r--deps/v8/test/mjsunit/es6/templates.js20
-rw-r--r--deps/v8/test/mjsunit/es6/toMethod.js106
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-copywithin.js173
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-every.js152
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-fill.js45
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-find.js187
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-findindex.js187
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-foreach.js155
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-from.js121
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-indexing.js71
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-iteration.js194
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-of.js133
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-proto.js42
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-reduce.js250
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-reverse.js54
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-slice.js71
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-sort.js55
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-tostring.js86
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray.js758
46 files changed, 5319 insertions, 67 deletions
diff --git a/deps/v8/test/mjsunit/es6/arguments-iterator.js b/deps/v8/test/mjsunit/es6/arguments-iterator.js
index 32d4b11ee1..cf1e1f97ca 100644
--- a/deps/v8/test/mjsunit/es6/arguments-iterator.js
+++ b/deps/v8/test/mjsunit/es6/arguments-iterator.js
@@ -219,10 +219,7 @@ function TestArgumentsAsProto() {
assertSame([][Symbol.iterator], o[Symbol.iterator]);
assertFalse(o.hasOwnProperty(Symbol.iterator));
assertSame([][Symbol.iterator], o[Symbol.iterator]);
- // This should throw, but currently it doesn't, because
- // ExecutableAccessorInfo callbacks don't see the current strict mode.
- // See note in accessors.cc:SetPropertyOnInstanceIfInherited.
- o[Symbol.iterator] = 10;
+ assertThrows(function () { o[Symbol.iterator] = 10 });
assertFalse(o.hasOwnProperty(Symbol.iterator));
assertEquals([][Symbol.iterator], o[Symbol.iterator]);
assertSame([][Symbol.iterator], arguments[Symbol.iterator]);
diff --git a/deps/v8/test/mjsunit/es6/block-for.js b/deps/v8/test/mjsunit/es6/block-for.js
index b91af0116c..420c41e610 100644
--- a/deps/v8/test/mjsunit/es6/block-for.js
+++ b/deps/v8/test/mjsunit/es6/block-for.js
@@ -158,7 +158,7 @@ closure_in_for_next();
// In a for-in statement the iteration variable is fresh
-// for earch iteration.
+// for each iteration.
function closures3(x) {
let a = [];
for (let p in x) {
@@ -171,3 +171,28 @@ function closures3(x) {
}
}
closures3({a : [0], b : 1, c : {v : 1}, get d() {}, set e(x) {}});
+
+// Check normal for statement completion values.
+assertEquals(1, eval("for (let i = 0; i < 10; i++) { 1; }"));
+assertEquals(9, eval("for (let i = 0; i < 10; i++) { i; }"));
+assertEquals(undefined, eval("for (let i = 0; false;) { }"));
+assertEquals(undefined, eval("for (const i = 0; false;) { }"));
+assertEquals(undefined, eval("for (let i = 0; i < 10; i++) { }"));
+assertEquals(undefined, eval("for (let i = 0; false;) { i; }"));
+assertEquals(undefined, eval("for (const i = 0; false;) { i; }"));
+assertEquals(undefined, eval("for (let i = 0; true;) { break; }"));
+assertEquals(undefined, eval("for (const i = 0; true;) { break; }"));
+assertEquals(undefined, eval("for (let i = 0; i < 10; i++) { continue; }"));
+assertEquals(undefined, eval("for (let i = 0; true;) { break; i; }"));
+assertEquals(undefined, eval("for (const i = 0; true;) { break; i; }"));
+assertEquals(undefined, eval("for (let i = 0; i < 10; i++) { continue; i; }"));
+assertEquals(0, eval("for (let i = 0; true;) { i; break; }"));
+assertEquals(0, eval("for (const i = 0; true;) { i; break; }"));
+assertEquals(9, eval("for (let i = 0; i < 10; i++) { i; continue; }"));
+assertEquals(3, eval("for (let i = 0; true; i++) { i; if (i >= 3) break; }"));
+assertEquals(2, eval("for (let i = 0; true; i++) { if (i >= 3) break; i; }"));
+assertEquals(
+ 2, eval("for (let i = 0; i < 10; i++) { if (i >= 3) continue; i; }"));
+assertEquals(undefined, eval("foo: for (let i = 0; true;) { break foo; }"));
+assertEquals(undefined, eval("foo: for (const i = 0; true;) { break foo; }"));
+assertEquals(3, eval("foo: for (let i = 3; true;) { i; break foo; }"));
diff --git a/deps/v8/test/mjsunit/es6/block-non-strict-errors.js b/deps/v8/test/mjsunit/es6/block-non-strict-errors.js
index 48cac21141..50d5f22cf1 100644
--- a/deps/v8/test/mjsunit/es6/block-non-strict-errors.js
+++ b/deps/v8/test/mjsunit/es6/block-non-strict-errors.js
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-classes
-
function CheckError(source) {
var exception = null;
try {
diff --git a/deps/v8/test/mjsunit/es6/class-property-name-eval-arguments.js b/deps/v8/test/mjsunit/es6/class-property-name-eval-arguments.js
new file mode 100644
index 0000000000..72ff60fd3e
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/class-property-name-eval-arguments.js
@@ -0,0 +1,79 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-sloppy
+
+
+(function Method() {
+ class C {
+ eval() {
+ return 1;
+ }
+ arguments() {
+ return 2;
+ }
+ static eval() {
+ return 3;
+ }
+ static arguments() {
+ return 4;
+ }
+ };
+
+ assertEquals(1, new C().eval());
+ assertEquals(2, new C().arguments());
+ assertEquals(3, C.eval());
+ assertEquals(4, C.arguments());
+})();
+
+
+(function Getters() {
+ class C {
+ get eval() {
+ return 1;
+ }
+ get arguments() {
+ return 2;
+ }
+ static get eval() {
+ return 3;
+ }
+ static get arguments() {
+ return 4;
+ }
+ };
+
+ assertEquals(1, new C().eval);
+ assertEquals(2, new C().arguments);
+ assertEquals(3, C.eval);
+ assertEquals(4, C.arguments);
+})();
+
+
+(function Setters() {
+ var x = 0;
+ class C {
+ set eval(v) {
+ x = v;
+ }
+ set arguments(v) {
+ x = v;
+ }
+ static set eval(v) {
+ x = v;
+ }
+ static set arguments(v) {
+ x = v;
+ }
+ };
+
+ new C().eval = 1;
+ assertEquals(1, x);
+ new C().arguments = 2;
+ assertEquals(2, x);
+ C.eval = 3;
+ assertEquals(3, x);
+ C.arguments = 4;
+ assertEquals(4, x);
+})();
diff --git a/deps/v8/test/mjsunit/es6/classes-experimental.js b/deps/v8/test/mjsunit/es6/classes-experimental.js
new file mode 100644
index 0000000000..4607a25957
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/classes-experimental.js
@@ -0,0 +1,337 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+(function TestArgumentsAccess() {
+ class Base {
+ constructor() {
+ assertEquals(2, arguments.length);
+ assertEquals(1, arguments[0]);
+ assertEquals(2, arguments[1]);
+ }
+ }
+
+ let b = new Base(1,2);
+
+ class Subclass extends Base {
+ constructor() {
+ assertEquals(2, arguments.length);
+ assertEquals(3, arguments[0]);
+ assertEquals(4, arguments[1]);
+ super(1,2);
+ }
+ }
+
+ let s = new Subclass(3,4);
+ assertEquals(0, Subclass.length);
+
+ class Subclass2 extends Base {
+ constructor(x,y) {
+ assertEquals(2, arguments.length);
+ assertEquals(3, arguments[0]);
+ assertEquals(4, arguments[1]);
+ super(1,2);
+ }
+ }
+
+ let s2 = new Subclass2(3,4);
+ assertEquals(2, Subclass2.length);
+}());
+
+(function TestThisAccessRestriction() {
+ class Base {
+ constructor(a, b) {
+ let o = new Object();
+ o.prp = a + b;
+ return o;
+ }
+ }
+
+ class Subclass extends Base {
+ constructor(a, b) {
+ var exn;
+ try {
+ this.prp1 = 3;
+ } catch (e) {
+ exn = e;
+ }
+ assertTrue(exn instanceof ReferenceError);
+ super(a, b);
+ assertSame(a + b, this.prp);
+ assertSame(undefined, this.prp1);
+ assertFalse(this.hasOwnProperty("prp1"));
+ return this;
+ }
+ }
+
+ let b = new Base(1, 2);
+ assertSame(3, b.prp);
+
+
+ let s = new Subclass(2, -1);
+ assertSame(1, s.prp);
+ assertSame(undefined, s.prp1);
+ assertFalse(s.hasOwnProperty("prp1"));
+
+ class Subclass2 extends Base {
+ constructor(x) {
+ super(1,2);
+
+ if (x < 0) return;
+
+ let called = false;
+ function tmp() { called = true; return 3; }
+ var exn = null;
+ try {
+ super(tmp(),4);
+ } catch (e) { exn = e; }
+ assertTrue(exn instanceof ReferenceError);
+ assertTrue(called);
+ }
+ }
+
+ var s2 = new Subclass2(1);
+ assertSame(3, s2.prp);
+
+ var s3 = new Subclass2(-1);
+ assertSame(3, s3.prp);
+
+ assertThrows(function() { Subclass.call(new Object(), 1, 2); }, TypeError);
+ assertThrows(function() { Base.call(new Object(), 1, 2); }, TypeError);
+
+ class BadSubclass extends Base {
+ constructor() {}
+ }
+
+ assertThrows(function() { new BadSubclass(); }, ReferenceError);
+}());
+
+(function TestThisCheckOrdering() {
+ let baseCalled = 0;
+ class Base {
+ constructor() { baseCalled++ }
+ }
+
+ let fCalled = 0;
+ function f() { fCalled++; return 3; }
+
+ class Subclass1 extends Base {
+ constructor() {
+ baseCalled = 0;
+ super();
+ assertEquals(1, baseCalled);
+ let obj = this;
+
+ let exn = null;
+ baseCalled = 0;
+ fCalled = 0;
+ try {
+ super(f());
+ } catch (e) { exn = e; }
+ assertTrue(exn instanceof ReferenceError);
+ assertEquals(1, fCalled);
+ assertEquals(1, baseCalled);
+ assertSame(obj, this);
+
+ exn = null;
+ baseCalled = 0;
+ fCalled = 0;
+ try {
+ super(super(), f());
+ } catch (e) { exn = e; }
+ assertTrue(exn instanceof ReferenceError);
+ assertEquals(0, fCalled);
+ assertEquals(1, baseCalled);
+ assertSame(obj, this);
+
+ exn = null;
+ baseCalled = 0;
+ fCalled = 0;
+ try {
+ super(f(), super());
+ } catch (e) { exn = e; }
+ assertTrue(exn instanceof ReferenceError);
+ assertEquals(1, fCalled);
+ assertEquals(1, baseCalled);
+ assertSame(obj, this);
+ }
+ }
+
+ new Subclass1();
+}());
+
+
+(function TestPrototypeWiring() {
+ class Base {
+ constructor(x) {
+ this.foobar = x;
+ }
+ }
+
+ class Subclass extends Base {
+ constructor(x) {
+ super(x);
+ }
+ }
+
+ let s = new Subclass(1);
+ assertSame(1, s.foobar);
+ assertSame(Subclass.prototype, s.__proto__);
+
+ let s1 = new Subclass(1, 2);
+ assertSame(1, s1.foobar);
+ assertTrue(s1.__proto__ === Subclass.prototype);
+
+ let s2 = new Subclass();
+ assertSame(undefined, s2.foobar);
+ assertSame(Subclass.prototype, s2.__proto__);
+ assertThrows(function() { Subclass(1); }, TypeError);
+ assertThrows(function() { Subclass(1,2,3,4); }, TypeError);
+
+ class Subclass2 extends Subclass {
+ constructor() {
+ super(5, 6, 7);
+ }
+ }
+
+ let ss2 = new Subclass2();
+ assertSame(5, ss2.foobar);
+ assertSame(Subclass2.prototype, ss2.__proto__);
+
+ class Subclass3 extends Base {
+ constructor(x,y) {
+ super(x + y);
+ }
+ }
+
+ let ss3 = new Subclass3(27,42-27);
+ assertSame(42, ss3.foobar);
+ assertSame(Subclass3.prototype, ss3.__proto__);
+}());
+
+(function TestSublclassingBuiltins() {
+ class ExtendedUint8Array extends Uint8Array {
+ constructor() {
+ super(10);
+ this[0] = 255;
+ this[1] = 0xFFA;
+ }
+ }
+
+ var eua = new ExtendedUint8Array();
+ assertEquals(10, eua.length);
+ assertEquals(10, eua.byteLength);
+ assertEquals(0xFF, eua[0]);
+ assertEquals(0xFA, eua[1]);
+ assertSame(ExtendedUint8Array.prototype, eua.__proto__);
+ assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua));
+}());
+
+(function TestSubclassingNull() {
+ let N = null;
+
+ class Foo extends N {
+ constructor(x,y) {
+ assertSame(1, x);
+ assertSame(2, y);
+ return {};
+ }
+ }
+
+ new Foo(1,2);
+}());
+
+(function TestSubclassBinding() {
+ class Base {
+ constructor(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+
+ let obj = {};
+ class Subclass extends Base {
+ constructor(x,y) {
+ super(x,y);
+ assertTrue(this !== obj);
+ }
+ }
+
+ let f = Subclass.bind(obj);
+ assertThrows(function () { f(1, 2); }, TypeError);
+ let s = new f(1, 2);
+ assertSame(1, s.x);
+ assertSame(2, s.y);
+ assertSame(Subclass.prototype, s.__proto__);
+
+ let s1 = new f(1);
+ assertSame(1, s1.x);
+ assertSame(undefined, s1.y);
+ assertSame(Subclass.prototype, s1.__proto__);
+
+ let g = Subclass.bind(obj, 1);
+ assertThrows(function () { g(8); }, TypeError);
+ let s2 = new g(8);
+ assertSame(1, s2.x);
+ assertSame(8, s2.y);
+ assertSame(Subclass.prototype, s.__proto__);
+}());
+
+
+(function TestDefaultConstructor() {
+ class Base1 { }
+ assertThrows(function() { Base1(); }, TypeError);
+
+ class Subclass1 extends Base1 { }
+
+ assertThrows(function() { Subclass1(); }, TypeError);
+
+ let s1 = new Subclass1();
+ assertSame(s1.__proto__, Subclass1.prototype);
+
+ class Base2 {
+ constructor(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+
+ class Subclass2 extends Base2 {};
+
+ let s2 = new Subclass2(1, 2);
+
+ assertSame(s2.__proto__, Subclass2.prototype);
+ assertSame(1, s2.x);
+ assertSame(2, s2.y);
+
+ let f = Subclass2.bind({}, 3, 4);
+ let s2prime = new f();
+ assertSame(s2prime.__proto__, Subclass2.prototype);
+ assertSame(3, s2prime.x);
+ assertSame(4, s2prime.y);
+
+ let obj = {};
+ class Base3 {
+ constructor() {
+ return obj;
+ }
+ }
+
+ class Subclass3 extends Base3 {};
+
+ let s3 = new Subclass3();
+ assertSame(obj, s3);
+
+ class ExtendedUint8Array extends Uint8Array { }
+
+ var eua = new ExtendedUint8Array(10);
+ assertEquals(10, eua.length);
+ assertEquals(10, eua.byteLength);
+ eua[0] = 0xFF;
+ eua[1] = 0xFFA;
+ assertEquals(0xFF, eua[0]);
+ assertEquals(0xFA, eua[1]);
+ assertSame(ExtendedUint8Array.prototype, eua.__proto__);
+ assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua));
+}());
diff --git a/deps/v8/test/mjsunit/es6/classes-lazy-parsing.js b/deps/v8/test/mjsunit/es6/classes-lazy-parsing.js
new file mode 100644
index 0000000000..c1bf31da2d
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/classes-lazy-parsing.js
@@ -0,0 +1,34 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --min-preparse-length=0
+
+'use strict';
+
+class Base {
+ m() {
+ return 42;
+ }
+}
+
+class Derived extends Base {
+ m() {
+ return super.m();
+ }
+ evalM() {
+ return eval('super.m()');
+ }
+}
+
+assertEquals(42, new Derived().m());
+assertEquals(42, new Derived().evalM());
+
+
+class LazyDerived extends Base {
+ constructor() {
+ eval('super()');
+ }
+}
+assertInstanceof(new LazyDerived(), LazyDerived);
+assertInstanceof(new LazyDerived(), Base);
diff --git a/deps/v8/test/mjsunit/es6/classes-maps.js b/deps/v8/test/mjsunit/es6/classes-maps.js
new file mode 100644
index 0000000000..e519676aa6
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/classes-maps.js
@@ -0,0 +1,68 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --allow-natives-syntax
+'use strict';
+
+(function TestMaps() {
+ class Base {}
+ class Derived extends Base {}
+
+ let d1 = new Derived();
+ let d2 = new Derived();
+
+ assertTrue(%HaveSameMap(d1, d2));
+}());
+
+
+(function TestProtoModificationArray() {
+ let called = 0;
+ function F() {
+ called++;
+ assertFalse(Array.isArray(this));
+ }
+ class Derived extends Array {}
+ assertSame(Derived.__proto__, Array);
+
+ let d1 = new Derived();
+ assertTrue(Array.isArray(d1));
+
+ Derived.__proto__ = F;
+ called = 0;
+ let d2 = new Derived();
+ assertSame(1, called);
+ assertFalse(Array.isArray(d2));
+
+ assertFalse(%HaveSameMap(d1, d2));
+}());
+
+
+(function TestProtoModification() {
+ let called = 0;
+ function F() {
+ called++;
+ let exn = null;
+ try {
+ this.byteLength;
+ } catch (e) {
+ exn = e;
+ }
+ assertTrue(exn instanceof TypeError);
+ }
+ class Derived extends Uint8Array {
+ constructor() { super(10); }
+ }
+ assertSame(Derived.__proto__, Uint8Array);
+
+ let d1 = new Derived();
+ assertSame(10, d1.byteLength);
+
+ Derived.__proto__ = F;
+ called = 0;
+ let d2 = new Derived();
+ assertSame(1, called);
+ assertThrows(function() { d2.byteLength; }, TypeError);
+
+ assertFalse(%HaveSameMap(d1, d2));
+}());
diff --git a/deps/v8/test/mjsunit/es6/classes-subclass-arrays.js b/deps/v8/test/mjsunit/es6/classes-subclass-arrays.js
new file mode 100644
index 0000000000..74feb6aeb4
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/classes-subclass-arrays.js
@@ -0,0 +1,149 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+(function TestDefaultConstructor() {
+ class Stack extends Array { }
+ {
+ let s1 = new Stack();
+ assertSame(Stack.prototype, s1.__proto__);
+ assertTrue(Array.isArray(s1));
+ assertSame(0, s1.length);
+ s1[0] = 'xyz';
+ assertSame(1, s1.length);
+ assertSame('xyz', s1[0]);
+ s1.push(42);
+ assertSame(2, s1.length);
+ assertSame('xyz', s1[0]);
+ assertSame(42, s1[1]);
+ }
+
+ {
+ let s2 = new Stack(10);
+ assertSame(Stack.prototype, s2.__proto__);
+ assertTrue(Array.isArray(s2));
+ assertSame(10, s2.length);
+ assertSame(undefined, s2[0]);
+ }
+
+ {
+ let a = [1,2,3];
+ let s3 = new Stack(a);
+ assertSame(Stack.prototype, s3.__proto__);
+ assertTrue(Array.isArray(s3));
+ assertSame(1, s3.length);
+ assertSame(a, s3[0]);
+ }
+
+ {
+ let s4 = new Stack(1, 2, 3);
+ assertSame(Stack.prototype, s4.__proto__);
+ assertTrue(Array.isArray(s4));
+ assertSame(3, s4.length);
+ assertSame(1, s4[0]);
+ assertSame(2, s4[1]);
+ assertSame(3, s4[2]);
+ }
+
+ {
+ let s5 = new Stack(undefined, undefined, undefined);
+ assertSame(Stack.prototype, s5.__proto__);
+ assertTrue(Array.isArray(s5));
+ assertSame(3, s5.length);
+ assertSame(undefined, s5[0]);
+ assertSame(undefined, s5[1]);
+ assertSame(undefined, s5[2]);
+ }
+}());
+
+
+(function TestEmptyArgsSuper() {
+ class Stack extends Array {
+ constructor() { super(); }
+ }
+ let s1 = new Stack();
+ assertSame(Stack.prototype, s1.__proto__);
+ assertTrue(Array.isArray(s1));
+ assertSame(0, s1.length);
+ s1[0] = 'xyz';
+ assertSame(1, s1.length);
+ assertSame('xyz', s1[0]);
+ s1.push(42);
+ assertSame(2, s1.length);
+ assertSame('xyz', s1[0]);
+ assertSame(42, s1[1]);
+}());
+
+
+(function TestOneArgSuper() {
+ class Stack extends Array {
+ constructor(x) {
+ super(x);
+ }
+ }
+
+ {
+ let s2 = new Stack(10, 'ignored arg');
+ assertSame(Stack.prototype, s2.__proto__);
+ assertTrue(Array.isArray(s2));
+ assertSame(10, s2.length);
+ assertSame(undefined, s2[0]);
+ }
+
+ {
+ let a = [1,2,3];
+ let s3 = new Stack(a, 'ignored arg');
+ assertSame(Stack.prototype, s3.__proto__);
+ assertTrue(Array.isArray(s3));
+ assertSame(1, s3.length);
+ assertSame(a, s3[0]);
+ }
+}());
+
+
+(function TestMultipleArgsSuper() {
+ class Stack extends Array {
+ constructor(x, y, z) {
+ super(x, y, z);
+ }
+ }
+ {
+ let s4 = new Stack(1, 2, 3, 4, 5);
+ assertSame(Stack.prototype, s4.__proto__);
+ assertTrue(Array.isArray(s4));
+ assertSame(3, s4.length);
+ assertSame(1, s4[0]);
+ assertSame(2, s4[1]);
+ assertSame(3, s4[2]);
+ }
+
+ {
+ let s5 = new Stack(undefined);
+ assertSame(Stack.prototype, s5.__proto__);
+ assertTrue(Array.isArray(s5));
+ assertTrue(s5.__proto__ == Stack.prototype);
+ assertSame(3, s5.length);
+ assertSame(undefined, s5[0]);
+ assertSame(undefined, s5[1]);
+ assertSame(undefined, s5[2]);
+ }
+}());
+
+
+(function TestArrayConcat() {
+ class Stack extends Array { }
+ let s1 = new Stack(1,2,3);
+
+ assertArrayEquals([1,2,3,4,5,6], s1.concat([4,5,6]));
+ assertArrayEquals([4,5,6,1,2,3], [4,5,6].concat(s1));
+}());
+
+
+(function TestJSONStringify() {
+ class Stack extends Array { }
+
+ let s1 = new Stack(1,2,3);
+ assertSame("[1,2,3]", JSON.stringify(s1));
+}());
diff --git a/deps/v8/test/mjsunit/es6/classes.js b/deps/v8/test/mjsunit/es6/classes.js
new file mode 100644
index 0000000000..a1420be1c2
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/classes.js
@@ -0,0 +1,948 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-sloppy
+
+(function TestBasics() {
+ var C = class C {}
+ assertEquals(typeof C, 'function');
+ assertEquals(C.__proto__, Function.prototype);
+ assertEquals(Object.prototype, Object.getPrototypeOf(C.prototype));
+ assertEquals(Function.prototype, Object.getPrototypeOf(C));
+ assertEquals('C', C.name);
+
+ class D {}
+ assertEquals(typeof D, 'function');
+ assertEquals(D.__proto__, Function.prototype);
+ assertEquals(Object.prototype, Object.getPrototypeOf(D.prototype));
+ assertEquals(Function.prototype, Object.getPrototypeOf(D));
+ assertEquals('D', D.name);
+
+ class D2 { constructor() {} }
+ assertEquals('D2', D2.name);
+
+ // TODO(arv): The logic for the name of anonymous functions in ES6 requires
+ // the below to be 'E';
+ var E = class {}
+ assertEquals('', E.name); // Should be 'E'.
+
+ var F = class { constructor() {} };
+ assertEquals('', F.name); // Should be 'F'.
+})();
+
+
+(function TestBasicsExtends() {
+ class C extends null {}
+ assertEquals(typeof C, 'function');
+ assertEquals(C.__proto__, Function.prototype);
+ assertEquals(null, Object.getPrototypeOf(C.prototype));
+
+ class D extends C {}
+ assertEquals(typeof D, 'function');
+ assertEquals(D.__proto__, C);
+ assertEquals(C.prototype, Object.getPrototypeOf(D.prototype));
+})();
+
+
+(function TestSideEffectInExtends() {
+ var calls = 0;
+ class C {}
+ class D extends (calls++, C) {}
+ assertEquals(1, calls);
+ assertEquals(typeof D, 'function');
+ assertEquals(D.__proto__, C);
+ assertEquals(C.prototype, Object.getPrototypeOf(D.prototype));
+})();
+
+
+(function TestInvalidExtends() {
+ assertThrows(function() {
+ class C extends 42 {}
+ }, TypeError);
+
+ assertThrows(function() {
+ // Function but its .prototype is not null or a function.
+ class C extends Math.abs {}
+ }, TypeError);
+
+ assertThrows(function() {
+ Math.abs.prototype = 42;
+ class C extends Math.abs {}
+ }, TypeError);
+ delete Math.abs.prototype;
+
+ assertThrows(function() {
+ function* g() {}
+ class C extends g {}
+ }, TypeError);
+})();
+
+
+(function TestConstructorProperty() {
+ class C {}
+ assertEquals(C, C.prototype.constructor);
+ var descr = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+})();
+
+
+(function TestPrototypeProperty() {
+ class C {}
+ var descr = Object.getOwnPropertyDescriptor(C, 'prototype');
+ assertFalse(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(descr.writable);
+})();
+
+
+(function TestConstructor() {
+ var count = 0;
+ class C {
+ constructor() {
+ assertEquals(Object.getPrototypeOf(this), C.prototype);
+ count++;
+ }
+ }
+ assertEquals(C, C.prototype.constructor);
+ var descr = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+
+ var c = new C();
+ assertEquals(1, count);
+ assertEquals(Object.getPrototypeOf(c), C.prototype);
+})();
+
+
+(function TestImplicitConstructor() {
+ class C {}
+ var c = new C();
+ assertEquals(Object.getPrototypeOf(c), C.prototype);
+})();
+
+
+(function TestConstructorStrict() {
+ class C {
+ constructor() {
+ assertThrows(function() {
+ nonExistingBinding = 42;
+ }, ReferenceError);
+ }
+ }
+ new C();
+})();
+
+
+(function TestSuperInConstructor() {
+ var calls = 0;
+ class B {}
+ B.prototype.x = 42;
+
+ class C extends B {
+ constructor() {
+ super();
+ calls++;
+ assertEquals(42, super.x);
+ }
+ }
+
+ new C;
+ assertEquals(1, calls);
+})();
+
+
+(function TestStrictMode() {
+ class C {}
+
+ with ({a: 1}) {
+ assertEquals(1, a);
+ }
+
+ assertThrows('class C extends function B() { with ({}); return B; }() {}',
+ SyntaxError);
+
+ var D = class extends function() {
+ arguments.caller;
+ } {};
+ assertThrows(function() {
+ Object.getPrototypeOf(D).arguments;
+ }, TypeError);
+ assertThrows(function() {
+ new D;
+ }, TypeError);
+})();
+
+
+(function TestToString() {
+ class C {}
+ assertEquals('class C {}', C.toString());
+
+ class D { constructor() { 42; } }
+ assertEquals('class D { constructor() { 42; } }', D.toString());
+
+ class E { x() { 42; } }
+ assertEquals('class E { x() { 42; } }', E.toString());
+})();
+
+
+function assertMethodDescriptor(object, name) {
+ var descr = Object.getOwnPropertyDescriptor(object, name);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertEquals('function', typeof descr.value);
+ assertFalse('prototype' in descr.value);
+}
+
+
+function assertGetterDescriptor(object, name) {
+ var descr = Object.getOwnPropertyDescriptor(object, name);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertEquals('function', typeof descr.get);
+ assertFalse('prototype' in descr.get);
+ assertEquals(undefined, descr.set);
+}
+
+
+function assertSetterDescriptor(object, name) {
+ var descr = Object.getOwnPropertyDescriptor(object, name);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertEquals(undefined, descr.get);
+ assertEquals('function', typeof descr.set);
+ assertFalse('prototype' in descr.set);
+}
+
+
+function assertAccessorDescriptor(object, name) {
+ var descr = Object.getOwnPropertyDescriptor(object, name);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertEquals('function', typeof descr.get);
+ assertEquals('function', typeof descr.set);
+ assertFalse('prototype' in descr.get);
+ assertFalse('prototype' in descr.set);
+}
+
+
+(function TestMethods() {
+ class C {
+ method() { return 1; }
+ static staticMethod() { return 2; }
+ method2() { return 3; }
+ static staticMethod2() { return 4; }
+ }
+
+ assertMethodDescriptor(C.prototype, 'method');
+ assertMethodDescriptor(C.prototype, 'method2');
+ assertMethodDescriptor(C, 'staticMethod');
+ assertMethodDescriptor(C, 'staticMethod2');
+
+ assertEquals(1, new C().method());
+ assertEquals(2, C.staticMethod());
+ assertEquals(3, new C().method2());
+ assertEquals(4, C.staticMethod2());
+})();
+
+
+(function TestGetters() {
+ class C {
+ get x() { return 1; }
+ static get staticX() { return 2; }
+ get y() { return 3; }
+ static get staticY() { return 4; }
+ }
+
+ assertGetterDescriptor(C.prototype, 'x');
+ assertGetterDescriptor(C.prototype, 'y');
+ assertGetterDescriptor(C, 'staticX');
+ assertGetterDescriptor(C, 'staticY');
+
+ assertEquals(1, new C().x);
+ assertEquals(2, C.staticX);
+ assertEquals(3, new C().y);
+ assertEquals(4, C.staticY);
+})();
+
+
+
+(function TestSetters() {
+ var x, staticX, y, staticY;
+ class C {
+ set x(v) { x = v; }
+ static set staticX(v) { staticX = v; }
+ set y(v) { y = v; }
+ static set staticY(v) { staticY = v; }
+ }
+
+ assertSetterDescriptor(C.prototype, 'x');
+ assertSetterDescriptor(C.prototype, 'y');
+ assertSetterDescriptor(C, 'staticX');
+ assertSetterDescriptor(C, 'staticY');
+
+ assertEquals(1, new C().x = 1);
+ assertEquals(1, x);
+ assertEquals(2, C.staticX = 2);
+ assertEquals(2, staticX);
+ assertEquals(3, new C().y = 3);
+ assertEquals(3, y);
+ assertEquals(4, C.staticY = 4);
+ assertEquals(4, staticY);
+})();
+
+
+(function TestSideEffectsInPropertyDefine() {
+ function B() {}
+ B.prototype = {
+ constructor: B,
+ set m(v) {
+ throw Error();
+ }
+ };
+
+ class C extends B {
+ m() { return 1; }
+ }
+
+ assertEquals(1, new C().m());
+})();
+
+
+(function TestAccessors() {
+ class C {
+ constructor(x) {
+ this._x = x;
+ }
+
+ get x() { return this._x; }
+ set x(v) { this._x = v; }
+
+ static get staticX() { return this._x; }
+ static set staticX(v) { this._x = v; }
+ }
+
+ assertAccessorDescriptor(C.prototype, 'x');
+ assertAccessorDescriptor(C, 'staticX');
+
+ var c = new C(1);
+ c._x = 1;
+ assertEquals(1, c.x);
+ c.x = 2;
+ assertEquals(2, c._x);
+
+ C._x = 3;
+ assertEquals(3, C.staticX);
+ C._x = 4;
+ assertEquals(4, C.staticX );
+})();
+
+
+(function TestProto() {
+ class C {
+ __proto__() { return 1; }
+ }
+ assertMethodDescriptor(C.prototype, '__proto__');
+ assertEquals(1, new C().__proto__());
+})();
+
+
+(function TestProtoStatic() {
+ class C {
+ static __proto__() { return 1; }
+ }
+ assertMethodDescriptor(C, '__proto__');
+ assertEquals(1, C.__proto__());
+})();
+
+
+(function TestProtoAccessor() {
+ class C {
+ get __proto__() { return this._p; }
+ set __proto__(v) { this._p = v; }
+ }
+ assertAccessorDescriptor(C.prototype, '__proto__');
+ var c = new C();
+ c._p = 1;
+ assertEquals(1, c.__proto__);
+ c.__proto__ = 2;
+ assertEquals(2, c.__proto__);
+})();
+
+
+(function TestStaticProtoAccessor() {
+ class C {
+ static get __proto__() { return this._p; }
+ static set __proto__(v) { this._p = v; }
+ }
+ assertAccessorDescriptor(C, '__proto__');
+ C._p = 1;
+ assertEquals(1, C.__proto__);
+ C.__proto__ = 2;
+ assertEquals(2, C.__proto__);
+})();
+
+
+(function TestSettersOnProto() {
+ function Base() {}
+ Base.prototype = {
+ set constructor(_) {
+ assertUnreachable();
+ },
+ set m(_) {
+ assertUnreachable();
+ }
+ };
+ Object.defineProperty(Base, 'staticM', {
+ set: function() {
+ assertUnreachable();
+ }
+ });
+
+ class C extends Base {
+ m() {
+ return 1;
+ }
+ static staticM() {
+ return 2;
+ }
+ }
+
+ assertEquals(1, new C().m());
+ assertEquals(2, C.staticM());
+})();
+
+
+(function TestConstructableButNoPrototype() {
+ var Base = function() {}.bind();
+ assertThrows(function() {
+ class C extends Base {}
+ }, TypeError);
+})();
+
+
+(function TestPrototypeGetter() {
+ var calls = 0;
+ var Base = function() {}.bind();
+ Object.defineProperty(Base, 'prototype', {
+ get: function() {
+ calls++;
+ return null;
+ },
+ configurable: true
+ });
+ class C extends Base {}
+ assertEquals(1, calls);
+
+ calls = 0;
+ Object.defineProperty(Base, 'prototype', {
+ get: function() {
+ calls++;
+ return 42;
+ },
+ configurable: true
+ });
+ assertThrows(function() {
+ class C extends Base {}
+ }, TypeError);
+ assertEquals(1, calls);
+})();
+
+
+(function TestPrototypeSetter() {
+ var Base = function() {}.bind();
+ Object.defineProperty(Base, 'prototype', {
+ set: function() {
+ assertUnreachable();
+ }
+ });
+ assertThrows(function() {
+ class C extends Base {}
+ }, TypeError);
+})();
+
+
+(function TestSuperInMethods() {
+ class B {
+ method() {
+ return 1;
+ }
+ get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ method() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, new C().method());
+})();
+
+
+(function TestSuperInGetter() {
+ class B {
+ method() {
+ return 1;
+ }
+ get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ get y() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, new C().y);
+})();
+
+
+(function TestSuperInSetter() {
+ class B {
+ method() {
+ return 1;
+ }
+ get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ set y(v) {
+ assertEquals(3, v);
+ assertEquals(2, super.x);
+ assertEquals(1, super.method());
+ }
+ }
+ assertEquals(3, new C().y = 3);
+})();
+
+
+(function TestSuperInStaticMethods() {
+ class B {
+ static method() {
+ return 1;
+ }
+ static get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ static method() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, C.method());
+})();
+
+
+(function TestSuperInStaticGetter() {
+ class B {
+ static method() {
+ return 1;
+ }
+ static get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ static get x() {
+ assertEquals(2, super.x);
+ return super.method();
+ }
+ }
+ assertEquals(1, C.x);
+})();
+
+
+(function TestSuperInStaticSetter() {
+ class B {
+ static method() {
+ return 1;
+ }
+ static get x() {
+ return 2;
+ }
+ }
+ class C extends B {
+ static set x(v) {
+ assertEquals(3, v);
+ assertEquals(2, super.x);
+ assertEquals(1, super.method());
+ }
+ }
+ assertEquals(3, C.x = 3);
+})();
+
+
+(function TestNumericPropertyNames() {
+ class B {
+ 1() { return 1; }
+ get 2() { return 2; }
+ set 3(_) {}
+
+ static 4() { return 4; }
+ static get 5() { return 5; }
+ static set 6(_) {}
+ }
+
+ assertMethodDescriptor(B.prototype, '1');
+ assertGetterDescriptor(B.prototype, '2');
+ assertSetterDescriptor(B.prototype, '3');
+
+ assertMethodDescriptor(B, '4');
+ assertGetterDescriptor(B, '5');
+ assertSetterDescriptor(B, '6');
+
+ class C extends B {
+ 1() { return super[1](); }
+ get 2() { return super[2]; }
+
+ static 4() { return super[4](); }
+ static get 5() { return super[5]; }
+ }
+
+ assertEquals(1, new C()[1]());
+ assertEquals(2, new C()[2]);
+ assertEquals(4, C[4]());
+ assertEquals(5, C[5]);
+})();
+
+
+(function TestDefaultConstructorNoCrash() {
+ // Regression test for https://code.google.com/p/v8/issues/detail?id=3661
+ class C {}
+ assertThrows(function () {C();}, TypeError);
+ assertThrows(function () {C(1);}, TypeError);
+ assertTrue(new C() instanceof C);
+ assertTrue(new C(1) instanceof C);
+})();
+
+
+(function TestDefaultConstructor() {
+ var calls = 0;
+ class Base {
+ constructor() {
+ calls++;
+ }
+ }
+ class Derived extends Base {}
+ var object = new Derived;
+ assertEquals(1, calls);
+
+ calls = 0;
+ assertThrows(function() { Derived(); }, TypeError);
+ assertEquals(0, calls);
+})();
+
+
+(function TestDefaultConstructorArguments() {
+ var args, self;
+ class Base {
+ constructor() {
+ self = this;
+ args = arguments;
+ }
+ }
+ class Derived extends Base {}
+
+ new Derived;
+ assertEquals(0, args.length);
+
+ new Derived(0, 1, 2);
+ assertEquals(3, args.length);
+ assertTrue(self instanceof Derived);
+
+ var arr = new Array(100);
+ var obj = {};
+ assertThrows(function() {Derived.apply(obj, arr);}, TypeError);
+})();
+
+
+(function TestDefaultConstructorArguments2() {
+ var args;
+ class Base {
+ constructor(x, y) {
+ args = arguments;
+ }
+ }
+ class Derived extends Base {}
+
+ new Derived;
+ assertEquals(0, args.length);
+
+ new Derived(1);
+ assertEquals(1, args.length);
+ assertEquals(1, args[0]);
+
+ new Derived(1, 2, 3);
+ assertEquals(3, args.length);
+ assertEquals(1, args[0]);
+ assertEquals(2, args[1]);
+ assertEquals(3, args[2]);
+})();
+
+
+(function TestNameBindingConst() {
+ assertThrows('class C { constructor() { C = 42; } }; new C();', TypeError);
+ assertThrows('new (class C { constructor() { C = 42; } })', TypeError);
+ assertThrows('class C { m() { C = 42; } }; new C().m()', TypeError);
+ assertThrows('new (class C { m() { C = 42; } }).m()', TypeError);
+ assertThrows('class C { get x() { C = 42; } }; new C().x', TypeError);
+ assertThrows('(new (class C { get x() { C = 42; } })).x', TypeError);
+ assertThrows('class C { set x(_) { C = 42; } }; new C().x = 15;', TypeError);
+ assertThrows('(new (class C { set x(_) { C = 42; } })).x = 15;', TypeError);
+})();
+
+
+(function TestNameBinding() {
+ var C2;
+ class C {
+ constructor() {
+ C2 = C;
+ }
+ m() {
+ C2 = C;
+ }
+ get x() {
+ C2 = C;
+ }
+ set x(_) {
+ C2 = C;
+ }
+ }
+ new C();
+ assertEquals(C, C2);
+
+ C2 = undefined;
+ new C().m();
+ assertEquals(C, C2);
+
+ C2 = undefined;
+ new C().x;
+ assertEquals(C, C2);
+
+ C2 = undefined;
+ new C().x = 1;
+ assertEquals(C, C2);
+})();
+
+
+(function TestNameBindingExpression() {
+ var C3;
+ var C = class C2 {
+ constructor() {
+ assertEquals(C2, C);
+ C3 = C2;
+ }
+ m() {
+ assertEquals(C2, C);
+ C3 = C2;
+ }
+ get x() {
+ assertEquals(C2, C);
+ C3 = C2;
+ }
+ set x(_) {
+ assertEquals(C2, C);
+ C3 = C2;
+ }
+ }
+ new C();
+ assertEquals(C, C3);
+
+ C3 = undefined;
+ new C().m();
+ assertEquals(C, C3);
+
+ C3 = undefined;
+ new C().x;
+ assertEquals(C, C3);
+
+ C3 = undefined;
+ new C().x = 1;
+ assertEquals(C, C3);
+})();
+
+
+(function TestNameBindingInExtendsExpression() {
+ assertThrows(function() {
+ class x extends x {}
+ }, ReferenceError);
+
+ assertThrows(function() {
+ (class x extends x {});
+ }, ReferenceError);
+
+ assertThrows(function() {
+ var x = (class x extends x {});
+ }, ReferenceError);
+})();
+
+
+(function TestThisAccessRestriction() {
+ class Base {}
+ (function() {
+ class C extends Base {
+ constructor() {
+ var y;
+ super();
+ }
+ }; new C();
+ }());
+ assertThrows(function() {
+ class C extends Base {
+ constructor() {
+ super(this.x);
+ }
+ }; new C();
+ }, ReferenceError);
+ assertThrows(function() {
+ class C extends Base {
+ constructor() {
+ super(this);
+ }
+ }; new C();
+ }, ReferenceError);
+ assertThrows(function() {
+ class C extends Base {
+ constructor() {
+ super.method();
+ super(this);
+ }
+ }; new C();
+ }, ReferenceError);
+ assertThrows(function() {
+ class C extends Base {
+ constructor() {
+ super(super.method());
+ }
+ }; new C();
+ }, ReferenceError);
+ assertThrows(function() {
+ class C extends Base {
+ constructor() {
+ super(super());
+ }
+ }; new C();
+ }, ReferenceError);
+ assertThrows(function() {
+ class C extends Base {
+ constructor() {
+ super(1, 2, Object.getPrototypeOf(this));
+ }
+ }; new C();
+ }, ReferenceError);
+ (function() {
+ class C extends Base {
+ constructor() {
+ { super(1, 2); }
+ }
+ }; new C();
+ }());
+ (function() {
+ class C extends Base {
+ constructor() {
+ if (1) super();
+ }
+ }; new C();
+ }());
+
+ class C1 extends Object {
+ constructor() {
+ 'use strict';
+ super();
+ }
+ };
+ new C1();
+
+ class C2 extends Object {
+ constructor() {
+ ; 'use strict';;;;;
+ super();
+ }
+ };
+ new C2();
+
+ class C3 extends Object {
+ constructor() {
+ ; 'use strict';;;;;
+ // This is a comment.
+ super();
+ }
+ };
+ new C3();
+}());
+
+
+function testClassRestrictedProperties(C) {
+ assertEquals(false, C.hasOwnProperty("arguments"));
+ assertThrows(function() { return C.arguments; }, TypeError);
+ assertThrows(function() { C.arguments = {}; }, TypeError);
+
+ assertEquals(false, C.hasOwnProperty("caller"));
+ assertThrows(function() { return C.caller; }, TypeError);
+ assertThrows(function() { C.caller = {}; }, TypeError);
+
+ assertEquals(false, (new C).method.hasOwnProperty("arguments"));
+ assertThrows(function() { return new C().method.arguments; }, TypeError);
+ assertThrows(function() { new C().method.arguments = {}; }, TypeError);
+
+ assertEquals(false, (new C).method.hasOwnProperty("caller"));
+ assertThrows(function() { return new C().method.caller; }, TypeError);
+ assertThrows(function() { new C().method.caller = {}; }, TypeError);
+}
+
+
+(function testRestrictedPropertiesStrict() {
+ "use strict";
+ class ClassWithDefaultConstructor {
+ method() {}
+ }
+ class Class {
+ constructor() {}
+ method() {}
+ }
+ class DerivedClassWithDefaultConstructor extends Class {}
+ class DerivedClass extends Class { constructor() { super(); } }
+
+ testClassRestrictedProperties(ClassWithDefaultConstructor);
+ testClassRestrictedProperties(Class);
+ testClassRestrictedProperties(DerivedClassWithDefaultConstructor);
+ testClassRestrictedProperties(DerivedClass);
+ testClassRestrictedProperties(class { method() {} });
+ testClassRestrictedProperties(class { constructor() {} method() {} });
+ testClassRestrictedProperties(class extends Class { });
+ testClassRestrictedProperties(
+ class extends Class { constructor() { super(); } });
+})();
+
+
+(function testRestrictedPropertiesSloppy() {
+ class ClassWithDefaultConstructor {
+ method() {}
+ }
+ class Class {
+ constructor() {}
+ method() {}
+ }
+ class DerivedClassWithDefaultConstructor extends Class {}
+ class DerivedClass extends Class { constructor() { super(); } }
+
+ testClassRestrictedProperties(ClassWithDefaultConstructor);
+ testClassRestrictedProperties(Class);
+ testClassRestrictedProperties(DerivedClassWithDefaultConstructor);
+ testClassRestrictedProperties(DerivedClass);
+ testClassRestrictedProperties(class { method() {} });
+ testClassRestrictedProperties(class { constructor() {} method() {} });
+ testClassRestrictedProperties(class extends Class { });
+ testClassRestrictedProperties(
+ class extends Class { constructor() { super(); } });
+})();
diff --git a/deps/v8/test/mjsunit/es6/debug-blockscopes.js b/deps/v8/test/mjsunit/es6/debug-blockscopes.js
index 39849da95f..31208d41f4 100644
--- a/deps/v8/test/mjsunit/es6/debug-blockscopes.js
+++ b/deps/v8/test/mjsunit/es6/debug-blockscopes.js
@@ -372,13 +372,16 @@ function for_loop_1() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Block,
+ debug.ScopeType.Block,
debug.ScopeType.Local,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
CheckScopeContent({x:'y'}, 0, exec_state);
// The function scope contains a temporary iteration variable, but it is
// hidden to the debugger.
- CheckScopeContent({}, 1, exec_state);
+ // TODO(adamk): This variable is only used to provide a TDZ for the enumerable
+ // expression and should not be visible to the debugger.
+ CheckScopeContent({x:undefined}, 1, exec_state);
};
for_loop_1();
EndTest();
@@ -398,6 +401,7 @@ function for_loop_2() {
listener_delegate = function(exec_state) {
CheckScopeChain([debug.ScopeType.Block,
debug.ScopeType.Block,
+ debug.ScopeType.Block,
debug.ScopeType.Local,
debug.ScopeType.Script,
debug.ScopeType.Global], exec_state);
@@ -405,7 +409,9 @@ listener_delegate = function(exec_state) {
CheckScopeContent({x:'y'}, 1, exec_state);
// The function scope contains a temporary iteration variable, hidden to the
// debugger.
- CheckScopeContent({}, 2, exec_state);
+ // TODO(adamk): This variable is only used to provide a TDZ for the enumerable
+ // expression and should not be visible to the debugger.
+ CheckScopeContent({x:undefined}, 2, exec_state);
};
for_loop_2();
EndTest();
diff --git a/deps/v8/test/mjsunit/es6/debug-evaluate-blockscopes.js b/deps/v8/test/mjsunit/es6/debug-evaluate-blockscopes.js
index e24ca78315..efc334e35f 100644
--- a/deps/v8/test/mjsunit/es6/debug-evaluate-blockscopes.js
+++ b/deps/v8/test/mjsunit/es6/debug-evaluate-blockscopes.js
@@ -48,8 +48,6 @@ function f() {
// Get the Debug object exposed from the debug context global object.
var Debug = debug.Debug
-// Set breakpoint on line 6.
-var bp = Debug.setBreakPoint(f, 6);
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
@@ -59,6 +57,10 @@ function listener(event, exec_state, event_data, data) {
// Add the debug event listener.
Debug.setListener(listener);
+
+//Set breakpoint on line 6.
+var bp = Debug.setBreakPoint(f, 6);
+
result = -1;
f();
assertEquals(1, result);
@@ -107,3 +109,5 @@ assertEquals(null, exception, exception);
exception = null;
f2();
assertEquals(null, exception, exception);
+
+Debug.setListener(null);
diff --git a/deps/v8/test/mjsunit/es6/debug-step-into-class-extends.js b/deps/v8/test/mjsunit/es6/debug-step-into-class-extends.js
new file mode 100644
index 0000000000..c368414ffc
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/debug-step-into-class-extends.js
@@ -0,0 +1,42 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-debug-as debug
+
+'use strict';
+
+var Debug = debug.Debug
+
+var done = false;
+var stepCount = 0;
+
+function listener(event, execState, eventData, data) {
+ if (event == Debug.DebugEvent.Break) {
+ if (!done) {
+ execState.prepareStep(Debug.StepAction.StepInto);
+ var s = execState.frame().sourceLineText();
+ assertTrue(s.indexOf('// ' + stepCount + '.') !== -1);
+ stepCount++;
+ }
+ }
+};
+
+Debug.setListener(listener);
+
+function GetBase() {
+ var x = 1; // 1.
+ var y = 2; // 2.
+ done = true; // 3.
+ return null;
+}
+
+function f() {
+ class Derived extends GetBase() {} // 0.
+}
+
+var bp = Debug.setBreakPoint(f, 0);
+f();
+assertEquals(4, stepCount);
+
+Debug.setListener(null);
diff --git a/deps/v8/test/mjsunit/es6/debug-step-into-constructor.js b/deps/v8/test/mjsunit/es6/debug-step-into-constructor.js
new file mode 100644
index 0000000000..66fc0b99d0
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/debug-step-into-constructor.js
@@ -0,0 +1,114 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-debug-as debug
+
+'use strict';
+
+var Debug = debug.Debug
+var done, stepCount;
+
+function listener(event, execState, eventData, data) {
+ if (event == Debug.DebugEvent.Break) {
+ if (!done) {
+ execState.prepareStep(Debug.StepAction.StepInto);
+ var s = execState.frame().sourceLineText();
+ print(s);
+ assertTrue(s.indexOf('// ' + stepCount + '.') !== -1);
+ stepCount++;
+ }
+ }
+};
+
+Debug.setListener(listener);
+
+
+class Base {
+ constructor() { // 1.
+ var x = 1; // 2.
+ var y = 2; // 3.
+ done = true; // 4.
+ }
+}
+
+class Derived extends Base {}
+
+
+(function TestBreakPointInConstructor() {
+ done = false;
+ stepCount = 1;
+ var bp = Debug.setBreakPoint(Base, 0);
+
+ new Base();
+ assertEquals(5, stepCount);
+
+ Debug.clearBreakPoint(bp);
+})();
+
+
+(function TestDefaultConstructor() {
+ done = false;
+ stepCount = 1;
+
+ var bp = Debug.setBreakPoint(Base, 0);
+ new Derived();
+ assertEquals(5, stepCount);
+
+ Debug.clearBreakPoint(bp);
+})();
+
+
+(function TestStepInto() {
+ done = false;
+ stepCount = 0;
+
+ function f() {
+ new Derived(); // 0.
+ }
+
+ var bp = Debug.setBreakPoint(f, 0);
+ f();
+ assertEquals(5, stepCount);
+
+ Debug.clearBreakPoint(bp);
+})();
+
+
+(function TestExtraIndirection() {
+ done = false;
+ stepCount = 0;
+
+ class Derived2 extends Derived {}
+
+ function f() {
+ new Derived2(); // 0.
+ }
+
+ var bp = Debug.setBreakPoint(f, 0);
+ f();
+ assertEquals(5, stepCount);
+
+ Debug.clearBreakPoint(bp);
+})();
+
+
+(function TestBoundClass() {
+ done = false;
+ stepCount = 0;
+
+ var bound = Derived.bind(null);
+
+ function f() {
+ new bound(); // 0.
+ }
+
+ var bp = Debug.setBreakPoint(f, 0);
+ f();
+ assertEquals(5, stepCount);
+
+ Debug.clearBreakPoint(bp);
+})();
+
+
+Debug.setListener(null);
diff --git a/deps/v8/test/mjsunit/es6/debug-stepnext-for.js b/deps/v8/test/mjsunit/es6/debug-stepnext-for.js
index 98af911ae3..fe50fa76b9 100644
--- a/deps/v8/test/mjsunit/es6/debug-stepnext-for.js
+++ b/deps/v8/test/mjsunit/es6/debug-stepnext-for.js
@@ -58,7 +58,9 @@ function f() {
s += a[j]; // Break L
}
- // TODO(yangguo): add test case for for-let.
+ for (let i = 0; i < 3; i++) { // Break m
+ s += a[i]; // Break M
+ }
} // Break y
function listener(event, exec_state, event_data, data) {
@@ -81,36 +83,39 @@ Debug.setListener(listener);
f();
Debug.setListener(null); // Break z
-print(JSON.stringify(log));
+print("log:\n"+ JSON.stringify(log));
// The let declaration differs from var in that the loop variable
// is declared in every iteration.
var expected = [
// Entry
"a2","b2",
- // Empty for-in-var: var decl, get enumerable
- "c7","c16",
+ // Empty for-in-var: get enumerable
+ "c16",
// Empty for-in: get enumerable
"d12",
- // For-in-var: var decl, get enumerable, assign, body, assign, body, ...
- "e7","e16","e11","E4","e11","E4","e11","E4","e11",
+ // For-in-var: get enumerable, assign, body, assign, body, ...
+ "e16","e11","E4","e11","E4","e11","E4","e11",
// For-in: get enumerable, assign, body, assign, body, ...
"f12","f7","F4","f7","F4","f7","F4","f7",
- // For-in-let: get enumerable, next, new let, body, next, new let, ...
- "g16","g11","g7","G4","g11","g7","G4","g11","g7","G4","g11",
- // For-of-var: var decl, next(), body, next(), body, ...
- "h7","h16","H4","h16","H4","h16","H4","h16",
+ // For-in-let: get enumerable, next, body, next, ...
+ "g16","g11","G4","g11","G4","g11","G4","g11",
+ // For-of-var: next(), body, next(), body, ...
+ "h16","H4","h16","H4","h16","H4","h16",
// For-of: next(), body, next(), body, ...
"i12","I4","i12","I4","i12","I4","i12",
- // For-of-let: next(), new let, body, next(), new let, ...
- "j16","j7","J4","j16","j7","J4","j16","j7","J4","j16",
+ // For-of-let: next(), body, next(), ...
+ "j16","J4","j16","J4","j16","J4","j16",
// For-var: var decl, condition, body, next, condition, body, ...
"k7","k20","K4","k23","k20","K4","k23","k20","K4","k23","k20",
// For: init, condition, body, next, condition, body, ...
- "l11","l16","L4","l19","l16","L4","l19","l16","L4","l19","l16",
+ "l7","l16","L4","l19","l16","L4","l19","l16","L4","l19","l16",
+ // For-let: init, condition, body, next, condition, body, ...
+ "m7","m20","M4","m23","m20","M4","m23","m20","M4","m23","m20",
// Exit.
"y0","z0",
]
+print("expected:\n"+ JSON.stringify(expected));
assertArrayEquals(expected, log);
-assertEquals(48, s);
+assertEquals(54, s);
assertNull(exception);
diff --git a/deps/v8/test/mjsunit/es6/generators-relocation.js b/deps/v8/test/mjsunit/es6/generators-relocation.js
index 6babb148be..2636f52d7b 100644
--- a/deps/v8/test/mjsunit/es6/generators-relocation.js
+++ b/deps/v8/test/mjsunit/es6/generators-relocation.js
@@ -25,13 +25,13 @@ function RunTest(formals_and_body, args, value1, value2) {
// Advance to the first yield.
assertIteratorResult(value1, false, obj.next());
- // Add a breakpoint on line 3 (the second yield).
- var bp = Debug.setBreakPoint(gen, 3);
-
// Enable the debugger, which should force recompilation of the generator
// function and relocation of the suspended generator activation.
Debug.setListener(listener);
+ // Add a breakpoint on line 3 (the second yield).
+ var bp = Debug.setBreakPoint(gen, 3);
+
// Check that the generator resumes and suspends properly.
assertIteratorResult(value2, false, obj.next());
diff --git a/deps/v8/test/mjsunit/es6/generators-runtime.js b/deps/v8/test/mjsunit/es6/generators-runtime.js
index 115c7a4149..98015b7f7c 100644
--- a/deps/v8/test/mjsunit/es6/generators-runtime.js
+++ b/deps/v8/test/mjsunit/es6/generators-runtime.js
@@ -35,6 +35,7 @@ function* g() { yield 1; }
var GeneratorFunctionPrototype = Object.getPrototypeOf(g);
var GeneratorFunction = GeneratorFunctionPrototype.constructor;
var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
+var IteratorPrototype = Object.getPrototypeOf(GeneratorObjectPrototype);
// A generator function should have the same set of properties as any
// other function.
@@ -51,16 +52,9 @@ function TestGeneratorFunctionInstance() {
var prop = f_own_property_names[i];
var f_desc = Object.getOwnPropertyDescriptor(f, prop);
var g_desc = Object.getOwnPropertyDescriptor(g, prop);
- if (prop === "prototype") {
- // ES6 draft 03-17-2015 section 25.2.2.2
- assertFalse(g_desc.writable, prop);
- assertFalse(g_desc.enumerable, prop);
- assertFalse(g_desc.configurable, prop);
- } else {
- assertEquals(f_desc.configurable, g_desc.configurable, prop);
- assertEquals(f_desc.writable, g_desc.writable, prop);
- assertEquals(f_desc.enumerable, g_desc.enumerable, prop);
- }
+ assertEquals(f_desc.configurable, g_desc.configurable, prop);
+ assertEquals(f_desc.writable, g_desc.writable, prop);
+ assertEquals(f_desc.enumerable, g_desc.enumerable, prop);
}
}
TestGeneratorFunctionInstance();
@@ -100,7 +94,7 @@ TestGeneratorFunctionPrototype();
// Functions that we associate with generator objects are actually defined by
// a common prototype.
function TestGeneratorObjectPrototype() {
- assertSame(Object.prototype,
+ assertSame(IteratorPrototype,
Object.getPrototypeOf(GeneratorObjectPrototype));
assertSame(GeneratorObjectPrototype,
Object.getPrototypeOf((function*(){yield 1}).prototype));
@@ -134,16 +128,6 @@ function TestGeneratorObjectPrototype() {
assertTrue(throw_desc.writable);
assertFalse(throw_desc.enumerable);
assertTrue(throw_desc.configurable);
-
- var iterator_desc = Object.getOwnPropertyDescriptor(GeneratorObjectPrototype,
- Symbol.iterator);
- assertTrue(iterator_desc !== undefined);
- assertFalse(iterator_desc.writable);
- assertFalse(iterator_desc.enumerable);
- assertFalse(iterator_desc.configurable);
-
- // The generator object's "iterator" function is just the identity.
- assertSame(iterator_desc.value.call(42), 42);
}
TestGeneratorObjectPrototype();
@@ -165,6 +149,13 @@ function TestGeneratorFunction() {
assertTrue((new GeneratorFunction()) instanceof GeneratorFunction);
assertTrue(GeneratorFunction() instanceof GeneratorFunction);
+
+ // ES6 draft 04-14-15, section 25.2.2.2
+ var prototype_desc = Object.getOwnPropertyDescriptor(GeneratorFunction,
+ "prototype");
+ assertFalse(prototype_desc.writable);
+ assertFalse(prototype_desc.enumerable);
+ assertFalse(prototype_desc.configurable);
}
TestGeneratorFunction();
diff --git a/deps/v8/test/mjsunit/es6/indexed-integer-exotics.js b/deps/v8/test/mjsunit/es6/indexed-integer-exotics.js
index 7aefd78c4f..85ae3692d8 100644
--- a/deps/v8/test/mjsunit/es6/indexed-integer-exotics.js
+++ b/deps/v8/test/mjsunit/es6/indexed-integer-exotics.js
@@ -8,7 +8,7 @@ Object.prototype["10"] = "unreachable";
Object.prototype["7"] = "unreachable";
Object.prototype["-1"] = "unreachable";
Object.prototype["-0"] = "unreachable";
-Object.prototype["4294967296"] = "unreachable";
+Object.prototype["4294967295"] = "unreachable";
var array = new Int32Array(10);
@@ -17,12 +17,12 @@ function check() {
assertEquals(undefined, array["-1"]);
assertEquals(undefined, array["-0"]);
assertEquals(undefined, array["10"]);
- assertEquals(undefined, array["4294967296"]);
+ assertEquals(undefined, array["4294967295"]);
}
assertEquals("unreachable", array.__proto__["-1"]);
assertEquals("unreachable", array.__proto__["-0"]);
assertEquals("unreachable", array.__proto__["10"]);
- assertEquals("unreachable", array.__proto__["4294967296"]);
+ assertEquals("unreachable", array.__proto__["4294967295"]);
}
check();
@@ -30,19 +30,19 @@ check();
array["-1"] = "unreachable";
array["-0"] = "unreachable";
array["10"] = "unreachable";
-array["4294967296"] = "unreachable";
+array["4294967295"] = "unreachable";
check();
delete array["-0"];
delete array["-1"];
delete array["10"];
-delete array["4294967296"];
+delete array["4294967295"];
assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "-1"));
assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "-0"));
assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "10"));
-assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "4294967296"));
+assertEquals(undefined, Object.getOwnPropertyDescriptor(array, "4294967295"));
assertEquals(10, Object.keys(array).length);
check();
@@ -55,9 +55,10 @@ for (var i = 0; i < 3; i++) {
%OptimizeFunctionOnNextCall(f);
assertEquals(undefined, f());
-Object.defineProperty(new Int32Array(), "-1", {'value': 1});
-Object.defineProperty(new Int32Array(), "-0", {'value': 1});
-Object.defineProperty(new Int32Array(), "-10", {'value': 1});
-Object.defineProperty(new Int32Array(), "4294967296", {'value': 1});
+assertThrows('Object.defineProperty(new Int32Array(100), -1, {value: 1})');
+// -0 gets converted to the string "0", so use "-0" instead.
+assertThrows('Object.defineProperty(new Int32Array(100), "-0", {value: 1})');
+assertThrows('Object.defineProperty(new Int32Array(100), -10, {value: 1})');
+assertThrows('Object.defineProperty(new Int32Array(), 4294967295, {value: 1})');
check();
diff --git a/deps/v8/test/mjsunit/es6/iterator-prototype.js b/deps/v8/test/mjsunit/es6/iterator-prototype.js
new file mode 100644
index 0000000000..0b266e9897
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/iterator-prototype.js
@@ -0,0 +1,58 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var arrayIteratorPrototype = [].entries().__proto__;
+var iteratorPrototype = arrayIteratorPrototype.__proto__;
+
+assertSame(Object.prototype, Object.getPrototypeOf(iteratorPrototype));
+assertTrue(Object.isExtensible(iteratorPrototype));
+assertSame(0, Object.getOwnPropertyNames(iteratorPrototype).length);
+assertSame(1, Object.getOwnPropertySymbols(iteratorPrototype).length);
+assertSame(Symbol.iterator,
+ Object.getOwnPropertySymbols(iteratorPrototype)[0]);
+
+var descr = Object.getOwnPropertyDescriptor(iteratorPrototype, Symbol.iterator);
+assertTrue(descr.configurable);
+assertFalse(descr.enumerable);
+assertTrue(descr.writable);
+
+var iteratorFunction = descr.value;
+assertSame('function', typeof iteratorFunction);
+assertSame(0, iteratorFunction.length);
+assertSame('[Symbol.iterator]', iteratorFunction.name);
+
+var obj = {};
+assertSame(obj, iteratorFunction.call(obj));
+assertSame(iteratorPrototype, iteratorPrototype[Symbol.iterator]());
+
+var mapIteratorPrototype = new Map().entries().__proto__;
+var setIteratorPrototype = new Set().values().__proto__;
+var stringIteratorPrototype = 'abc'[Symbol.iterator]().__proto__;
+assertSame(iteratorPrototype, mapIteratorPrototype.__proto__);
+assertSame(iteratorPrototype, setIteratorPrototype.__proto__);
+assertSame(iteratorPrototype, stringIteratorPrototype.__proto__);
+
+var typedArrays = [
+ Float32Array,
+ Float64Array,
+ Int16Array,
+ Int32Array,
+ Int8Array,
+ Uint16Array,
+ Uint32Array,
+ Uint8Array,
+ Uint8ClampedArray,
+];
+
+for (var constructor of typedArrays) {
+ var array = new constructor();
+ var iterator = array[Symbol.iterator]();
+ assertSame(iteratorPrototype, iterator.__proto__.__proto__);
+}
+
+function* gen() {}
+assertSame(iteratorPrototype, gen.prototype.__proto__.__proto__);
+var g = gen();
+assertSame(gen.prototype, g.__proto__);
+assertSame(iteratorPrototype, g.__proto__.__proto__.__proto__);
diff --git a/deps/v8/test/mjsunit/es6/method-name-eval-arguments.js b/deps/v8/test/mjsunit/es6/method-name-eval-arguments.js
new file mode 100644
index 0000000000..8792177e25
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/method-name-eval-arguments.js
@@ -0,0 +1,33 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function TestSloppyMode() {
+ var o = {
+ eval() {
+ return 1;
+ },
+ arguments() {
+ return 2;
+ },
+ };
+
+ assertEquals(1, o.eval());
+ assertEquals(2, o.arguments());
+})();
+
+(function TestStrictMode() {
+ 'use strict';
+
+ var o = {
+ eval() {
+ return 1;
+ },
+ arguments() {
+ return 2;
+ },
+ };
+
+ assertEquals(1, o.eval());
+ assertEquals(2, o.arguments());
+})();
diff --git a/deps/v8/test/mjsunit/es6/object-literals-method.js b/deps/v8/test/mjsunit/es6/object-literals-method.js
new file mode 100644
index 0000000000..e4527cb776
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/object-literals-method.js
@@ -0,0 +1,314 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax
+
+
+(function TestBasics() {
+ var object = {
+ method() {
+ return 42;
+ }
+ };
+ assertEquals(42, object.method());
+})();
+
+
+(function TestThis() {
+ var object = {
+ method() {
+ assertEquals(object, this);
+ }
+ };
+ object.method();
+})();
+
+
+(function TestDescriptor() {
+ var object = {
+ method() {
+ return 42;
+ }
+ };
+
+ var desc = Object.getOwnPropertyDescriptor(object, 'method');
+ assertTrue(desc.enumerable);
+ assertTrue(desc.configurable);
+ assertTrue(desc.writable);
+ assertEquals('function', typeof desc.value);
+
+ assertEquals(42, desc.value());
+})();
+
+
+(function TestProto() {
+ var object = {
+ method() {}
+ };
+
+ assertEquals(Function.prototype, Object.getPrototypeOf(object.method));
+})();
+
+
+(function TestNotConstructable() {
+ var object = {
+ method() {}
+ };
+
+ assertThrows(function() {
+ new object.method;
+ });
+})();
+
+
+(function TestFunctionName() {
+ var object = {
+ method() {},
+ 1() {},
+ 2.0() {}
+ };
+ var f = object.method;
+ assertEquals('method', f.name);
+ var g = object[1];
+ assertEquals('1', g.name);
+ var h = object[2];
+ assertEquals('2', h.name);
+})();
+
+
+(function TestNoBinding() {
+ var method = 'local';
+ var calls = 0;
+ var object = {
+ method() {
+ calls++;
+ assertEquals('local', method);
+ }
+ };
+ object.method();
+ assertEquals(1, calls);
+})();
+
+
+(function TestNoPrototype() {
+ var object = {
+ method() {}
+ };
+ var f = object.method;
+ assertFalse(f.hasOwnProperty('prototype'));
+ assertEquals(undefined, f.prototype);
+
+ f.prototype = 42;
+ assertEquals(42, f.prototype);
+})();
+
+
+(function TestNoRestrictedPropertiesStrict() {
+ var obj = {
+ method() { "use strict"; }
+ };
+ assertFalse(obj.method.hasOwnProperty("arguments"));
+ assertThrows(function() { return obj.method.arguments; }, TypeError);
+ assertThrows(function() { obj.method.arguments = {}; }, TypeError);
+
+ assertFalse(obj.method.hasOwnProperty("caller"));
+ assertThrows(function() { return obj.method.caller; }, TypeError);
+ assertThrows(function() { obj.method.caller = {}; }, TypeError);
+})();
+
+
+(function TestNoRestrictedPropertiesSloppy() {
+ var obj = {
+ method() {}
+ };
+ assertFalse(obj.method.hasOwnProperty("arguments"));
+ assertThrows(function() { return obj.method.arguments; }, TypeError);
+ assertThrows(function() { obj.method.arguments = {}; }, TypeError);
+
+ assertFalse(obj.method.hasOwnProperty("caller"));
+ assertThrows(function() { return obj.method.caller; }, TypeError);
+ assertThrows(function() { obj.method.caller = {}; }, TypeError);
+})();
+
+
+(function TestToString() {
+ var object = {
+ method() { 42; }
+ };
+ assertEquals('method() { 42; }', object.method.toString());
+})();
+
+
+(function TestOptimized() {
+ var object = {
+ method() { return 42; }
+ };
+ assertEquals(42, object.method());
+ assertEquals(42, object.method());
+ %OptimizeFunctionOnNextCall(object.method);
+ assertEquals(42, object.method());
+ assertFalse(object.method.hasOwnProperty('prototype'));
+})();
+
+
+///////////////////////////////////////////////////////////////////////////////
+
+
+var GeneratorFunction = function*() {}.__proto__.constructor;
+var GeneratorPrototype = Object.getPrototypeOf(function*() {}).prototype;
+
+
+function assertIteratorResult(value, done, result) {
+ assertEquals({value: value, done: done}, result);
+}
+
+
+(function TestGeneratorBasics() {
+ var object = {
+ *method() {
+ yield 1;
+ }
+ };
+ var g = object.method();
+ assertIteratorResult(1, false, g.next());
+ assertIteratorResult(undefined, true, g.next());
+})();
+
+
+(function TestGeneratorThis() {
+ var object = {
+ *method() {
+ yield this;
+ }
+ };
+ var g = object.method();
+ assertIteratorResult(object, false, g.next());
+ assertIteratorResult(undefined, true, g.next());
+})();
+
+
+(function TestGeneratorSymbolIterator() {
+ var object = {
+ *method() {}
+ };
+ var g = object.method();
+ assertEquals(g, g[Symbol.iterator]());
+})();
+
+
+(function TestGeneratorDescriptor() {
+ var object = {
+ *method() {
+ yield 1;
+ }
+ };
+
+ var desc = Object.getOwnPropertyDescriptor(object, 'method');
+ assertTrue(desc.enumerable);
+ assertTrue(desc.configurable);
+ assertTrue(desc.writable);
+ assertEquals('function', typeof desc.value);
+
+ var g = desc.value();
+ assertIteratorResult(1, false, g.next());
+ assertIteratorResult(undefined, true, g.next());
+})();
+
+
+(function TestGeneratorPrototypeDescriptor() {
+ var object = {
+ *method() {}
+ };
+
+ var desc = Object.getOwnPropertyDescriptor(object.method, 'prototype');
+ assertFalse(desc.enumerable);
+ assertFalse(desc.configurable);
+ assertTrue(desc.writable);
+ assertEquals(GeneratorPrototype, Object.getPrototypeOf(desc.value));
+})();
+
+
+(function TestGeneratorProto() {
+ var object = {
+ *method() {}
+ };
+
+ assertEquals(GeneratorFunction.prototype,
+ Object.getPrototypeOf(object.method));
+})();
+
+
+(function TestGeneratorConstructable() {
+ var object = {
+ *method() {
+ yield 1;
+ }
+ };
+
+ var g = new object.method();
+ assertIteratorResult(1, false, g.next());
+ assertIteratorResult(undefined, true, g.next());
+})();
+
+
+(function TestGeneratorName() {
+ var object = {
+ *method() {},
+ *1() {},
+ *2.0() {}
+ };
+ var f = object.method;
+ assertEquals('method', f.name);
+ var g = object[1];
+ assertEquals('1', g.name);
+ var h = object[2];
+ assertEquals('2', h.name);
+})();
+
+
+(function TestGeneratorNoBinding() {
+ var method = 'local';
+ var calls = 0;
+ var object = {
+ *method() {
+ calls++;
+ assertEquals('local', method);
+ }
+ };
+ var g = object.method();
+ assertIteratorResult(undefined, true, g.next());
+ assertEquals(1, calls);
+})();
+
+
+(function TestGeneratorToString() {
+ var object = {
+ *method() { yield 1; }
+ };
+ assertEquals('*method() { yield 1; }', object.method.toString());
+})();
+
+
+(function TestProtoName() {
+ var object = {
+ __proto__() {
+ return 1;
+ }
+ };
+ assertEquals(Object.prototype, Object.getPrototypeOf(object));
+ assertEquals(1, object.__proto__());
+})();
+
+
+(function TestProtoName2() {
+ var p = {};
+ var object = {
+ __proto__() {
+ return 1;
+ },
+ __proto__: p
+ };
+ assertEquals(p, Object.getPrototypeOf(object));
+ assertEquals(1, object.__proto__());
+})();
diff --git a/deps/v8/test/mjsunit/es6/object-literals-property-shorthand.js b/deps/v8/test/mjsunit/es6/object-literals-property-shorthand.js
new file mode 100644
index 0000000000..29ce66d270
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/object-literals-property-shorthand.js
@@ -0,0 +1,71 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+
+(function TestBasics() {
+ var x = 1;
+ var object = {x};
+ assertEquals(1, object.x);
+})();
+
+
+(function TestDescriptor() {
+ var x = 1;
+ var object = {x};
+ var descr = Object.getOwnPropertyDescriptor(object, 'x');
+ assertEquals(1, descr.value);
+ assertTrue(descr.enumerable);
+ assertTrue(descr.writable);
+ assertTrue(descr.configurable);
+})();
+
+
+(function TestNotDefined() {
+ 'use strict';
+ assertThrows(function() {
+ return {notDefined};
+ }, ReferenceError);
+})();
+
+
+(function TestLet() {
+ var let = 1;
+ var object = {let};
+ assertEquals(1, object.let);
+})();
+
+
+(function TestYieldInFunction() {
+ var yield = 1;
+ var object = {yield};
+ assertEquals(1, object.yield);
+})();
+
+
+(function TestToString() {
+ function f(x) { return {x}; }
+ assertEquals('function f(x) { return {x}; }', f.toString());
+})();
+
+
+(function TestProtoName() {
+ var __proto__ = 1;
+ var object = {
+ __proto__
+ };
+ assertEquals(Object.prototype, Object.getPrototypeOf(object));
+ assertEquals(1, object.__proto__);
+})();
+
+
+(function TestProtoName2() {
+ var __proto__ = 1;
+ var p = {};
+ var object = {
+ __proto__: p,
+ __proto__,
+ };
+ assertEquals(p, Object.getPrototypeOf(object));
+ assertEquals(1, object.__proto__);
+})();
diff --git a/deps/v8/test/mjsunit/es6/promise-internal-setter.js b/deps/v8/test/mjsunit/es6/promise-internal-setter.js
new file mode 100644
index 0000000000..83e4738316
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/promise-internal-setter.js
@@ -0,0 +1,17 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+Object.defineProperties(Object.prototype, {
+ promise: {set: assertUnreachable},
+ reject: {set: assertUnreachable},
+ resolve: {set: assertUnreachable},
+});
+
+class P extends Promise {}
+
+P.all([Promise.resolve('ok')]);
+P.race([Promise.resolve('ok')]);
+P.defer();
diff --git a/deps/v8/test/mjsunit/es6/regress/regress-2506.js b/deps/v8/test/mjsunit/es6/regress/regress-2506.js
index b5cc91dbd7..5f88fcd1d4 100644
--- a/deps/v8/test/mjsunit/es6/regress/regress-2506.js
+++ b/deps/v8/test/mjsunit/es6/regress/regress-2506.js
@@ -18,15 +18,15 @@ assertEquals(3, f[2]());
let x = 1;
s = 0;
-for (const x of [x, x+1, x+2]) {
- s += x;
+for (const z of [x, x+1, x+2]) {
+ s += z;
}
assertEquals(6, s);
s = 0;
var q = 1;
-for (const q of [q, q+1, q+2]) {
- s += q;
+for (const x of [q, q+1, q+2]) {
+ s += x;
}
assertEquals(6, s);
@@ -56,15 +56,15 @@ assertThrows("'use strict'; for (const x in [1,2,3]) { x++ }", TypeError);
let x = 1;
s = 0;
- for (const x of [x, x+1, x+2]) {
- s += x;
+ for (const q of [x, x+1, x+2]) {
+ s += q;
}
assertEquals(6, s);
s = 0;
var q = 1;
- for (const q of [q, q+1, q+2]) {
- s += q;
+ for (const x of [q, q+1, q+2]) {
+ s += x;
}
assertEquals(6, s);
diff --git a/deps/v8/test/mjsunit/es6/regress/regress-3750.js b/deps/v8/test/mjsunit/es6/regress/regress-3750.js
new file mode 100644
index 0000000000..a425def2b7
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/regress/regress-3750.js
@@ -0,0 +1,7 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+class Example { }
+Object.observe(Example.prototype, function(){});
diff --git a/deps/v8/test/mjsunit/es6/regress/regress-4097.js b/deps/v8/test/mjsunit/es6/regress/regress-4097.js
new file mode 100644
index 0000000000..52f2e9f20d
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/regress/regress-4097.js
@@ -0,0 +1,37 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function StoreToSuper () {
+ "use strict";
+ class A {
+ s() {
+ super.bla = 10;
+ }
+ };
+
+ let a = new A();
+ (new A).s.call(a);
+ assertEquals(10, a.bla);
+ assertThrows(function() { (new A).s.call(undefined); }, TypeError);
+ assertThrows(function() { (new A).s.call(42); }, TypeError);
+ assertThrows(function() { (new A).s.call(null); }, TypeError);
+ assertThrows(function() { (new A).s.call("abc"); }, TypeError);
+})();
+
+
+(function LoadFromSuper () {
+ "use strict";
+ class A {
+ s() {
+ return super.bla;
+ }
+ };
+
+ let a = new A();
+ assertSame(undefined, (new A).s.call(a));
+ assertSame(undefined, (new A).s.call(undefined));
+ assertSame(undefined, (new A).s.call(42));
+ assertSame(undefined, (new A).s.call(null));
+ assertSame(undefined, (new A).s.call("abc"));
+})();
diff --git a/deps/v8/test/mjsunit/es6/regress/regress-455141.js b/deps/v8/test/mjsunit/es6/regress/regress-455141.js
new file mode 100644
index 0000000000..676adebe72
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/regress/regress-455141.js
@@ -0,0 +1,15 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --no-lazy
+"use strict";
+class Base {
+}
+class Subclass extends Base {
+ constructor() {
+ this.prp1 = 3;
+ }
+}
+function __f_1(){
+}
diff --git a/deps/v8/test/mjsunit/es6/string-html.js b/deps/v8/test/mjsunit/es6/string-html.js
index 4f3feb56dd..690830ba84 100644
--- a/deps/v8/test/mjsunit/es6/string-html.js
+++ b/deps/v8/test/mjsunit/es6/string-html.js
@@ -157,3 +157,45 @@ assertThrows(function() {
String.prototype.sup.call(null);
}, TypeError);
assertEquals(String.prototype.sup.length, 0);
+
+
+(function TestToString() {
+ var calls = 0;
+ var obj = {
+ toString() {
+ calls++;
+ return 'abc';
+ },
+ valueOf() {
+ assertUnreachable();
+ }
+ };
+
+ var methodNames = [
+ 'anchor',
+ 'big',
+ 'blink',
+ 'bold',
+ 'fixed',
+ 'fontcolor',
+ 'fontsize',
+ 'italics',
+ 'link',
+ 'small',
+ 'strike',
+ 'sub',
+ 'sup',
+ ];
+ for (var name of methodNames) {
+ calls = 0;
+ String.prototype[name].call(obj);
+ assertEquals(1, calls);
+ }
+})();
+
+
+(function TestDeleteStringRelace() {
+ assertEquals('<a name="n">s</a>', 's'.anchor('n'));
+ assertTrue(delete String.prototype.replace);
+ assertEquals('<a name="n">s</a>', 's'.anchor('n'));
+})();
diff --git a/deps/v8/test/mjsunit/es6/templates.js b/deps/v8/test/mjsunit/es6/templates.js
index 0734f0e5d0..feb7364613 100644
--- a/deps/v8/test/mjsunit/es6/templates.js
+++ b/deps/v8/test/mjsunit/es6/templates.js
@@ -588,6 +588,26 @@ var global = this;
})();
+(function testReturnValueAsTagFn() {
+ "use strict";
+ var i = 0;
+ function makeTag() {
+ return function tag(cs) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ var rcs = [];
+ rcs.raw = cs.map(function(s) {
+ return '!' + s + '!';
+ });
+ args.unshift(rcs);
+ return String.raw.apply(null, args);
+ }
+ }
+ assertEquals('!hi!', makeTag()`hi`);
+ assertEquals('!test!0!test!', makeTag()`test${0}test`);
+ assertEquals('!!', makeTag()``);
+});
+
+
(function testToStringSubstitutions() {
var a = {
toString: function() { return "a"; },
diff --git a/deps/v8/test/mjsunit/es6/toMethod.js b/deps/v8/test/mjsunit/es6/toMethod.js
new file mode 100644
index 0000000000..c18251b2dc
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/toMethod.js
@@ -0,0 +1,106 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --allow-natives-syntax
+
+
+(function TestSingleClass() {
+ function f(x) {
+ var a = [0, 1, 2]
+ return a[x];
+ }
+
+ function ClassD() { }
+
+ assertEquals(1, f(1));
+ var g = %ToMethod(f, ClassD.prototype);
+ assertEquals(1, g(1));
+ assertEquals(undefined, f[%HomeObjectSymbol()]);
+ assertEquals(ClassD.prototype, g[%HomeObjectSymbol()]);
+}());
+
+
+(function TestClassHierarchy() {
+ function f(x) {
+ return function g(y) { x++; return x + y; };
+ }
+
+ function Base() {}
+ function Derived() { }
+ Derived.prototype = Object.create(Base.prototype);
+
+ var q = f(0);
+ assertEquals(2, q(1));
+ assertEquals(3, q(1));
+ var g = %ToMethod(q, Derived.prototype);
+ assertFalse(g === q);
+ assertEquals(4, g(1));
+ assertEquals(5, q(1));
+}());
+
+
+(function TestPrototypeChain() {
+ var o = {};
+ var o1 = {};
+ function f() { }
+
+ function g() { }
+
+ var fMeth = %ToMethod(f, o);
+ assertEquals(o, fMeth[%HomeObjectSymbol()]);
+ g.__proto__ = fMeth;
+ assertEquals(undefined, g[%HomeObjectSymbol()]);
+ var gMeth = %ToMethod(g, o1);
+ assertEquals(fMeth, gMeth.__proto__);
+ assertEquals(o, fMeth[%HomeObjectSymbol()]);
+ assertEquals(o1, gMeth[%HomeObjectSymbol()]);
+}());
+
+
+(function TestBoundFunction() {
+ var o = {};
+ var p = {};
+
+
+ function f(x, y, z, w) {
+ assertEquals(o, this);
+ assertEquals(1, x);
+ assertEquals(2, y);
+ assertEquals(3, z);
+ assertEquals(4, w);
+ return x+y+z+w;
+ }
+
+ var fBound = f.bind(o, 1, 2, 3);
+ var fMeth = %ToMethod(fBound, p);
+ assertEquals(10, fMeth(4));
+ assertEquals(10, fMeth.call(p, 4));
+ var fBound1 = fBound.bind(o, 4);
+ assertEquals(10, fBound1());
+ var fMethBound = fMeth.bind(o, 4);
+ assertEquals(10, fMethBound());
+}());
+
+(function TestOptimized() {
+ function f(o) {
+ return o.x;
+ }
+ var o = {x : 15};
+ assertEquals(15, f(o));
+ assertEquals(15, f(o));
+ %OptimizeFunctionOnNextCall(f);
+ assertEquals(15, f(o));
+ var g = %ToMethod(f, {});
+ var o1 = {y : 1024, x : "abc"};
+ assertEquals("abc", f(o1));
+ assertEquals("abc", g(o1));
+} ());
+
+(function TestExtensibility() {
+ function f() {}
+ Object.preventExtensions(f);
+ assertFalse(Object.isExtensible(f));
+ var m = %ToMethod(f, {});
+ assertTrue(Object.isExtensible(m));
+}());
diff --git a/deps/v8/test/mjsunit/es6/typedarray-copywithin.js b/deps/v8/test/mjsunit/es6/typedarray-copywithin.js
new file mode 100644
index 0000000000..ad5a0df563
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-copywithin.js
@@ -0,0 +1,173 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+function CheckEachTypedArray(fn) {
+ typedArrayConstructors.forEach(fn);
+}
+
+CheckEachTypedArray(function copyWithinArity(constructor) {
+ assertEquals(new constructor([]).copyWithin.length, 2);
+});
+
+
+CheckEachTypedArray(function copyWithinTargetAndStart(constructor) {
+ // works with two arguments
+ assertArrayEquals([4, 5, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3));
+ assertArrayEquals([1, 4, 5, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(1, 3));
+ assertArrayEquals([1, 3, 4, 5, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(1, 2));
+ assertArrayEquals([1, 2, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(2, 2));
+});
+
+
+CheckEachTypedArray(function copyWithinTargetStartAndEnd(constructor) {
+ // works with three arguments
+ assertArrayEquals(new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3, 4),
+ [4, 2, 3, 4, 5]);
+ assertArrayEquals(new constructor([1, 2, 3, 4, 5]).copyWithin(1, 3, 4),
+ [1, 4, 3, 4, 5]);
+ assertArrayEquals(new constructor([1, 2, 3, 4, 5]).copyWithin(1, 2, 4),
+ [1, 3, 4, 4, 5]);
+});
+
+
+CheckEachTypedArray(function copyWithinNegativeRelativeOffsets(constructor) {
+ // works with negative arguments
+ assertArrayEquals([4, 5, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(0, -2));
+ assertArrayEquals([4, 2, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(0, -2, -1));
+ assertArrayEquals([1, 3, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(-4, -3, -2));
+ assertArrayEquals([1, 3, 4, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(-4, -3, -1));
+ assertArrayEquals([1, 3, 4, 5, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(-4, -3));
+ // test with arguments equal to -this.length
+ assertArrayEquals([1, 2, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(-5, 0));
+});
+
+
+CheckEachTypedArray(function mustBeTypedArray(constructor) {
+ // throws on non-TypedArray values
+ assertThrows(function() {
+ return constructor.prototype.copyWithin.call(null, 0, 3);
+ }, TypeError);
+ assertThrows(function() {
+ return constructor.prototype.copyWithin.call(undefined, 0, 3);
+ }, TypeError);
+ assertThrows(function() {
+ return constructor.prototype.copyWithin.call(34, 0, 3);
+ }, TypeError);
+ assertThrows(function() {
+ return constructor.prototype.copyWithin.call([1, 2, 3, 4, 5], 0, 3);
+ }, TypeError);
+});
+
+
+CheckEachTypedArray(function copyWithinStartLessThanTarget(constructor) {
+ // test with target > start on 2 arguments
+ assertArrayEquals([1, 2, 3, 1, 2],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(3, 0));
+
+ // test with target > start on 3 arguments
+ assertArrayEquals([1, 2, 3, 1, 2],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(3, 0, 4));
+});
+
+CheckEachTypedArray(function copyWithinNonIntegerRelativeOffsets(constructor) {
+ // test on fractional arguments
+ assertArrayEquals([4, 5, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(0.2, 3.9));
+});
+
+
+CheckEachTypedArray(function copyWithinNegativeZeroTarget(constructor) {
+ // test with -0
+ assertArrayEquals([4, 5, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(-0, 3));
+});
+
+
+CheckEachTypedArray(function copyWithinTargetOutsideStart(constructor) {
+ // test with arguments more than this.length
+ assertArrayEquals([1, 2, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(0, 7));
+
+ // test with arguments less than -this.length
+ assertArrayEquals([1, 2, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(-7, 0));
+});
+
+
+CheckEachTypedArray(function copyWithinEmptyArray(constructor) {
+ // test on empty array
+ assertArrayEquals([], new constructor([]).copyWithin(0, 3));
+});
+
+
+CheckEachTypedArray(function copyWithinTargetCutOff(constructor) {
+ // test with target range being shorter than end - start
+ assertArrayEquals([1, 2, 2, 3, 4], [1, 2, 3, 4, 5].copyWithin(2, 1, 4));
+});
+
+
+CheckEachTypedArray(function copyWithinOverlappingRanges(constructor) {
+ // test overlapping ranges
+ var arr = [1, 2, 3, 4, 5];
+ arr.copyWithin(2, 1, 4);
+ assertArrayEquals([1, 2, 2, 2, 3], arr.copyWithin(2, 1, 4));
+});
+
+
+CheckEachTypedArray(function copyWithinDefaultEnd(constructor) {
+ // undefined as third argument
+ assertArrayEquals([4, 5, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3, undefined));
+});
+
+
+CheckEachTypedArray(function copyWithinLargeArray(constructor) {
+ var large = 10000;
+
+ // test on a large array
+ var arr = new constructor(large);
+ assertArrayEquals(arr, arr.copyWithin(45, 9000));
+
+ var expected = new Array(large);
+ // test on numbers
+ for (var i = 0; i < large; i++) {
+ arr[i] = Math.random() * 100; // May be cast to an int
+ expected[i] = arr[i];
+ if (i >= 9000) {
+ expected[(i - 9000) + 45] = arr[i];
+ }
+ }
+ assertArrayEquals(expected, arr.copyWithin(45, 9000));
+
+ // test array length remains same
+ assertEquals(large, arr.length);
+});
+
+
+CheckEachTypedArray(function copyWithinNullEnd(constructor) {
+ // test null on third argument is converted to +0
+ assertArrayEquals([1, 2, 3, 4, 5],
+ new constructor([1, 2, 3, 4, 5]).copyWithin(0, 3, null));
+});
diff --git a/deps/v8/test/mjsunit/es6/typedarray-every.js b/deps/v8/test/mjsunit/es6/typedarray-every.js
new file mode 100644
index 0000000000..22132f32b1
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-every.js
@@ -0,0 +1,152 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+function CheckTypedArrayIsNeutered(array) {
+ assertEquals(0, array.byteLength);
+ assertEquals(0, array.byteOffset);
+ assertEquals(0, array.length);
+}
+
+function TestTypedArrayForEach(constructor) {
+ assertEquals(1, constructor.prototype.every.length);
+
+ var a = new constructor(3);
+ a[0] = 0;
+ a[1] = 1;
+ a[2] = 2;
+
+ var result = a.every(function (n) { return n < 2; });
+ assertFalse(result);
+
+ var result = a.every(function (n) { return n > 2; });
+ assertFalse(result);
+
+ var result = a.every(function (n) { return n >= 0; });
+ assertEquals(true, result);
+
+ // Use specified object as this object when calling the function.
+ var o = { value: 42 };
+ result = a.every(function (n, index, array) { return n == index && n < this.value; }, o);
+ assertEquals(true, result);
+
+ // Early exit happens when appropriate
+ count = 0;
+ result = a.every(function () { count++; return false; });
+ assertEquals(1, count);
+ assertFalse(result);
+
+ // Modify the original array.
+ count = 0;
+ result = a.every(function (n, index, array) {
+ array[index] = n + 1; count++; return true;
+ });
+ assertEquals(3, count);
+ assertEquals(true, result);
+ assertArrayEquals([1, 2, 3], a);
+
+ // Check that values passed as second argument are wrapped into
+ // objects when calling into sloppy mode functions.
+ function CheckWrapping(value, wrapper) {
+ var wrappedValue = new wrapper(value);
+
+ a.every(function () {
+ assertEquals("object", typeof this);
+ assertEquals(wrappedValue, this);
+ }, value);
+
+ a.every(function () {
+ "use strict";
+ assertEquals(typeof value, typeof this);
+ assertEquals(value, this);
+ }, value);
+ }
+ CheckWrapping(true, Boolean);
+ CheckWrapping(false, Boolean);
+ CheckWrapping("xxx", String);
+ CheckWrapping(42, Number);
+ CheckWrapping(3.14, Number);
+ CheckWrapping({}, Object);
+
+ // Neutering the buffer backing the typed array mid-way should
+ // still make .forEach() finish, and the array should keep being
+ // empty after neutering it.
+ count = 0;
+ a = new constructor(3);
+ result = a.every(function (n, index, array) {
+ assertFalse(array[index] === undefined); // don't get here if neutered
+ if (count > 0) %ArrayBufferNeuter(array.buffer);
+ array[index] = n + 1;
+ count++;
+ return count > 1 ? array[index] === undefined : true;
+ });
+ assertEquals(2, count);
+ assertEquals(true, result);
+ CheckTypedArrayIsNeutered(a);
+ assertEquals(undefined, a[0]);
+
+ // The method must work for typed arrays created from ArrayBuffer.
+ // The length of the ArrayBuffer is chosen so it is a multiple of
+ // all lengths of the typed array items.
+ a = new constructor(new ArrayBuffer(64));
+ count = 0;
+ result = a.every(function (n) { return n == 0; });
+ assertEquals(result, true);
+
+ // Externalizing the array mid-way accessing the .buffer property
+ // should work.
+ a = new constructor(2);
+ count = 0;
+ var buffer = undefined;
+ a.every(function (n, index, array) {
+ if (count++ > 0)
+ buffer = array.buffer;
+ return true;
+ });
+ assertEquals(2, count);
+ assertTrue(!!buffer);
+ assertEquals("ArrayBuffer", %_ClassOf(buffer));
+ assertSame(buffer, a.buffer);
+
+ // The %TypedArray%.every() method should not work when
+ // transplanted to objects that are not typed arrays.
+ assertThrows(function () { constructor.prototype.every.call([1, 2, 3], function (x) {}) }, TypeError);
+ assertThrows(function () { constructor.prototype.every.call("abc", function (x) {}) }, TypeError);
+ assertThrows(function () { constructor.prototype.every.call({}, function (x) {}) }, TypeError);
+ assertThrows(function () { constructor.prototype.every.call(0, function (x) {}) }, TypeError);
+
+ // Method must be useable on instances of other typed arrays.
+ for (var i = 0; i < typedArrayConstructors.length; i++) {
+ count = 0;
+ a = new typedArrayConstructors[i](4);
+ constructor.prototype.every.call(a, function (x) { count++; return true; });
+ assertEquals(a.length, count);
+ }
+
+ // Shadowing length doesn't affect every, unlike Array.prototype.every
+ a = new constructor([1, 2]);
+ Object.defineProperty(a, 'length', {value: 1});
+ var x = 0;
+ assertEquals(a.every(function(elt) { x += elt; return true; }), true);
+ assertEquals(x, 3);
+ assertEquals(Array.prototype.every.call(a,
+ function(elt) { x += elt; return true; }), true);
+ assertEquals(x, 4);
+}
+
+for (i = 0; i < typedArrayConstructors.length; i++) {
+ TestTypedArrayForEach(typedArrayConstructors[i]);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-fill.js b/deps/v8/test/mjsunit/es6/typedarray-fill.js
new file mode 100644
index 0000000000..2c612016f6
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-fill.js
@@ -0,0 +1,45 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+for (var constructor of typedArrayConstructors) {
+ assertEquals(1, constructor.prototype.fill.length);
+
+ assertArrayEquals(new constructor([]).fill(8), []);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8), [8, 8, 8, 8, 8]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1), [0, 8, 8, 8, 8]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 10), [0, 0, 0, 0, 0]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -5), [8, 8, 8, 8, 8]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, 4), [0, 8, 8, 8, 0]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, -1), [0, 8, 8, 8, 0]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, 42), [0, 8, 8, 8, 8]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -3, 42), [0, 0, 8, 8, 8]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8, 0]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0]);
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, 4), [8, 8, 8, 8, 0]);
+
+ // Test exceptions
+ assertThrows('constructor.prototype.fill.call(null)', TypeError);
+ assertThrows('constructor.prototype.fill.call(undefined)', TypeError);
+ assertThrows('constructor.prototype.fill.call([])', TypeError);
+
+ // Shadowing length doesn't affect fill, unlike Array.prototype.fill
+ var a = new constructor([2, 2]);
+ Object.defineProperty(a, 'length', {value: 1});
+ a.fill(3);
+ assertArrayEquals([a[0], a[1]], [3, 3]);
+ Array.prototype.fill.call(a, 4);
+ assertArrayEquals([a[0], a[1]], [4, 3]);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-find.js b/deps/v8/test/mjsunit/es6/typedarray-find.js
new file mode 100644
index 0000000000..69ceedc8b5
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-find.js
@@ -0,0 +1,187 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+for (var constructor of typedArrayConstructors) {
+
+assertEquals(1, constructor.prototype.find.length);
+
+var a = new constructor([21, 22, 23, 24]);
+assertEquals(undefined, a.find(function() { return false; }));
+assertEquals(21, a.find(function() { return true; }));
+assertEquals(undefined, a.find(function(val) { return 121 === val; }));
+assertEquals(24, a.find(function(val) { return 24 === val; }));
+assertEquals(23, a.find(function(val) { return 23 === val; }), null);
+assertEquals(22, a.find(function(val) { return 22 === val; }), undefined);
+
+
+//
+// Test predicate is not called when array is empty
+//
+(function() {
+ var a = new constructor([]);
+ var l = -1;
+ var o = -1;
+ var v = -1;
+ var k = -1;
+
+ a.find(function(val, key, obj) {
+ o = obj;
+ l = obj.length;
+ v = val;
+ k = key;
+
+ return false;
+ });
+
+ assertEquals(-1, l);
+ assertEquals(-1, o);
+ assertEquals(-1, v);
+ assertEquals(-1, k);
+})();
+
+
+//
+// Test predicate is called with correct arguments
+//
+(function() {
+ var a = new constructor([5]);
+ var l = -1;
+ var o = -1;
+ var v = -1;
+ var k = -1;
+
+ var found = a.find(function(val, key, obj) {
+ o = obj;
+ l = obj.length;
+ v = val;
+ k = key;
+
+ return false;
+ });
+
+ assertArrayEquals(a, o);
+ assertEquals(a.length, l);
+ assertEquals(5, v);
+ assertEquals(0, k);
+ assertEquals(undefined, found);
+})();
+
+
+//
+// Test predicate is called array.length times
+//
+(function() {
+ var a = new constructor([1, 2, 3, 4, 5]);
+ var l = 0;
+ var found = a.find(function() {
+ l++;
+ return false;
+ });
+
+ assertEquals(a.length, l);
+ assertEquals(undefined, found);
+})();
+
+
+//
+// Test array modifications
+//
+(function() {
+ a = new constructor([1, 2, 3]);
+ found = a.find(function(val, key) { a[key] = ++val; return false; });
+ assertArrayEquals([2, 3, 4], a);
+ assertEquals(3, a.length);
+ assertEquals(undefined, found);
+})();
+
+//
+// Test thisArg
+//
+(function() {
+ // Test String as a thisArg
+ var found = new constructor([1, 2, 3]).find(function(val, key) {
+ return this.charAt(Number(key)) === String(val);
+ }, "321");
+ assertEquals(2, found);
+
+ // Test object as a thisArg
+ var thisArg = {
+ elementAt: function(key) {
+ return this[key];
+ }
+ };
+ Array.prototype.push.apply(thisArg, [3, 2, 1]);
+
+ found = new constructor([1, 2, 3]).find(function(val, key) {
+ return this.elementAt(key) === val;
+ }, thisArg);
+ assertEquals(2, found);
+
+ // Create a new object in each function call when receiver is a
+ // primitive value. See ECMA-262, Annex C.
+ a = [];
+ new constructor([1, 2]).find(function() { a.push(this) }, "");
+ assertTrue(a[0] !== a[1]);
+
+ // Do not create a new object otherwise.
+ a = [];
+ new constructor([1, 2]).find(function() { a.push(this) }, {});
+ assertEquals(a[0], a[1]);
+
+ // In strict mode primitive values should not be coerced to an object.
+ a = [];
+ new constructor([1, 2]).find(function() { 'use strict'; a.push(this); }, "");
+ assertEquals("", a[0]);
+ assertEquals(a[0], a[1]);
+
+})();
+
+// Test exceptions
+assertThrows('constructor.prototype.find.call(null, function() { })',
+ TypeError);
+assertThrows('constructor.prototype.find.call(undefined, function() { })',
+ TypeError);
+assertThrows('constructor.prototype.find.apply(null, function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.find.apply(undefined, function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.find.apply([], function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.find.apply({}, function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.find.apply("", function() { }, [])',
+ TypeError);
+
+assertThrows('new constructor([]).find(null)', TypeError);
+assertThrows('new constructor([]).find(undefined)', TypeError);
+assertThrows('new constructor([]).find(0)', TypeError);
+assertThrows('new constructor([]).find(true)', TypeError);
+assertThrows('new constructor([]).find(false)', TypeError);
+assertThrows('new constructor([]).find("")', TypeError);
+assertThrows('new constructor([]).find({})', TypeError);
+assertThrows('new constructor([]).find([])', TypeError);
+assertThrows('new constructor([]).find(/\d+/)', TypeError);
+
+// Shadowing length doesn't affect find, unlike Array.prototype.find
+a = new constructor([1, 2]);
+Object.defineProperty(a, 'length', {value: 1});
+var x = 0;
+assertEquals(a.find(function(elt) { x += elt; return false; }), undefined);
+assertEquals(x, 3);
+assertEquals(Array.prototype.find.call(a,
+ function(elt) { x += elt; return false; }), undefined);
+assertEquals(x, 4);
+
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-findindex.js b/deps/v8/test/mjsunit/es6/typedarray-findindex.js
new file mode 100644
index 0000000000..51c439203d
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-findindex.js
@@ -0,0 +1,187 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+for (var constructor of typedArrayConstructors) {
+
+assertEquals(1, constructor.prototype.findIndex.length);
+
+var a = new constructor([21, 22, 23, 24]);
+assertEquals(-1, a.findIndex(function() { return false; }));
+assertEquals(-1, a.findIndex(function(val) { return 121 === val; }));
+assertEquals(0, a.findIndex(function() { return true; }));
+assertEquals(1, a.findIndex(function(val) { return 22 === val; }), undefined);
+assertEquals(2, a.findIndex(function(val) { return 23 === val; }), null);
+assertEquals(3, a.findIndex(function(val) { return 24 === val; }));
+
+
+//
+// Test predicate is not called when array is empty
+//
+(function() {
+ var a = new constructor([]);
+ var l = -1;
+ var o = -1;
+ var v = -1;
+ var k = -1;
+
+ a.findIndex(function(val, key, obj) {
+ o = obj;
+ l = obj.length;
+ v = val;
+ k = key;
+
+ return false;
+ });
+
+ assertEquals(-1, l);
+ assertEquals(-1, o);
+ assertEquals(-1, v);
+ assertEquals(-1, k);
+})();
+
+
+//
+// Test predicate is called with correct argumetns
+//
+(function() {
+ var a = new constructor([5]);
+ var l = -1;
+ var o = -1;
+ var v = -1;
+ var k = -1;
+
+ var index = a.findIndex(function(val, key, obj) {
+ o = obj;
+ l = obj.length;
+ v = val;
+ k = key;
+
+ return false;
+ });
+
+ assertArrayEquals(a, o);
+ assertEquals(a.length, l);
+ assertEquals(5, v);
+ assertEquals(0, k);
+ assertEquals(-1, index);
+})();
+
+
+//
+// Test predicate is called array.length times
+//
+(function() {
+ var a = new constructor([1, 2, 3, 4, 5]);
+ var l = 0;
+
+ a.findIndex(function() {
+ l++;
+ return false;
+ });
+
+ assertEquals(a.length, l);
+})();
+
+
+//
+// Test array modifications
+//
+(function() {
+ a = new constructor([1, 2, 3]);
+ a.findIndex(function(val, key) { a[key] = ++val; return false; });
+ assertArrayEquals([2, 3, 4], a);
+ assertEquals(3, a.length);
+})();
+
+
+//
+// Test thisArg
+//
+(function() {
+ // Test String as a thisArg
+ var index = new constructor([1, 2, 3]).findIndex(function(val, key) {
+ return this.charAt(Number(key)) === String(val);
+ }, "321");
+ assertEquals(1, index);
+
+ // Test object as a thisArg
+ var thisArg = {
+ elementAt: function(key) {
+ return this[key];
+ }
+ };
+ Array.prototype.push.apply(thisArg, [3, 2, 1]);
+
+ index = new constructor([1, 2, 3]).findIndex(function(val, key) {
+ return this.elementAt(key) === val;
+ }, thisArg);
+ assertEquals(1, index);
+
+ // Create a new object in each function call when receiver is a
+ // primitive value. See ECMA-262, Annex C.
+ a = [];
+ new constructor([1, 2]).findIndex(function() { a.push(this) }, "");
+ assertTrue(a[0] !== a[1]);
+
+ // Do not create a new object otherwise.
+ a = [];
+ new constructor([1, 2]).findIndex(function() { a.push(this) }, {});
+ assertEquals(a[0], a[1]);
+
+ // In strict mode primitive values should not be coerced to an object.
+ a = [];
+ new constructor([1, 2]).findIndex(function() { 'use strict'; a.push(this); }, "");
+ assertEquals("", a[0]);
+ assertEquals(a[0], a[1]);
+
+})();
+
+// Test exceptions
+assertThrows('constructor.prototype.findIndex.call(null, function() { })',
+ TypeError);
+assertThrows('constructor.prototype.findIndex.call(undefined, function() { })',
+ TypeError);
+assertThrows('constructor.prototype.findIndex.apply(null, function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.findIndex.apply(undefined, function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.findIndex.apply([], function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.findIndex.apply({}, function() { }, [])',
+ TypeError);
+assertThrows('constructor.prototype.findIndex.apply("", function() { }, [])',
+ TypeError);
+
+assertThrows('new constructor([]).findIndex(null)', TypeError);
+assertThrows('new constructor([]).findIndex(undefined)', TypeError);
+assertThrows('new constructor([]).findIndex(0)', TypeError);
+assertThrows('new constructor([]).findIndex(true)', TypeError);
+assertThrows('new constructor([]).findIndex(false)', TypeError);
+assertThrows('new constructor([]).findIndex("")', TypeError);
+assertThrows('new constructor([]).findIndex({})', TypeError);
+assertThrows('new constructor([]).findIndex([])', TypeError);
+assertThrows('new constructor([]).findIndex(/\d+/)', TypeError);
+
+// Shadowing length doesn't affect findIndex, unlike Array.prototype.findIndex
+a = new constructor([1, 2]);
+Object.defineProperty(a, 'length', {value: 1});
+var x = 0;
+assertEquals(a.findIndex(function(elt) { x += elt; return false; }), -1);
+assertEquals(x, 3);
+assertEquals(Array.prototype.findIndex.call(a,
+ function(elt) { x += elt; return false; }), -1);
+assertEquals(x, 4);
+
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-foreach.js b/deps/v8/test/mjsunit/es6/typedarray-foreach.js
new file mode 100644
index 0000000000..b9789805f6
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-foreach.js
@@ -0,0 +1,155 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+function CheckTypedArrayIsNeutered(array) {
+ assertEquals(0, array.byteLength);
+ assertEquals(0, array.byteOffset);
+ assertEquals(0, array.length);
+}
+
+function TestTypedArrayForEach(constructor) {
+ assertEquals(1, constructor.prototype.forEach.length);
+
+ var a = new constructor(2);
+ a[0] = 0;
+ a[1] = 1;
+
+ var count = 0;
+ a.forEach(function (n) { count++; });
+ assertEquals(2, count);
+
+ // Use specified object as this object when calling the function.
+ var o = { value: 42 };
+ var result = [];
+ a.forEach(function (n, index, array) { result.push(this.value); }, o);
+ assertArrayEquals([42, 42], result);
+
+ // Modify the original array.
+ count = 0;
+ a.forEach(function (n, index, array) { array[index] = n + 1; count++ });
+ assertEquals(2, count);
+ assertArrayEquals([1, 2], a);
+
+ // Check that values passed as second argument are wrapped into
+ // objects when calling into sloppy mode functions.
+ function CheckWrapping(value, wrapper) {
+ var wrappedValue = new wrapper(value);
+
+ a.forEach(function () {
+ assertEquals("object", typeof this);
+ assertEquals(wrappedValue, this);
+ }, value);
+
+ a.forEach(function () {
+ "use strict";
+ assertEquals(typeof value, typeof this);
+ assertEquals(value, this);
+ }, value);
+ }
+ CheckWrapping(true, Boolean);
+ CheckWrapping(false, Boolean);
+ CheckWrapping("xxx", String);
+ CheckWrapping(42, Number);
+ CheckWrapping(3.14, Number);
+ CheckWrapping({}, Object);
+
+ // Throw before completing iteration, only the first element
+ // should be modified when thorwing mid-way.
+ count = 0;
+ a[0] = 42;
+ a[1] = 42;
+ try {
+ a.forEach(function (n, index, array) {
+ if (count > 0) throw "meh";
+ array[index] = n + 1;
+ count++;
+ });
+ } catch (e) {
+ }
+ assertEquals(1, count);
+ assertEquals(43, a[0]);
+ assertEquals(42, a[1]);
+
+ // Neutering the buffer backing the typed array mid-way should
+ // still make .forEach() finish, but exiting early due to the missing
+ // elements, and the array should keep being empty after detaching it.
+ // TODO(dehrenberg): According to the ES6 spec, accessing or testing
+ // for members on a detached TypedArray should throw, so really this
+ // should throw in the third iteration. However, this behavior matches
+ // the Khronos spec.
+ a = new constructor(3);
+ count = 0;
+ a.forEach(function (n, index, array) {
+ if (count > 0) %ArrayBufferNeuter(array.buffer);
+ array[index] = n + 1;
+ count++;
+ });
+ assertEquals(2, count);
+ CheckTypedArrayIsNeutered(a);
+ assertEquals(undefined, a[0]);
+
+ // The method must work for typed arrays created from ArrayBuffer.
+ // The length of the ArrayBuffer is chosen so it is a multiple of
+ // all lengths of the typed array items.
+ a = new constructor(new ArrayBuffer(64));
+ count = 0;
+ a.forEach(function (n) { count++ });
+ assertEquals(a.length, count);
+
+ // Externalizing the array mid-way accessing the .buffer property
+ // should work.
+ a = new constructor(2);
+ count = 0;
+ var buffer = undefined;
+ a.forEach(function (n, index, array) {
+ if (count++ > 0)
+ buffer = array.buffer;
+ });
+ assertEquals(2, count);
+ assertTrue(!!buffer);
+ assertEquals("ArrayBuffer", %_ClassOf(buffer));
+ assertSame(buffer, a.buffer);
+
+ // The %TypedArray%.forEach() method should not work when
+ // transplanted to objects that are not typed arrays.
+ assertThrows(function () { constructor.prototype.forEach.call([1, 2, 3], function (x) {}) }, TypeError);
+ assertThrows(function () { constructor.prototype.forEach.call("abc", function (x) {}) }, TypeError);
+ assertThrows(function () { constructor.prototype.forEach.call({}, function (x) {}) }, TypeError);
+ assertThrows(function () { constructor.prototype.forEach.call(0, function (x) {}) }, TypeError);
+
+ // Method must be useable on instances of other typed arrays.
+ for (var i = 0; i < typedArrayConstructors.length; i++) {
+ count = 0;
+ a = new typedArrayConstructors[i](4);
+ constructor.prototype.forEach.call(a, function (x) { count++ });
+ assertEquals(a.length, count);
+ }
+
+ // Shadowing length doesn't affect forEach, unlike Array.prototype.forEach
+ a = new constructor([1, 2]);
+ Object.defineProperty(a, 'length', {value: 1});
+ var x = 0;
+ assertEquals(a.forEach(function(elt) { x += elt; }), undefined);
+ assertEquals(x, 3);
+ assertEquals(Array.prototype.forEach.call(a,
+ function(elt) { x += elt; }), undefined);
+ assertEquals(x, 4);
+}
+
+for (i = 0; i < typedArrayConstructors.length; i++) {
+ TestTypedArrayForEach(typedArrayConstructors[i]);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-from.js b/deps/v8/test/mjsunit/es6/typedarray-from.js
new file mode 100644
index 0000000000..709c453379
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-from.js
@@ -0,0 +1,121 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+for (var constructor of typedArrayConstructors) {
+ assertEquals(1, constructor.from.length);
+
+ // TypedArray.from only callable on this subclassing %TypedArray%
+ assertThrows(function () {constructor.from.call(Array, [])}, TypeError);
+
+ function assertArrayLikeEquals(value, expected, type) {
+ assertEquals(value.__proto__, type.prototype);
+ assertEquals(expected.length, value.length);
+ for (var i = 0; i < value.length; ++i) {
+ assertEquals(expected[i], value[i]);
+ }
+ }
+
+ // Assert that calling mapfn with / without thisArg in sloppy and strict modes
+ // works as expected.
+ var global = this;
+ function non_strict() { assertEquals(global, this); }
+ function strict() { 'use strict'; assertEquals(undefined, this); }
+ function strict_null() { 'use strict'; assertEquals(null, this); }
+ constructor.from([1], non_strict);
+ constructor.from([1], non_strict, void 0);
+ constructor.from([1], non_strict, null);
+ constructor.from([1], strict);
+ constructor.from([1], strict, void 0);
+ constructor.from([1], strict_null, null);
+
+ // TypedArray.from can only be called on TypedArray constructors
+ assertThrows(function() {constructor.from.call({}, [])}, TypeError);
+ assertThrows(function() {constructor.from.call([], [])}, TypeError);
+ assertThrows(function() {constructor.from.call(1, [])}, TypeError);
+ assertThrows(function() {constructor.from.call(undefined, [])}, TypeError);
+
+ // Converting from various other types, demonstrating that it can
+ // operate on array-like objects as well as iterables.
+ // TODO(littledan): constructors should have similar flexibility.
+ assertArrayLikeEquals(constructor.from(
+ { length: 1, 0: 5 }), [5], constructor);
+
+ assertArrayLikeEquals(constructor.from(
+ { length: -1, 0: 5 }), [], constructor);
+
+ assertArrayLikeEquals(constructor.from(
+ [1, 2, 3]), [1, 2, 3], constructor);
+
+ var set = new Set([1, 2, 3]);
+ assertArrayLikeEquals(constructor.from(set), [1, 2, 3],
+ constructor);
+
+ function* generator() {
+ yield 4;
+ yield 5;
+ yield 6;
+ }
+
+ assertArrayLikeEquals(constructor.from(generator()),
+ [4, 5, 6], constructor);
+
+ assertThrows(function() { constructor.from(null); }, TypeError);
+ assertThrows(function() { constructor.from(undefined); }, TypeError);
+ assertThrows(function() { constructor.from([], null); }, TypeError);
+ assertThrows(function() { constructor.from([], 'noncallable'); },
+ TypeError);
+
+ var nullIterator = {};
+ nullIterator[Symbol.iterator] = null;
+ assertArrayLikeEquals(constructor.from(nullIterator), [],
+ constructor);
+
+ var nonObjIterator = {};
+ nonObjIterator[Symbol.iterator] = function() { return 'nonObject'; };
+ assertThrows(function() { constructor.from(nonObjIterator); },
+ TypeError);
+
+ assertThrows(function() { constructor.from([], null); }, TypeError);
+
+ // Ensure iterator is only accessed once, and only invoked once
+ var called = 0;
+ var arr = [1, 2, 3];
+ var obj = {};
+ var counter = 0;
+
+ // Test order --- only get iterator method once
+ function testIterator() {
+ called++;
+ assertEquals(obj, this);
+ return arr[Symbol.iterator]();
+ }
+ var getCalled = 0;
+ Object.defineProperty(obj, Symbol.iterator, {
+ get: function() {
+ getCalled++;
+ return testIterator;
+ },
+ set: function() {
+ assertUnreachable('@@iterator should not be set');
+ }
+ });
+ assertArrayLikeEquals(constructor.from(obj), [1, 2, 3], constructor);
+ assertEquals(getCalled, 1);
+ assertEquals(called, 1);
+
+ assertEquals(constructor, Uint8Array.from.call(constructor, [1]).constructor);
+ assertEquals(Uint8Array, constructor.from.call(Uint8Array, [1]).constructor);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-indexing.js b/deps/v8/test/mjsunit/es6/typedarray-indexing.js
new file mode 100644
index 0000000000..44472e3eb3
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-indexing.js
@@ -0,0 +1,71 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+for (var constructor of typedArrayConstructors) {
+ var array = new constructor([1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]);
+
+ // ----------------------------------------------------------------------
+ // %TypedArray%.prototype.indexOf.
+ // ----------------------------------------------------------------------
+
+ // Negative cases.
+ assertEquals(-1, new constructor([]).indexOf(1));
+ assertEquals(-1, array.indexOf(4));
+ assertEquals(-1, array.indexOf(3, array.length));
+
+ assertEquals(2, array.indexOf(3));
+ // Negative index out of range.
+ assertEquals(0, array.indexOf(1, -17));
+ // Negative index in rage.
+ assertEquals(3, array.indexOf(1, -11));
+ // Index in range.
+ assertEquals(3, array.indexOf(1, 1));
+ assertEquals(3, array.indexOf(1, 3));
+ assertEquals(6, array.indexOf(1, 4));
+
+ // Basic TypedArray function properties
+ assertEquals(1, array.indexOf.length);
+ assertThrows(function(){ array.indexOf.call([1], 1); }, TypeError);
+ Object.defineProperty(array, 'length', {value: 1});
+ assertEquals(array.indexOf(2), 1);
+
+
+ // ----------------------------------------------------------------------
+ // %TypedArray%.prototype.lastIndexOf.
+ // ----------------------------------------------------------------------
+ array = new constructor([1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]);
+
+ // Negative cases.
+ assertEquals(-1, new constructor([]).lastIndexOf(1));
+ assertEquals(-1, array.lastIndexOf(1, -17));
+
+ assertEquals(9, array.lastIndexOf(1));
+ // Index out of range.
+ assertEquals(9, array.lastIndexOf(1, array.length));
+ // Index in range.
+ assertEquals(0, array.lastIndexOf(1, 2));
+ assertEquals(3, array.lastIndexOf(1, 4));
+ assertEquals(3, array.lastIndexOf(1, 3));
+ // Negative index in range.
+ assertEquals(0, array.lastIndexOf(1, -11));
+
+ // Basic TypedArray function properties
+ assertEquals(1, array.lastIndexOf.length);
+ assertThrows(function(){ array.lastIndexOf.call([1], 1); }, TypeError);
+ Object.defineProperty(array, 'length', {value: 1});
+ assertEquals(array.lastIndexOf(2), 10);
+ delete array.length;
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-iteration.js b/deps/v8/test/mjsunit/es6/typedarray-iteration.js
new file mode 100644
index 0000000000..9560cbc5df
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-iteration.js
@@ -0,0 +1,194 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Tests for standard TypedArray array iteration functions.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+function assertArrayLikeEquals(expected, value, type) {
+ assertEquals(value.__proto__, type.prototype);
+ assertEquals(expected.length, value.length);
+ for (var i = 0; i < value.length; ++i) {
+ assertEquals(expected[i], value[i]);
+ }
+}
+
+for (var constructor of typedArrayConstructors) {
+ (function TypedArrayFilterTest() {
+ // Simple use.
+ var a = new constructor([0, 1]);
+ assertArrayLikeEquals([0], a.filter(function(n) { return n == 0; }),
+ constructor);
+ assertArrayLikeEquals([0, 1], a, constructor);
+
+ // Use specified object as this object when calling the function.
+ var o = { value: 42 }
+ a = new constructor([1, 42, 3, 42, 4]);
+ assertArrayLikeEquals([42, 42], a.filter(function(n) {
+ return this.value == n
+ }, o), constructor);
+
+ // Modify original array.
+ a = new constructor([1, 42, 3, 42, 4]);
+ assertArrayLikeEquals([42, 42], a.filter(function(n, index, array) {
+ array[index] = 43; return 42 == n;
+ }), constructor);
+ assertArrayLikeEquals([43, 43, 43, 43, 43], a, constructor);
+
+ // Create a new object in each function call when receiver is a
+ // primitive value. See ECMA-262, Annex C.
+ a = [];
+ new constructor([1, 2]).filter(function() { a.push(this) }, '');
+ assertTrue(a[0] !== a[1]);
+
+ // Do not create a new object otherwise.
+ a = [];
+ new constructor([1, 2]).filter(function() { a.push(this) }, {});
+ assertEquals(a[0], a[1]);
+
+ // In strict mode primitive values should not be coerced to an object.
+ a = [];
+ new constructor([1, 2]).filter(function() {
+ 'use strict';
+ a.push(this);
+ }, '');
+ assertEquals('', a[0]);
+ assertEquals(a[0], a[1]);
+
+ // Calling this method on other types is a TypeError
+ assertThrows(function() {
+ constructor.prototype.filter.call([], function() {});
+ }, TypeError);
+
+ // Shadowing the length property doesn't change anything
+ a = new constructor([1, 2]);
+ Object.defineProperty(a, 'length', { value: 1 });
+ assertArrayLikeEquals([2], a.filter(function(elt) {
+ return elt == 2;
+ }), constructor);
+ })();
+
+ (function TypedArrayMapTest() {
+ var a = new constructor([0, 1, 2, 3, 4]);
+
+ // Simple use.
+ var result = [1, 2, 3, 4, 5];
+ assertArrayLikeEquals(result, a.map(function(n) { return n + 1; }),
+ constructor);
+ assertEquals(a, a);
+
+ // Use specified object as this object when calling the function.
+ var o = { delta: 42 }
+ result = [42, 43, 44, 45, 46];
+ assertArrayLikeEquals(result, a.map(function(n) {
+ return this.delta + n;
+ }, o), constructor);
+
+ // Modify original array.
+ a = new constructor([0, 1, 2, 3, 4]);
+ result = [1, 2, 3, 4, 5];
+ assertArrayLikeEquals(result, a.map(function(n, index, array) {
+ array[index] = n + 1;
+ return n + 1;
+ }), constructor);
+ assertArrayLikeEquals(result, a, constructor);
+
+ // Create a new object in each function call when receiver is a
+ // primitive value. See ECMA-262, Annex C.
+ a = [];
+ new constructor([1, 2]).map(function() { a.push(this) }, '');
+ assertTrue(a[0] !== a[1]);
+
+ // Do not create a new object otherwise.
+ a = [];
+ new constructor([1, 2]).map(function() { a.push(this) }, {});
+ assertEquals(a[0], a[1]);
+
+ // In strict mode primitive values should not be coerced to an object.
+ a = [];
+ new constructor([1, 2]).map(function() { 'use strict'; a.push(this); }, '');
+ assertEquals('', a[0]);
+ assertEquals(a[0], a[1]);
+
+ // Test that the result is converted to the right type
+ assertArrayLikeEquals([3, 3], new constructor([1, 2]).map(function() {
+ return "3";
+ }), constructor);
+ if (constructor !== Float32Array && constructor !== Float64Array) {
+ assertArrayLikeEquals([0, 0], new constructor([1, 2]).map(function() {
+ return NaN;
+ }), constructor);
+ }
+ })();
+
+ //
+ // %TypedArray%.prototype.some
+ //
+ (function TypedArraySomeTest() {
+ var a = new constructor([0, 1, 2, 3, 4]);
+
+ // Simple use.
+ assertTrue(a.some(function(n) { return n == 3}));
+ assertFalse(a.some(function(n) { return n == 5}));
+
+ // Use specified object as this object when calling the function.
+ var o = { element: 42 };
+ a = new constructor([1, 42, 3]);
+ assertTrue(a.some(function(n) { return this.element == n; }, o));
+ a = new constructor([1]);
+ assertFalse(a.some(function(n) { return this.element == n; }, o));
+
+ // Modify original array.
+ a = new constructor([0, 1, 2, 3]);
+ assertTrue(a.some(function(n, index, array) {
+ array[index] = n + 1;
+ return n == 2;
+ }));
+ assertArrayLikeEquals([1, 2, 3, 3], a, constructor);
+
+ // Create a new object in each function call when receiver is a
+ // primitive value. See ECMA-262, Annex C.
+ a = [];
+ new constructor([1, 2]).some(function() { a.push(this) }, '');
+ assertTrue(a[0] !== a[1]);
+
+ // Do not create a new object otherwise.
+ a = [];
+ new constructor([1, 2]).some(function() { a.push(this) }, {});
+ assertEquals(a[0], a[1]);
+
+ // In strict mode primitive values should not be coerced to an object.
+ a = [];
+ new constructor([1, 2]).some(function() {
+ 'use strict';
+ a.push(this);
+ }, '');
+ assertEquals('', a[0]);
+ assertEquals(a[0], a[1]);
+
+ // Calling this method on other types is a TypeError
+ assertThrows(function() {
+ constructor.prototype.some.call([], function() {});
+ }, TypeError);
+
+ // Shadowing the length property doesn't change anything
+ a = new constructor([1, 2]);
+ Object.defineProperty(a, 'length', { value: 1 });
+ assertEquals(true, a.some(function(elt) { return elt == 2; }));
+ assertEquals(false, Array.prototype.some.call(a, function(elt) {
+ return elt == 2;
+ }));
+ })();
+
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-of.js b/deps/v8/test/mjsunit/es6/typedarray-of.js
new file mode 100644
index 0000000000..cf57615d12
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-of.js
@@ -0,0 +1,133 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/source/js/src/jit-test/tests/collections
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+
+function TestTypedArrayOf(constructor) {
+ // %TypedArray%.of basics.
+ var a = constructor.of();
+ assertEquals(0, a.length);
+ assertEquals(constructor.prototype, Object.getPrototypeOf(a));
+ assertEquals(false, Array.isArray(a));
+
+ // Items are coerced to numerical values.
+ a = constructor.of(undefined, null, [], true, false, 3.14);
+
+ // For typed arrays of floating point values, values are not rounded.
+ if (constructor === Float32Array || constructor === Float64Array) {
+ assertEquals(NaN, a[0]);
+ assertEquals(0, a[1]);
+ assertEquals(0, a[2]);
+ assertEquals(1, a[3]);
+ assertEquals(0, a[4]);
+ assertEquals(true, Math.abs(a[5] - 3.14) < 1e-6);
+ } else {
+ assertEquals(0, a[0]);
+ assertEquals(0, a[1]);
+ assertEquals(0, a[2]);
+ assertEquals(1, a[3]);
+ assertEquals(0, a[4]);
+ assertEquals(3, a[5]);
+ }
+
+ var aux = [];
+ for (var i = 0; i < 100; i++)
+ aux[i] = i;
+
+ a = constructor.of.apply(constructor, aux);
+ assertEquals(aux.length, a.length);
+ assertArrayEquals(aux, a);
+
+ // %TypedArray%.of can be transplanted to other constructors.
+ var hits = 0;
+ function Bag(length) {
+ assertEquals(arguments.length, 1);
+ assertEquals(length, 2);
+ this.length = length;
+ hits++;
+ }
+ Bag.of = constructor.of;
+
+ hits = 0;
+ a = Bag.of("zero", "one");
+ assertEquals(1, hits);
+ assertEquals(2, a.length);
+ assertArrayEquals(["zero", "one"], a);
+ assertEquals(Bag.prototype, a.__proto__);
+
+ hits = 0;
+ actual = constructor.of.call(Bag, "zero", "one");
+ assertEquals(1, hits);
+ assertEquals(2, a.length);
+ assertArrayEquals(["zero", "one"], a);
+ assertEquals(Bag.prototype, a.__proto__);
+
+ // %TypedArray%.of does not trigger prototype setters.
+ // (It defines elements rather than assigning to them.)
+ var status = "pass";
+ Object.defineProperty(constructor.prototype, "0", {
+ set: function(v) { status = "fail"; }
+ });
+ assertEquals(1, constructor.of(1)[0], 1);
+ assertEquals("pass", status);
+
+ // Note that %TypedArray%.of does not trigger "length" setter itself, as
+ // it relies on the constructor to set "length" to the value passed to it.
+ // If the constructor does not assign "length", the setter should not be
+ // invoked.
+
+ // Setter on the newly created object.
+ function Pack() {
+ Object.defineProperty(this, "length", {
+ set: function (v) { status = "fail"; }
+ });
+ }
+ Pack.of = constructor.of;
+ var pack = Pack.of("wolves", "cards", "cigarettes", "lies");
+ assertEquals("pass", status);
+
+ // when the setter is on the new object's prototype
+ function Bevy() {}
+ Object.defineProperty(Bevy.prototype, "length", {
+ set: function (v) { status = "fail"; }
+ });
+ Bevy.of = constructor.of;
+ var bevy = Bevy.of("quail");
+ assertEquals("pass", status);
+
+ // Check superficial features of %TypedArray%.of.
+ var desc = Object.getOwnPropertyDescriptor(constructor, "of");
+
+ assertEquals(desc.configurable, false);
+ assertEquals(desc.enumerable, false);
+ assertEquals(desc.writable, false);
+ assertEquals(constructor.of.length, 0);
+
+ // %TypedArray%.of is not a constructor.
+ assertThrows(function() { new constructor.of(); }, TypeError);
+
+ // For receivers which are not constructors %TypedArray%.of does not
+ // allocate a typed array using a default constructor, but throws an
+ // exception. Note that this is different from Array.of, which uses
+ // Array as default constructor.
+ for (var x of [undefined, null, false, true, "cow", 42, 3.14]) {
+ assertThrows(function () { constructor.of.call(x); }, TypeError);
+ }
+}
+
+for (var constructor of typedArrayConstructors) {
+ TestTypedArrayOf(constructor);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-proto.js b/deps/v8/test/mjsunit/es6/typedarray-proto.js
new file mode 100644
index 0000000000..558cb0ad7a
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-proto.js
@@ -0,0 +1,42 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Test that the methods for different TypedArray types have the same
+// identity.
+// TODO(dehrenberg): Test that the TypedArray proto hierarchy is set
+// up properly.
+// TODO(dehrenberg): subarray is currently left out because that still
+// uses per-type methods. When that's fixed, stop leaving it out.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+function functionProperties(object) {
+ return Object.getOwnPropertyNames(object).filter(function(name) {
+ return typeof Object.getOwnPropertyDescriptor(object, name).value
+ == "function"
+ && name != 'constructor' && name != 'subarray';
+ });
+}
+
+var typedArrayMethods = functionProperties(Uint8Array.prototype);
+var typedArrayClassMethods = functionProperties(Uint8Array);
+
+for (var constructor of typedArrayConstructors) {
+ for (var method of typedArrayMethods) {
+ assertEquals(constructor.prototype[method],
+ Uint8Array.prototype[method], method);
+ }
+ for (var classMethod of typedArrayClassMethods) {
+ assertEquals(constructor[method], Uint8Array[method], classMethod);
+ }
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-reduce.js b/deps/v8/test/mjsunit/es6/typedarray-reduce.js
new file mode 100644
index 0000000000..1fddeca0bc
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-reduce.js
@@ -0,0 +1,250 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+function clone(v) {
+ // Shallow-copies arrays, returns everything else verbatim.
+ if (v instanceof Array) {
+ // Shallow-copy an array.
+ var newArray = new Array(v.length);
+ for (var i in v) {
+ newArray[i] = v[i];
+ }
+ return newArray;
+ }
+ return v;
+}
+
+
+// Creates a callback function for reduce/reduceRight that tests the number
+// of arguments and otherwise behaves as "func", but which also
+// records all calls in an array on the function (as arrays of arguments
+// followed by result).
+function makeRecorder(func, testName) {
+ var record = [];
+ var f = function recorder(a, b, i, s) {
+ assertEquals(4, arguments.length,
+ testName + "(number of arguments: " + arguments.length + ")");
+ assertEquals("number", typeof(i), testName + "(index must be number)");
+ assertEquals(s[i], b, testName + "(current argument is at index)");
+ if (record.length > 0) {
+ var prevRecord = record[record.length - 1];
+ var prevResult = prevRecord[prevRecord.length - 1];
+ assertEquals(prevResult, a,
+ testName + "(prev result -> current input)");
+ }
+ var args = [clone(a), clone(b), i, clone(s)];
+ var result = func.apply(this, arguments);
+ args.push(clone(result));
+ record.push(args);
+ return result;
+ };
+ f.record = record;
+ return f;
+}
+
+
+function testReduce(type,
+ testName,
+ expectedResult,
+ expectedCalls,
+ array,
+ combine,
+ init) {
+ var rec = makeRecorder(combine);
+ var result;
+ var performsCall;
+ if (arguments.length > 6) {
+ result = array[type](rec, init);
+ } else {
+ result = array[type](rec);
+ }
+ var calls = rec.record;
+ assertEquals(expectedCalls.length, calls.length,
+ testName + " (number of calls)");
+ for (var i = 0; i < expectedCalls.length; i++) {
+ assertEquals(expectedCalls[i], calls[i],
+ testName + " (call " + (i + 1) + ")");
+ }
+ assertEquals(expectedResult, result, testName + " (result)");
+}
+
+
+function sum(a, b) { return a + b; }
+function prod(a, b) { return a * b; }
+function dec(a, b, i, arr) { return a + b * Math.pow(10, arr.length - i - 1); }
+function accumulate(acc, elem, i) { acc[i] = elem; return acc; }
+
+for (var constructor of typedArrayConstructors) {
+ // ---- Test Reduce[Left]
+
+ var simpleArray = new constructor([2,4,6])
+
+ testReduce("reduce", "SimpleReduceSum", 12,
+ [[0, 2, 0, simpleArray, 2],
+ [2, 4, 1, simpleArray, 6],
+ [6, 6, 2, simpleArray, 12]],
+ simpleArray, sum, 0);
+
+ testReduce("reduce", "SimpleReduceProd", 48,
+ [[1, 2, 0, simpleArray, 2],
+ [2, 4, 1, simpleArray, 8],
+ [8, 6, 2, simpleArray, 48]],
+ simpleArray, prod, 1);
+
+ testReduce("reduce", "SimpleReduceDec", 246,
+ [[0, 2, 0, simpleArray, 200],
+ [200, 4, 1, simpleArray, 240],
+ [240, 6, 2, simpleArray, 246]],
+ simpleArray, dec, 0);
+
+ testReduce("reduce", "SimpleReduceAccumulate", [2, 4, 6],
+ [[[], 2, 0, simpleArray, [2]],
+ [[2], 4, 1, simpleArray, [2, 4]],
+ [[2,4], 6, 2, simpleArray, [2, 4, 6]]],
+ simpleArray, accumulate, []);
+
+
+ testReduce("reduce", "EmptyReduceSum", 0, [], new constructor([]), sum, 0);
+ testReduce("reduce", "EmptyReduceProd", 1, [], new constructor([]), prod, 1);
+ testReduce("reduce", "EmptyReduceDec", 0, [], new constructor([]), dec, 0);
+ testReduce("reduce", "EmptyReduceAccumulate", [], [], new constructor([]), accumulate, []);
+
+ testReduce("reduce", "EmptyReduceSumNoInit", 0, [], new constructor([0]), sum);
+ testReduce("reduce", "EmptyReduceProdNoInit", 1, [], new constructor([1]), prod);
+ testReduce("reduce", "EmptyReduceDecNoInit", 0, [], new constructor([0]), dec);
+
+ // ---- Test ReduceRight
+
+ testReduce("reduceRight", "SimpleReduceRightSum", 12,
+ [[0, 6, 2, simpleArray, 6],
+ [6, 4, 1, simpleArray, 10],
+ [10, 2, 0, simpleArray, 12]],
+ simpleArray, sum, 0);
+
+ testReduce("reduceRight", "SimpleReduceRightProd", 48,
+ [[1, 6, 2, simpleArray, 6],
+ [6, 4, 1, simpleArray, 24],
+ [24, 2, 0, simpleArray, 48]],
+ simpleArray, prod, 1);
+
+ testReduce("reduceRight", "SimpleReduceRightDec", 246,
+ [[0, 6, 2, simpleArray, 6],
+ [6, 4, 1, simpleArray, 46],
+ [46, 2, 0, simpleArray, 246]],
+ simpleArray, dec, 0);
+
+
+ testReduce("reduceRight", "EmptyReduceRightSum", 0, [], new constructor([]), sum, 0);
+ testReduce("reduceRight", "EmptyReduceRightProd", 1, [], new constructor([]), prod, 1);
+ testReduce("reduceRight", "EmptyReduceRightDec", 0, [], new constructor([]), dec, 0);
+ testReduce("reduceRight", "EmptyReduceRightAccumulate", [],
+ [], new constructor([]), accumulate, []);
+
+ testReduce("reduceRight", "EmptyReduceRightSumNoInit", 0, [], new constructor([0]), sum);
+ testReduce("reduceRight", "EmptyReduceRightProdNoInit", 1, [], new constructor([1]), prod);
+ testReduce("reduceRight", "EmptyReduceRightDecNoInit", 0, [], new constructor([0]), dec);
+
+ // Ignore non-array properties:
+
+ var arrayPlus = new constructor([1,2,3]);
+ arrayPlus[-1] = NaN;
+ arrayPlus["00"] = NaN;
+ arrayPlus["02"] = NaN;
+ arrayPlus["-0"] = NaN;
+ arrayPlus.x = NaN;
+
+ testReduce("reduce", "ArrayWithNonElementPropertiesReduce", 6,
+ [[0, 1, 0, arrayPlus, 1],
+ [1, 2, 1, arrayPlus, 3],
+ [3, 3, 2, arrayPlus, 6],
+ ], arrayPlus, sum, 0);
+
+ testReduce("reduceRight", "ArrayWithNonElementPropertiesReduceRight", 6,
+ [[0, 3, 2, arrayPlus, 3],
+ [3, 2, 1, arrayPlus, 5],
+ [5, 1, 0, arrayPlus, 6],
+ ], arrayPlus, sum, 0);
+
+
+ // Test error conditions:
+
+ var exception = false;
+ try {
+ new constructor([1]).reduce("not a function");
+ } catch (e) {
+ exception = true;
+ assertTrue(e instanceof TypeError,
+ "reduce callback not a function not throwing TypeError");
+ assertTrue(e.message.indexOf(" is not a function") >= 0,
+ "reduce non function TypeError type");
+ }
+ assertTrue(exception);
+
+ exception = false;
+ try {
+ new constructor([1]).reduceRight("not a function");
+ } catch (e) {
+ exception = true;
+ assertTrue(e instanceof TypeError,
+ "reduceRight callback not a function not throwing TypeError");
+ assertTrue(e.message.indexOf(" is not a function") >= 0,
+ "reduceRight non function TypeError type");
+ }
+ assertTrue(exception);
+
+ exception = false;
+ try {
+ new constructor([]).reduce(sum);
+ } catch (e) {
+ exception = true;
+ assertTrue(e instanceof TypeError,
+ "reduce no initial value not throwing TypeError");
+ assertEquals("Reduce of empty array with no initial value", e.message,
+ "reduce no initial TypeError type");
+ }
+ assertTrue(exception);
+
+ exception = false;
+ try {
+ new constructor([]).reduceRight(sum);
+ } catch (e) {
+ exception = true;
+ assertTrue(e instanceof TypeError,
+ "reduceRight no initial value not throwing TypeError");
+ assertEquals("Reduce of empty array with no initial value", e.message,
+ "reduceRight no initial TypeError type");
+ }
+ assertTrue(exception);
+
+ // Reduce fails when called on non-TypedArrays
+ assertThrows(function() {
+ constructor.prototype.reduce.call([], function() {}, null);
+ }, TypeError);
+ assertThrows(function() {
+ constructor.prototype.reduceRight.call([], function() {}, null);
+ }, TypeError);
+
+ // Shadowing length doesn't affect every, unlike Array.prototype.every
+ var a = new constructor([1, 2]);
+ Object.defineProperty(a, 'length', {value: 1});
+ assertEquals(a.reduce(sum, 0), 3);
+ assertEquals(Array.prototype.reduce.call(a, sum, 0), 1);
+ assertEquals(a.reduceRight(sum, 0), 3);
+ assertEquals(Array.prototype.reduceRight.call(a, sum, 0), 1);
+
+ assertEquals(1, constructor.prototype.reduce.length);
+ assertEquals(1, constructor.prototype.reduceRight.length);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-reverse.js b/deps/v8/test/mjsunit/es6/typedarray-reverse.js
new file mode 100644
index 0000000000..f32813e155
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-reverse.js
@@ -0,0 +1,54 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function ArrayMaker(x) {
+ return x;
+}
+ArrayMaker.prototype = Array.prototype;
+
+var arrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array,
+ ArrayMaker // Also test arrays
+];
+
+function assertArrayLikeEquals(value, expected, type) {
+ assertEquals(value.__proto__, type.prototype);
+ assertEquals(expected.length, value.length);
+ for (var i = 0; i < value.length; ++i) {
+ assertEquals(expected[i], value[i]);
+ }
+}
+
+for (var constructor of arrayConstructors) {
+ // Test reversing both even and odd length arrays
+ var a = new constructor([1, 2, 3]);
+ assertArrayLikeEquals(a.reverse(), [3, 2, 1], constructor);
+ assertArrayLikeEquals(a, [3, 2, 1], constructor);
+
+ a = new constructor([1, 2, 3, 4]);
+ assertArrayLikeEquals(a.reverse(), [4, 3, 2, 1], constructor);
+ assertArrayLikeEquals(a, [4, 3, 2, 1], constructor);
+
+ if (constructor != ArrayMaker) {
+ // Cannot be called on objects which are not TypedArrays
+ assertThrows(function () { a.reverse.call({ length: 0 }); }, TypeError);
+ } else {
+ // Array.reverse works on array-like objects
+ var x = { length: 2, 1: 5 };
+ a.reverse.call(x);
+ assertEquals(2, x.length);
+ assertFalse(Object.hasOwnProperty(x, '1'));
+ assertEquals(5, x[0]);
+ }
+
+ assertEquals(0, a.reverse.length);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-slice.js b/deps/v8/test/mjsunit/es6/typedarray-slice.js
new file mode 100644
index 0000000000..ddd021a8fa
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-slice.js
@@ -0,0 +1,71 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+for (var constructor of typedArrayConstructors) {
+ // Check various variants of empty array's slicing.
+ var array = new constructor(0);
+ for (var i = 0; i < 7; i++) {
+ assertEquals(0, array.slice(0, 0).length);
+ assertEquals(0, array.slice(1, 0).length);
+ assertEquals(0, array.slice(0, 1).length);
+ assertEquals(0, array.slice(-1, 0).length);
+ }
+
+
+ // Check various forms of arguments omission.
+ array = new constructor(7);
+
+ for (var i = 0; i < 7; i++) {
+ assertEquals(array, array.slice());
+ assertEquals(array, array.slice(0));
+ assertEquals(array, array.slice(undefined));
+ assertEquals(array, array.slice("foobar"));
+ assertEquals(array, array.slice(undefined, undefined));
+ }
+
+
+ // Check variants of negatives and positive indices.
+ array = new constructor(7);
+
+ assertEquals(7, array.slice(-100).length);
+ assertEquals(3, array.slice(-3).length);
+ assertEquals(3, array.slice(4).length);
+ assertEquals(1, array.slice(6).length);
+ assertEquals(0, array.slice(7).length);
+ assertEquals(0, array.slice(8).length);
+ assertEquals(0, array.slice(100).length);
+
+ assertEquals(0, array.slice(0, -100).length);
+ assertEquals(4, array.slice(0, -3).length);
+ assertEquals(4, array.slice(0, 4).length);
+ assertEquals(6, array.slice(0, 6).length);
+ assertEquals(7, array.slice(0, 7).length);
+ assertEquals(7, array.slice(0, 8).length);
+ assertEquals(7, array.slice(0, 100).length);
+
+ // Does not permit being called on other types
+ assertThrows(function () {
+ constructor.prototype.slice.call([], 0, 0);
+ }, TypeError);
+
+ // Check that elements are copied properly in slice
+ array = new constructor([1, 2, 3, 4]);
+ var slice = array.slice(1, 3);
+ assertEquals(2, slice.length);
+ assertEquals(2, slice[0]);
+ assertEquals(3, slice[1]);
+ assertTrue(slice instanceof constructor);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-sort.js b/deps/v8/test/mjsunit/es6/typedarray-sort.js
new file mode 100644
index 0000000000..4fb8469075
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-sort.js
@@ -0,0 +1,55 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+function assertArrayLikeEquals(value, expected, type) {
+ assertEquals(value.__proto__, type.prototype);
+ // Don't test value.length because we mess with that;
+ // instead in certain callsites we check that length
+ // is set appropriately.
+ for (var i = 0; i < expected.length; ++i) {
+ // Use Object.is to differentiate between +-0
+ assertSame(expected[i], value[i]);
+ }
+}
+
+for (var constructor of typedArrayConstructors) {
+ // Test default numerical sorting order
+ var a = new constructor([100, 7, 45])
+ assertEquals(a.sort(), a);
+ assertArrayLikeEquals(a, [7, 45, 100], constructor);
+ assertEquals(a.length, 3);
+
+ // For arrays of floats, certain handling of +-0/NaN
+ if (constructor === Float32Array || constructor === Float64Array) {
+ var b = new constructor([+0, -0, NaN, -0, NaN, +0])
+ b.sort();
+ assertArrayLikeEquals(b, [-0, -0, +0, +0, NaN, NaN], constructor);
+ assertEquals(b.length, 6);
+ }
+
+ // Custom sort--backwards
+ a.sort(function(x, y) { return y - x; });
+ assertArrayLikeEquals(a, [100, 45, 7], constructor);
+
+ // Basic TypedArray method properties:
+ // Length field is ignored
+ Object.defineProperty(a, 'length', {value: 1});
+ assertEquals(a.sort(), a);
+ assertArrayLikeEquals(a, [7, 45, 100], constructor);
+ assertEquals(a.length, 1);
+ // Method doesn't work on other objects
+ assertThrows(function() { a.sort.call([]); }, TypeError);
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray-tostring.js b/deps/v8/test/mjsunit/es6/typedarray-tostring.js
new file mode 100644
index 0000000000..e6adda0405
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-tostring.js
@@ -0,0 +1,86 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Array's toString should call the object's own join method, if one exists and
+// is callable. Otherwise, just use the original Object.toString function.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+for (var constructor of typedArrayConstructors) {
+ var success = "[test success]";
+ var expectedThis;
+ function testJoin() {
+ assertEquals(0, arguments.length);
+ assertSame(expectedThis, this);
+ return success;
+ }
+
+
+ // On an Array object.
+
+ // Default case.
+ var a1 = new constructor([1, 2, 3]);
+ assertEquals("1,2,3", a1.toString());
+ assertEquals("1,2,3", a1.join());
+ assertEquals("1,2,3", a1.toLocaleString());
+
+ // Non-standard "join" function is called correctly.
+ var a2 = new constructor([1, 2, 3]);
+ a2.join = testJoin;
+ expectedThis = a2;
+ assertEquals(success, a2.toString());
+ assertEquals(success, a2.join());
+ assertEquals("1,2,3", a2.toLocaleString());
+
+ // Non-callable join function is ignored and Object.prototype.toString is
+ // used instead.
+ var a3 = new constructor([1, 2, 3]);
+ a3.join = "not callable";
+ assertEquals(0, a3.toString().search(/\[object .+Array\]/));
+
+ // Non-existing join function is treated same as non-callable.
+ var a4 = new constructor([1, 2, 3]);
+ a4.__proto__ = { toString: constructor.prototype.toString };
+ // No join on Array.
+ assertEquals(0, a3.toString().search(/\[object .+Array\]/));
+
+
+ // On a non-Array object, throws.
+ var o1 = {length: 3, 0: 1, 1: 2, 2: 3,
+ toString: constructor.prototype.toString,
+ join: constructor.prototype.join,
+ toLocaleString: constructor.prototype.toLocaleString};
+ assertThrows(function() { o1.join() }, TypeError);
+ assertThrows(function() { o1.toString() }, TypeError);
+ assertThrows(function() { o1.toLocaleString() }, TypeError);
+ // toString is OK if join not from here:
+ o1.join = Array.prototype.join;
+ assertEquals("1,2,3", o1.join());
+ assertEquals("1,2,3", o1.toString());
+ assertThrows(function() { o1.toLocaleString() }, TypeError);
+ // TODO(littledan): Use the same function for TypedArray as for
+ // Array, as the spec says (but Firefox doesn't do either).
+ // Currently, using the same method leads to a bootstrap failure.
+ // assertEquals(o1.toString, Array.prototype.toString);
+
+ // Redefining length does not change result
+ var a5 = new constructor([1, 2, 3])
+ Object.defineProperty(a5, 'length', { value: 2 });
+ assertEquals("1,2,3", a5.join());
+ assertEquals("1,2,3", a5.toString());
+ assertEquals("1,2,3", a5.toLocaleString());
+ assertEquals("1,2", Array.prototype.join.call(a5));
+ assertEquals("1,2,3", Array.prototype.toString.call(a5));
+ assertEquals("1,2", Array.prototype.toLocaleString.call(a5));
+}
diff --git a/deps/v8/test/mjsunit/es6/typedarray.js b/deps/v8/test/mjsunit/es6/typedarray.js
new file mode 100644
index 0000000000..ef7955ce92
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray.js
@@ -0,0 +1,758 @@
+// Copyright 2013 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// Flags: --harmony-tostring
+
+// ArrayBuffer
+
+function TestByteLength(param, expectedByteLength) {
+ var ab = new ArrayBuffer(param);
+ assertSame(expectedByteLength, ab.byteLength);
+}
+
+function TestArrayBufferCreation() {
+ TestByteLength(1, 1);
+ TestByteLength(256, 256);
+ TestByteLength(2.567, 2);
+
+ TestByteLength("abc", 0);
+
+ TestByteLength(0, 0);
+
+ assertThrows(function() { new ArrayBuffer(-10); }, RangeError);
+ assertThrows(function() { new ArrayBuffer(-2.567); }, RangeError);
+
+/* TODO[dslomov]: Reenable the test
+ assertThrows(function() {
+ var ab1 = new ArrayBuffer(0xFFFFFFFFFFFF)
+ }, RangeError);
+*/
+
+ var ab = new ArrayBuffer();
+ assertSame(0, ab.byteLength);
+ assertEquals("[object ArrayBuffer]",
+ Object.prototype.toString.call(ab));
+}
+
+TestArrayBufferCreation();
+
+function TestByteLengthNotWritable() {
+ var ab = new ArrayBuffer(1024);
+ assertSame(1024, ab.byteLength);
+
+ assertThrows(function() { "use strict"; ab.byteLength = 42; }, TypeError);
+}
+
+TestByteLengthNotWritable();
+
+function TestSlice(expectedResultLen, initialLen, start, end) {
+ var ab = new ArrayBuffer(initialLen);
+ var a1 = new Uint8Array(ab);
+ for (var i = 0; i < a1.length; i++) {
+ a1[i] = 0xCA;
+ }
+ var slice = ab.slice(start, end);
+ assertSame(expectedResultLen, slice.byteLength);
+ var a2 = new Uint8Array(slice);
+ for (var i = 0; i < a2.length; i++) {
+ assertSame(0xCA, a2[i]);
+ }
+}
+
+function TestArrayBufferSlice() {
+ var ab = new ArrayBuffer(1024);
+ var ab1 = ab.slice(512, 1024);
+ assertSame(512, ab1.byteLength);
+
+ TestSlice(512, 1024, 512, 1024);
+ TestSlice(512, 1024, 512);
+
+ TestSlice(0, 0, 1, 20);
+ TestSlice(100, 100, 0, 100);
+ TestSlice(100, 100, 0, 1000);
+
+ TestSlice(0, 100, 5, 1);
+
+ TestSlice(1, 100, -11, -10);
+ TestSlice(9, 100, -10, 99);
+ TestSlice(0, 100, -10, 80);
+ TestSlice(10, 100, 80, -10);
+
+ TestSlice(10, 100, 90, "100");
+ TestSlice(10, 100, "90", "100");
+
+ TestSlice(0, 100, 90, "abc");
+ TestSlice(10, 100, "abc", 10);
+
+ TestSlice(10, 100, 0.96, 10.96);
+ TestSlice(10, 100, 0.96, 10.01);
+ TestSlice(10, 100, 0.01, 10.01);
+ TestSlice(10, 100, 0.01, 10.96);
+
+ TestSlice(10, 100, 90);
+ TestSlice(10, 100, -10);
+}
+
+TestArrayBufferSlice();
+
+// Typed arrays
+
+function TestTypedArray(constr, elementSize, typicalElement) {
+ assertSame(elementSize, constr.BYTES_PER_ELEMENT);
+
+ var ab = new ArrayBuffer(256*elementSize);
+
+ var a0 = new constr(30);
+ assertEquals("[object " + constr.name + "]",
+ Object.prototype.toString.call(a0));
+
+ assertTrue(ArrayBuffer.isView(a0));
+ assertSame(elementSize, a0.BYTES_PER_ELEMENT);
+ assertSame(30, a0.length);
+ assertSame(30*elementSize, a0.byteLength);
+ assertSame(0, a0.byteOffset);
+ assertSame(30*elementSize, a0.buffer.byteLength);
+
+ var aLen0 = new constr(0);
+ assertSame(elementSize, aLen0.BYTES_PER_ELEMENT);
+ assertSame(0, aLen0.length);
+ assertSame(0, aLen0.byteLength);
+ assertSame(0, aLen0.byteOffset);
+ assertSame(0, aLen0.buffer.byteLength);
+
+ var aOverBufferLen0 = new constr(ab, 128*elementSize, 0);
+ assertSame(ab, aOverBufferLen0.buffer);
+ assertSame(elementSize, aOverBufferLen0.BYTES_PER_ELEMENT);
+ assertSame(0, aOverBufferLen0.length);
+ assertSame(0, aOverBufferLen0.byteLength);
+ assertSame(128*elementSize, aOverBufferLen0.byteOffset);
+
+ var a1 = new constr(ab, 128*elementSize, 128);
+ assertSame(ab, a1.buffer);
+ assertSame(elementSize, a1.BYTES_PER_ELEMENT);
+ assertSame(128, a1.length);
+ assertSame(128*elementSize, a1.byteLength);
+ assertSame(128*elementSize, a1.byteOffset);
+
+
+ var a2 = new constr(ab, 64*elementSize, 128);
+ assertSame(ab, a2.buffer);
+ assertSame(elementSize, a2.BYTES_PER_ELEMENT);
+ assertSame(128, a2.length);
+ assertSame(128*elementSize, a2.byteLength);
+ assertSame(64*elementSize, a2.byteOffset);
+
+ var a3 = new constr(ab, 192*elementSize);
+ assertSame(ab, a3.buffer);
+ assertSame(64, a3.length);
+ assertSame(64*elementSize, a3.byteLength);
+ assertSame(192*elementSize, a3.byteOffset);
+
+ var a4 = new constr(ab);
+ assertSame(ab, a4.buffer);
+ assertSame(256, a4.length);
+ assertSame(256*elementSize, a4.byteLength);
+ assertSame(0, a4.byteOffset);
+
+
+ var i;
+ for (i = 0; i < 128; i++) {
+ a1[i] = typicalElement;
+ }
+
+ for (i = 0; i < 128; i++) {
+ assertSame(typicalElement, a1[i]);
+ }
+
+ for (i = 0; i < 64; i++) {
+ assertSame(0, a2[i]);
+ }
+
+ for (i = 64; i < 128; i++) {
+ assertSame(typicalElement, a2[i]);
+ }
+
+ for (i = 0; i < 64; i++) {
+ assertSame(typicalElement, a3[i]);
+ }
+
+ for (i = 0; i < 128; i++) {
+ assertSame(0, a4[i]);
+ }
+
+ for (i = 128; i < 256; i++) {
+ assertSame(typicalElement, a4[i]);
+ }
+
+ var aAtTheEnd = new constr(ab, 256*elementSize);
+ assertSame(elementSize, aAtTheEnd.BYTES_PER_ELEMENT);
+ assertSame(0, aAtTheEnd.length);
+ assertSame(0, aAtTheEnd.byteLength);
+ assertSame(256*elementSize, aAtTheEnd.byteOffset);
+
+ assertThrows(function () { new constr(ab, 257*elementSize); }, RangeError);
+ assertThrows(
+ function () { new constr(ab, 128*elementSize, 192); },
+ RangeError);
+
+ if (elementSize !== 1) {
+ assertThrows(function() { new constr(ab, 128*elementSize - 1, 10); },
+ RangeError);
+ var unalignedArrayBuffer = new ArrayBuffer(10*elementSize + 1);
+ var goodArray = new constr(unalignedArrayBuffer, 0, 10);
+ assertSame(10, goodArray.length);
+ assertSame(10*elementSize, goodArray.byteLength);
+ assertThrows(function() { new constr(unalignedArrayBuffer)}, RangeError);
+ assertThrows(function() { new constr(unalignedArrayBuffer, 5*elementSize)},
+ RangeError);
+ }
+
+ var aFromString = new constr("30");
+ assertSame(elementSize, aFromString.BYTES_PER_ELEMENT);
+ assertSame(30, aFromString.length);
+ assertSame(30*elementSize, aFromString.byteLength);
+ assertSame(0, aFromString.byteOffset);
+ assertSame(30*elementSize, aFromString.buffer.byteLength);
+
+ var jsArray = [];
+ for (i = 0; i < 30; i++) {
+ jsArray.push(typicalElement);
+ }
+ var aFromArray = new constr(jsArray);
+ assertSame(elementSize, aFromArray.BYTES_PER_ELEMENT);
+ assertSame(30, aFromArray.length);
+ assertSame(30*elementSize, aFromArray.byteLength);
+ assertSame(0, aFromArray.byteOffset);
+ assertSame(30*elementSize, aFromArray.buffer.byteLength);
+ for (i = 0; i < 30; i++) {
+ assertSame(typicalElement, aFromArray[i]);
+ }
+
+ var abLen0 = new ArrayBuffer(0);
+ var aOverAbLen0 = new constr(abLen0);
+ assertSame(abLen0, aOverAbLen0.buffer);
+ assertSame(elementSize, aOverAbLen0.BYTES_PER_ELEMENT);
+ assertSame(0, aOverAbLen0.length);
+ assertSame(0, aOverAbLen0.byteLength);
+ assertSame(0, aOverAbLen0.byteOffset);
+
+ var aNoParam = new constr();
+ assertSame(elementSize, aNoParam.BYTES_PER_ELEMENT);
+ assertSame(0, aNoParam.length);
+ assertSame(0, aNoParam.byteLength);
+ assertSame(0, aNoParam.byteOffset);
+
+ var a = new constr(ab, 64*elementSize, 128);
+ assertEquals("[object " + constr.name + "]",
+ Object.prototype.toString.call(a));
+ var desc = Object.getOwnPropertyDescriptor(
+ constr.prototype, Symbol.toStringTag);
+ assertTrue(desc.configurable);
+ assertFalse(desc.enumerable);
+ assertFalse(!!desc.writable);
+ assertFalse(!!desc.set);
+ assertEquals("function", typeof desc.get);
+
+ // Test that the constructor can be called with an iterable
+ function* gen() { for (var i = 0; i < 10; i++) yield i; }
+ var genArr = new constr(gen());
+ assertEquals(10, genArr.length);
+ assertEquals(0, genArr[0]);
+ assertEquals(9, genArr[9]);
+ // Arrays can be converted to TypedArrays
+ genArr = new constr([1, 2, 3]);
+ assertEquals(3, genArr.length);
+ assertEquals(1, genArr[0]);
+ assertEquals(3, genArr[2]);
+ // Redefining Array.prototype[Symbol.iterator] still works
+ var arrayIterator = Array.prototype[Symbol.iterator];
+ Array.prototype[Symbol.iterator] = gen;
+ genArr = new constr([1, 2, 3]);
+ assertEquals(10, genArr.length);
+ assertEquals(0, genArr[0]);
+ assertEquals(9, genArr[9]);
+ Array.prototype[Symbol.iterator] = arrayIterator;
+ // Other array-like things can be made into a TypedArray
+ var myObject = { 0: 5, 1: 6, length: 2 };
+ genArr = new constr(myObject);
+ assertEquals(2, genArr.length);
+ assertEquals(5, genArr[0]);
+ assertEquals(6, genArr[1]);
+ // Iterator takes precedence over array-like, and the property
+ // is read only once.
+ var iteratorReadCount = 0;
+ Object.defineProperty(myObject, Symbol.iterator, {
+ get: function() { iteratorReadCount++; return gen; }
+ });
+ genArr = new constr(myObject);
+ assertEquals(10, genArr.length);
+ assertEquals(0, genArr[0]);
+ assertEquals(9, genArr[9]);
+ assertEquals(1, iteratorReadCount);
+}
+
+TestTypedArray(Uint8Array, 1, 0xFF);
+TestTypedArray(Int8Array, 1, -0x7F);
+TestTypedArray(Uint16Array, 2, 0xFFFF);
+TestTypedArray(Int16Array, 2, -0x7FFF);
+TestTypedArray(Uint32Array, 4, 0xFFFFFFFF);
+TestTypedArray(Int32Array, 4, -0x7FFFFFFF);
+TestTypedArray(Float32Array, 4, 0.5);
+TestTypedArray(Float64Array, 8, 0.5);
+TestTypedArray(Uint8ClampedArray, 1, 0xFF);
+
+function SubarrayTestCase(constructor, item, expectedResultLen, expectedStartIndex,
+ initialLen, start, end) {
+ var a = new constructor(initialLen);
+ var s = a.subarray(start, end);
+ assertSame(constructor, s.constructor);
+ assertSame(expectedResultLen, s.length);
+ if (s.length > 0) {
+ s[0] = item;
+ assertSame(item, a[expectedStartIndex]);
+ }
+}
+
+function TestSubArray(constructor, item) {
+ SubarrayTestCase(constructor, item, 512, 512, 1024, 512, 1024);
+ SubarrayTestCase(constructor, item, 512, 512, 1024, 512);
+
+ SubarrayTestCase(constructor, item, 0, undefined, 0, 1, 20);
+ SubarrayTestCase(constructor, item, 100, 0, 100, 0, 100);
+ SubarrayTestCase(constructor, item, 100, 0, 100, 0, 1000);
+ SubarrayTestCase(constructor, item, 0, undefined, 100, 5, 1);
+
+ SubarrayTestCase(constructor, item, 1, 89, 100, -11, -10);
+ SubarrayTestCase(constructor, item, 9, 90, 100, -10, 99);
+ SubarrayTestCase(constructor, item, 0, undefined, 100, -10, 80);
+ SubarrayTestCase(constructor, item, 10,80, 100, 80, -10);
+
+ SubarrayTestCase(constructor, item, 10,90, 100, 90, "100");
+ SubarrayTestCase(constructor, item, 10,90, 100, "90", "100");
+
+ SubarrayTestCase(constructor, item, 0, undefined, 100, 90, "abc");
+ SubarrayTestCase(constructor, item, 10,0, 100, "abc", 10);
+
+ SubarrayTestCase(constructor, item, 10,0, 100, 0.96, 10.96);
+ SubarrayTestCase(constructor, item, 10,0, 100, 0.96, 10.01);
+ SubarrayTestCase(constructor, item, 10,0, 100, 0.01, 10.01);
+ SubarrayTestCase(constructor, item, 10,0, 100, 0.01, 10.96);
+
+
+ SubarrayTestCase(constructor, item, 10,90, 100, 90);
+ SubarrayTestCase(constructor, item, 10,90, 100, -10);
+
+ var method = constructor.prototype.subarray;
+ method.call(new constructor(100), 0, 100);
+ var o = {};
+ assertThrows(function() { method.call(o, 0, 100); }, TypeError);
+}
+
+TestSubArray(Uint8Array, 0xFF);
+TestSubArray(Int8Array, -0x7F);
+TestSubArray(Uint16Array, 0xFFFF);
+TestSubArray(Int16Array, -0x7FFF);
+TestSubArray(Uint32Array, 0xFFFFFFFF);
+TestSubArray(Int32Array, -0x7FFFFFFF);
+TestSubArray(Float32Array, 0.5);
+TestSubArray(Float64Array, 0.5);
+TestSubArray(Uint8ClampedArray, 0xFF);
+
+function TestTypedArrayOutOfRange(constructor, value, result) {
+ var a = new constructor(1);
+ a[0] = value;
+ assertSame(result, a[0]);
+}
+
+TestTypedArrayOutOfRange(Uint8Array, 0x1FA, 0xFA);
+TestTypedArrayOutOfRange(Uint8Array, -1, 0xFF);
+
+TestTypedArrayOutOfRange(Int8Array, 0x1FA, 0x7A - 0x80);
+
+TestTypedArrayOutOfRange(Uint16Array, 0x1FFFA, 0xFFFA);
+TestTypedArrayOutOfRange(Uint16Array, -1, 0xFFFF);
+TestTypedArrayOutOfRange(Int16Array, 0x1FFFA, 0x7FFA - 0x8000);
+
+TestTypedArrayOutOfRange(Uint32Array, 0x1FFFFFFFA, 0xFFFFFFFA);
+TestTypedArrayOutOfRange(Uint32Array, -1, 0xFFFFFFFF);
+TestTypedArrayOutOfRange(Int32Array, 0x1FFFFFFFA, 0x7FFFFFFA - 0x80000000);
+
+TestTypedArrayOutOfRange(Uint8ClampedArray, 0x1FA, 0xFF);
+TestTypedArrayOutOfRange(Uint8ClampedArray, -1, 0);
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+function TestPropertyTypeChecks(constructor) {
+ function CheckProperty(name) {
+ var d = Object.getOwnPropertyDescriptor(constructor.prototype, name);
+ var o = {};
+ assertThrows(function() {d.get.call(o);}, TypeError);
+ for (var i = 0; i < typedArrayConstructors.length; i++) {
+ var ctor = typedArrayConstructors[i];
+ var a = new ctor(10);
+ if (ctor === constructor) {
+ d.get.call(a); // shouldn't throw
+ } else {
+ assertThrows(function() {d.get.call(a);}, TypeError);
+ }
+ }
+ }
+
+ CheckProperty("buffer");
+ CheckProperty("byteOffset");
+ CheckProperty("byteLength");
+ CheckProperty("length");
+}
+
+for(i = 0; i < typedArrayConstructors.length; i++) {
+ TestPropertyTypeChecks(typedArrayConstructors[i]);
+}
+
+
+function TestTypedArraySet() {
+ // Test array.set in different combinations.
+
+ function assertArrayPrefix(expected, array) {
+ for (var i = 0; i < expected.length; ++i) {
+ assertEquals(expected[i], array[i]);
+ }
+ }
+
+ var a11 = new Int16Array([1, 2, 3, 4, 0, -1])
+ var a12 = new Uint16Array(15)
+ a12.set(a11, 3)
+ assertArrayPrefix([0, 0, 0, 1, 2, 3, 4, 0, 0xffff, 0, 0], a12)
+ assertThrows(function(){ a11.set(a12) })
+
+ var a21 = [1, undefined, 10, NaN, 0, -1, {valueOf: function() {return 3}}]
+ var a22 = new Int32Array(12)
+ a22.set(a21, 2)
+ assertArrayPrefix([0, 0, 1, 0, 10, 0, 0, -1, 3, 0], a22)
+
+ var a31 = new Float32Array([2, 4, 6, 8, 11, NaN, 1/0, -3])
+ var a32 = a31.subarray(2, 6)
+ a31.set(a32, 4)
+ assertArrayPrefix([2, 4, 6, 8, 6, 8, 11, NaN], a31)
+ assertArrayPrefix([6, 8, 6, 8], a32)
+
+ var a4 = new Uint8ClampedArray([3,2,5,6])
+ a4.set(a4)
+ assertArrayPrefix([3, 2, 5, 6], a4)
+
+ // Cases with overlapping backing store but different element sizes.
+ var b = new ArrayBuffer(4)
+ var a5 = new Int16Array(b)
+ var a50 = new Int8Array(b)
+ var a51 = new Int8Array(b, 0, 2)
+ var a52 = new Int8Array(b, 1, 2)
+ var a53 = new Int8Array(b, 2, 2)
+
+ a5.set([0x5050, 0x0a0a])
+ assertArrayPrefix([0x50, 0x50, 0x0a, 0x0a], a50)
+ assertArrayPrefix([0x50, 0x50], a51)
+ assertArrayPrefix([0x50, 0x0a], a52)
+ assertArrayPrefix([0x0a, 0x0a], a53)
+
+ a50.set([0x50, 0x50, 0x0a, 0x0a])
+ a51.set(a5)
+ assertArrayPrefix([0x50, 0x0a, 0x0a, 0x0a], a50)
+
+ a50.set([0x50, 0x50, 0x0a, 0x0a])
+ a52.set(a5)
+ assertArrayPrefix([0x50, 0x50, 0x0a, 0x0a], a50)
+
+ a50.set([0x50, 0x50, 0x0a, 0x0a])
+ a53.set(a5)
+ assertArrayPrefix([0x50, 0x50, 0x50, 0x0a], a50)
+
+ a50.set([0x50, 0x51, 0x0a, 0x0b])
+ a5.set(a51)
+ assertArrayPrefix([0x0050, 0x0051], a5)
+
+ a50.set([0x50, 0x51, 0x0a, 0x0b])
+ a5.set(a52)
+ assertArrayPrefix([0x0051, 0x000a], a5)
+
+ a50.set([0x50, 0x51, 0x0a, 0x0b])
+ a5.set(a53)
+ assertArrayPrefix([0x000a, 0x000b], a5)
+
+ // Mixed types of same size.
+ var a61 = new Float32Array([1.2, 12.3])
+ var a62 = new Int32Array(2)
+ a62.set(a61)
+ assertArrayPrefix([1, 12], a62)
+ a61.set(a62)
+ assertArrayPrefix([1, 12], a61)
+
+ // Invalid source
+ var a = new Uint16Array(50);
+ var expected = [];
+ for (i = 0; i < 50; i++) {
+ a[i] = i;
+ expected.push(i);
+ }
+ a.set({});
+ assertArrayPrefix(expected, a);
+ assertThrows(function() { a.set.call({}) }, TypeError);
+ assertThrows(function() { a.set.call([]) }, TypeError);
+
+ assertThrows(function() { a.set(0); }, TypeError);
+ assertThrows(function() { a.set(0, 1); }, TypeError);
+}
+
+TestTypedArraySet();
+
+function TestTypedArraysWithIllegalIndices() {
+ var a = new Int32Array(100);
+
+ a[-10] = 10;
+ assertEquals(undefined, a[-10]);
+ a["-10"] = 10;
+ assertEquals(undefined, a["-10"]);
+
+ var s = " -10";
+ a[s] = 10;
+ assertEquals(10, a[s]);
+ var s1 = " -10 ";
+ a[s] = 10;
+ assertEquals(10, a[s]);
+
+ a["-1e2"] = 10;
+ assertEquals(10, a["-1e2"]);
+ assertEquals(undefined, a[-1e2]);
+
+ a["-0"] = 256;
+ var s2 = " -0";
+ a[s2] = 255;
+ assertEquals(undefined, a["-0"]);
+ assertEquals(255, a[s2]);
+ assertEquals(0, a[-0]);
+
+ /* Chromium bug: 424619
+ * a[-Infinity] = 50;
+ * assertEquals(undefined, a[-Infinity]);
+ */
+ a[1.5] = 10;
+ assertEquals(undefined, a[1.5]);
+ var nan = Math.sqrt(-1);
+ a[nan] = 5;
+ assertEquals(undefined, a[nan]);
+
+ var x = 0;
+ var y = -0;
+ assertEquals(Infinity, 1/x);
+ assertEquals(-Infinity, 1/y);
+ a[x] = 5;
+ a[y] = 27;
+ assertEquals(27, a[x]);
+ assertEquals(27, a[y]);
+}
+
+TestTypedArraysWithIllegalIndices();
+
+function TestTypedArraysWithIllegalIndicesStrict() {
+ 'use strict';
+ var a = new Int32Array(100);
+
+ a[-10] = 10;
+ assertEquals(undefined, a[-10]);
+ a["-10"] = 10;
+ assertEquals(undefined, a["-10"]);
+
+ var s = " -10";
+ a[s] = 10;
+ assertEquals(10, a[s]);
+ var s1 = " -10 ";
+ a[s] = 10;
+ assertEquals(10, a[s]);
+
+ a["-1e2"] = 10;
+ assertEquals(10, a["-1e2"]);
+ assertEquals(undefined, a[-1e2]);
+
+ a["-0"] = 256;
+ var s2 = " -0";
+ a[s2] = 255;
+ assertEquals(undefined, a["-0"]);
+ assertEquals(255, a[s2]);
+ assertEquals(0, a[-0]);
+
+ /* Chromium bug: 424619
+ * a[-Infinity] = 50;
+ * assertEquals(undefined, a[-Infinity]);
+ */
+ a[1.5] = 10;
+ assertEquals(undefined, a[1.5]);
+ var nan = Math.sqrt(-1);
+ a[nan] = 5;
+ assertEquals(undefined, a[nan]);
+
+ var x = 0;
+ var y = -0;
+ assertEquals(Infinity, 1/x);
+ assertEquals(-Infinity, 1/y);
+ a[x] = 5;
+ a[y] = 27;
+ assertEquals(27, a[x]);
+ assertEquals(27, a[y]);
+}
+
+TestTypedArraysWithIllegalIndicesStrict();
+
+// DataView
+function TestDataViewConstructor() {
+ var ab = new ArrayBuffer(256);
+
+ var d1 = new DataView(ab, 1, 255);
+ assertTrue(ArrayBuffer.isView(d1));
+ assertSame(ab, d1.buffer);
+ assertSame(1, d1.byteOffset);
+ assertSame(255, d1.byteLength);
+
+ var d2 = new DataView(ab, 2);
+ assertSame(ab, d2.buffer);
+ assertSame(2, d2.byteOffset);
+ assertSame(254, d2.byteLength);
+
+ var d3 = new DataView(ab);
+ assertSame(ab, d3.buffer);
+ assertSame(0, d3.byteOffset);
+ assertSame(256, d3.byteLength);
+
+ var d3a = new DataView(ab, 1, 0);
+ assertSame(ab, d3a.buffer);
+ assertSame(1, d3a.byteOffset);
+ assertSame(0, d3a.byteLength);
+
+ var d3b = new DataView(ab, 256, 0);
+ assertSame(ab, d3b.buffer);
+ assertSame(256, d3b.byteOffset);
+ assertSame(0, d3b.byteLength);
+
+ var d3c = new DataView(ab, 256);
+ assertSame(ab, d3c.buffer);
+ assertSame(256, d3c.byteOffset);
+ assertSame(0, d3c.byteLength);
+
+ var d4 = new DataView(ab, 1, 3.1415926);
+ assertSame(ab, d4.buffer);
+ assertSame(1, d4.byteOffset);
+ assertSame(3, d4.byteLength);
+
+
+ // error cases
+ assertThrows(function() { new DataView(ab, -1); }, RangeError);
+ assertThrows(function() { new DataView(ab, 1, -1); }, RangeError);
+ assertThrows(function() { new DataView(); }, TypeError);
+ assertThrows(function() { new DataView([]); }, TypeError);
+ assertThrows(function() { new DataView(ab, 257); }, RangeError);
+ assertThrows(function() { new DataView(ab, 1, 1024); }, RangeError);
+}
+
+TestDataViewConstructor();
+
+function TestDataViewPropertyTypeChecks() {
+ var a = new DataView(new ArrayBuffer(10));
+ function CheckProperty(name) {
+ var d = Object.getOwnPropertyDescriptor(DataView.prototype, name);
+ var o = {}
+ assertThrows(function() {d.get.call(o);}, TypeError);
+ d.get.call(a); // shouldn't throw
+ }
+
+ CheckProperty("buffer");
+ CheckProperty("byteOffset");
+ CheckProperty("byteLength");
+}
+
+
+TestDataViewPropertyTypeChecks();
+
+
+function TestDataViewToStringTag() {
+ var a = new DataView(new ArrayBuffer(10));
+ assertEquals("[object DataView]", Object.prototype.toString.call(a));
+ var desc = Object.getOwnPropertyDescriptor(
+ DataView.prototype, Symbol.toStringTag);
+ assertTrue(desc.configurable);
+ assertFalse(desc.enumerable);
+ assertFalse(desc.writable);
+ assertEquals("DataView", desc.value);
+}
+
+
+// General tests for properties
+
+// Test property attribute [[Enumerable]]
+function TestEnumerable(func, obj) {
+ function props(x) {
+ var array = [];
+ for (var p in x) array.push(p);
+ return array.sort();
+ }
+ assertArrayEquals([], props(func));
+ assertArrayEquals([], props(func.prototype));
+ if (obj)
+ assertArrayEquals([], props(obj));
+}
+TestEnumerable(ArrayBuffer, new ArrayBuffer());
+for(i = 0; i < typedArrayConstructors.length; i++) {
+ TestEnumerable(typedArrayConstructors[i]);
+}
+TestEnumerable(DataView, new DataView(new ArrayBuffer()));
+
+// Test arbitrary properties on ArrayBuffer
+function TestArbitrary(m) {
+ function TestProperty(map, property, value) {
+ map[property] = value;
+ assertEquals(value, map[property]);
+ }
+ for (var i = 0; i < 20; i++) {
+ TestProperty(m, 'key' + i, 'val' + i);
+ TestProperty(m, 'foo' + i, 'bar' + i);
+ }
+}
+TestArbitrary(new ArrayBuffer(256));
+for(i = 0; i < typedArrayConstructors.length; i++) {
+ TestArbitrary(new typedArrayConstructors[i](10));
+}
+TestArbitrary(new DataView(new ArrayBuffer(256)));
+
+
+// Test direct constructor call
+assertThrows(function() { ArrayBuffer(); }, TypeError);
+assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError);