summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-03-31 14:38:28 +0200
committerFedor Indutny <fedor@indutny.com>2014-04-02 00:05:24 +0400
commit67e078094b53861a5aa7e9354e33487d0bd4f73b (patch)
tree09a706adee1ddb59c1507ee3320de9cb6896135b /deps/v8/test/mjsunit/es6
parentf984555d47298cfb01b3e55c2861066379306fc3 (diff)
downloadandroid-node-v8-67e078094b53861a5aa7e9354e33487d0bd4f73b.tar.gz
android-node-v8-67e078094b53861a5aa7e9354e33487d0bd4f73b.tar.bz2
android-node-v8-67e078094b53861a5aa7e9354e33487d0bd4f73b.zip
deps: upgrade v8 to 3.25.30
Diffstat (limited to 'deps/v8/test/mjsunit/es6')
-rw-r--r--deps/v8/test/mjsunit/es6/math-cbrt.js27
-rw-r--r--deps/v8/test/mjsunit/es6/math-clz32.js36
-rw-r--r--deps/v8/test/mjsunit/es6/math-expm1.js38
-rw-r--r--deps/v8/test/mjsunit/es6/math-fround.js99
-rw-r--r--deps/v8/test/mjsunit/es6/math-hyperbolic.js138
-rw-r--r--deps/v8/test/mjsunit/es6/math-hypot.js94
-rw-r--r--deps/v8/test/mjsunit/es6/math-log1p.js41
-rw-r--r--deps/v8/test/mjsunit/es6/math-log2-log10.js47
-rw-r--r--deps/v8/test/mjsunit/es6/math-sign.js48
-rw-r--r--deps/v8/test/mjsunit/es6/math-trunc.js51
-rw-r--r--deps/v8/test/mjsunit/es6/microtask-delivery.js168
-rw-r--r--deps/v8/test/mjsunit/es6/promises.js801
-rw-r--r--deps/v8/test/mjsunit/es6/regress/regress-2034.js44
-rw-r--r--deps/v8/test/mjsunit/es6/regress/regress-2156.js39
-rw-r--r--deps/v8/test/mjsunit/es6/regress/regress-2829.js51
-rw-r--r--deps/v8/test/mjsunit/es6/weak_collections.js333
16 files changed, 2055 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/es6/math-cbrt.js b/deps/v8/test/mjsunit/es6/math-cbrt.js
new file mode 100644
index 0000000000..83d9eb5d75
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-cbrt.js
@@ -0,0 +1,27 @@
+// 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-maths
+
+assertTrue(isNaN(Math.cbrt(NaN)));
+assertTrue(isNaN(Math.cbrt(function() {})));
+assertTrue(isNaN(Math.cbrt({ toString: function() { return NaN; } })));
+assertTrue(isNaN(Math.cbrt({ valueOf: function() { return "abc"; } })));
+assertEquals("Infinity", String(1/Math.cbrt(0)));
+assertEquals("-Infinity", String(1/Math.cbrt(-0)));
+assertEquals("Infinity", String(Math.cbrt(Infinity)));
+assertEquals("-Infinity", String(Math.cbrt(-Infinity)));
+
+for (var i = 1E-100; i < 1E100; i *= Math.PI) {
+ assertEqualsDelta(i, Math.cbrt(i*i*i), i * 1E-15);
+}
+
+for (var i = -1E-100; i > -1E100; i *= Math.E) {
+ assertEqualsDelta(i, Math.cbrt(i*i*i), -i * 1E-15);
+}
+
+// Let's be exact at least for small integers.
+for (var i = 2; i < 10000; i++) {
+ assertEquals(i, Math.cbrt(i*i*i));
+}
diff --git a/deps/v8/test/mjsunit/es6/math-clz32.js b/deps/v8/test/mjsunit/es6/math-clz32.js
new file mode 100644
index 0000000000..816f6a936e
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-clz32.js
@@ -0,0 +1,36 @@
+// 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-maths --allow-natives-syntax
+
+[NaN, Infinity, -Infinity, 0, -0, "abc", "Infinity", "-Infinity", {}].forEach(
+ function(x) {
+ assertEquals(32, Math.clz32(x));
+ }
+);
+
+function testclz(x) {
+ for (var i = 0; i < 33; i++) {
+ if (x & 0x80000000) return i;
+ x <<= 1;
+ }
+ return 32;
+}
+
+
+function f(e) {
+ var max = Math.pow(2, e);
+ for (var x = 0; x < max; x = x * 1.01 + 1) {
+ assertEquals(testclz(x), Math.clz32(x));
+ assertEquals(testclz(-x), Math.clz32(-x));
+ assertEquals(testclz(x), Math.clz32({ valueOf: function() { return x; } }));
+ assertEquals(testclz(-x),
+ Math.clz32({ toString: function() { return -x; } }));
+ }
+}
+
+f(5);
+f(5);
+%OptimizeFunctionOnNextCall(f);
+f(40);
diff --git a/deps/v8/test/mjsunit/es6/math-expm1.js b/deps/v8/test/mjsunit/es6/math-expm1.js
new file mode 100644
index 0000000000..de915c0969
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-expm1.js
@@ -0,0 +1,38 @@
+// 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-maths --no-fast-math
+
+assertTrue(isNaN(Math.expm1(NaN)));
+assertTrue(isNaN(Math.expm1(function() {})));
+assertTrue(isNaN(Math.expm1({ toString: function() { return NaN; } })));
+assertTrue(isNaN(Math.expm1({ valueOf: function() { return "abc"; } })));
+assertEquals("Infinity", String(1/Math.expm1(0)));
+assertEquals("-Infinity", String(1/Math.expm1(-0)));
+assertEquals("Infinity", String(Math.expm1(Infinity)));
+assertEquals(-1, Math.expm1(-Infinity));
+
+for (var x = 0.1; x < 700; x += 0.1) {
+ var expected = Math.exp(x) - 1;
+ assertEqualsDelta(expected, Math.expm1(x), expected * 1E-14);
+ expected = Math.exp(-x) - 1;
+ assertEqualsDelta(expected, Math.expm1(-x), -expected * 1E-14);
+}
+
+// Values close to 0:
+// Use six terms of Taylor expansion at 0 for exp(x) as test expectation:
+// exp(x) - 1 == exp(0) + exp(0) * x + x * x / 2 + ... - 1
+// == x + x * x / 2 + x * x * x / 6 + ...
+function expm1(x) {
+ return x * (1 + x * (1/2 + x * (
+ 1/6 + x * (1/24 + x * (
+ 1/120 + x * (1/720 + x * (
+ 1/5040 + x * (1/40320 + x*(
+ 1/362880 + x * (1/3628800))))))))));
+}
+
+for (var x = 1E-1; x > 1E-300; x *= 0.8) {
+ var expected = expm1(x);
+ assertEqualsDelta(expected, Math.expm1(x), expected * 1E-14);
+}
diff --git a/deps/v8/test/mjsunit/es6/math-fround.js b/deps/v8/test/mjsunit/es6/math-fround.js
new file mode 100644
index 0000000000..ea432ea2de
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-fround.js
@@ -0,0 +1,99 @@
+// 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-maths
+
+// Monkey-patch Float32Array.
+Float32Array = function(x) { this[0] = 0; };
+
+assertTrue(isNaN(Math.fround(NaN)));
+assertTrue(isNaN(Math.fround(function() {})));
+assertTrue(isNaN(Math.fround({ toString: function() { return NaN; } })));
+assertTrue(isNaN(Math.fround({ valueOf: function() { return "abc"; } })));
+assertEquals("Infinity", String(1/Math.fround(0)));
+assertEquals("-Infinity", String(1/Math.fround(-0)));
+assertEquals("Infinity", String(Math.fround(Infinity)));
+assertEquals("-Infinity", String(Math.fround(-Infinity)));
+
+assertEquals("Infinity", String(Math.fround(1E200)));
+assertEquals("-Infinity", String(Math.fround(-1E200)));
+assertEquals("Infinity", String(1/Math.fround(1E-300)));
+assertEquals("-Infinity", String(1/Math.fround(-1E-300)));
+
+mantissa_23_shift = Math.pow(2, -23);
+mantissa_29_shift = Math.pow(2, -23-29);
+
+// Javascript implementation of IEEE 754 to test double to single conversion.
+function ieee754float(sign_bit,
+ exponent_bits,
+ mantissa_23_bits,
+ mantissa_29_bits) {
+ this.sign_bit = sign_bit & 1;
+ this.exponent_bits = exponent_bits & ((1 << 11) - 1);
+ this.mantissa_23_bits = mantissa_23_bits & ((1 << 23) - 1);
+ this.mantissa_29_bits = mantissa_29_bits & ((1 << 29) - 1);
+}
+
+ieee754float.prototype.returnSpecial = function() {
+ if (mantissa_23_bits == 0 && mantissa_29_bits == 0) return sign * Infinity;
+ return NaN;
+}
+
+ieee754float.prototype.toDouble = function() {
+ var sign = this.sign_bit ? -1 : 1;
+ var exponent = this.exponent_bits - 1023;
+ if (exponent == -1023) returnSpecial();
+ var mantissa = 1 + this.mantissa_23_bits * mantissa_23_shift +
+ this.mantissa_29_bits * mantissa_29_shift;
+ return sign * Math.pow(2, exponent) * mantissa;
+}
+
+ieee754float.prototype.toSingle = function() {
+ var sign = this.sign_bit ? -1 : 1;
+ var exponent = this.exponent_bits - 1023;
+ if (exponent == -1023) returnSpecial();
+ if (exponent > 127) return sign * Infinity;
+ if (exponent < -126) return this.toSingleSubnormal(sign, exponent);
+ var round = this.mantissa_29_bits >> 28;
+ var mantissa = 1 + (this.mantissa_23_bits + round) * mantissa_23_shift;
+ return sign * Math.pow(2, exponent) * mantissa;
+}
+
+ieee754float.prototype.toSingleSubnormal = function(sign, exponent) {
+ var shift = -126 - exponent;
+ if (shift > 24) return sign * 0;
+ var round_mask = 1 << (shift - 1);
+ var mantissa_23_bits = this.mantissa_23_bits + (1 << 23);
+ var round = ((mantissa_23_bits & round_mask) != 0) | 0;
+ if (round) { // Round to even if tied.
+ var tied_mask = round_mask - 1;
+ var result_last_bit_mask = 1 << shift;
+ var tied = this.mantissa_29_bits == 0 &&
+ (mantissa_23_bits & tied_mask ) == 0;
+ var result_already_even = (mantissa_23_bits & result_last_bit_mask) == 0;
+ if (tied && result_already_even) round = 0;
+ }
+ mantissa_23_bits >>= shift;
+ var mantissa = (mantissa_23_bits + round) * mantissa_23_shift;
+ return sign * Math.pow(2, -126) * mantissa;
+}
+
+
+var pi = new ieee754float(0, 0x400, 0x490fda, 0x14442d18);
+assertEquals(pi.toSingle(), Math.fround(pi.toDouble()));
+
+function fuzz_mantissa(sign, exp, m1inc, m2inc) {
+ for (var m1 = 0; m1 < (1 << 23); m1 += m1inc) {
+ for (var m2 = 0; m2 < (1 << 29); m2 += m2inc) {
+ var float = new ieee754float(sign, exp, m1, m2);
+ assertEquals(float.toSingle(), Math.fround(float.toDouble()));
+ }
+ }
+}
+
+for (var sign = 0; sign < 2; sign++) {
+ for (var exp = 1024 - 170; exp < 1024 + 170; exp++) {
+ fuzz_mantissa(sign, exp, 1337 * exp - sign, 127913 * exp - sign);
+ }
+}
diff --git a/deps/v8/test/mjsunit/es6/math-hyperbolic.js b/deps/v8/test/mjsunit/es6/math-hyperbolic.js
new file mode 100644
index 0000000000..c45a19c526
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-hyperbolic.js
@@ -0,0 +1,138 @@
+// 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-maths
+
+[Math.sinh, Math.cosh, Math.tanh, Math.asinh, Math.acosh, Math.atanh].
+ forEach(function(fun) {
+ assertTrue(isNaN(fun(NaN)));
+ assertTrue(isNaN(fun("abc")));
+ assertTrue(isNaN(fun({})));
+ assertEquals(fun(0), fun([]));
+ assertTrue(isNaN(fun([1, 1])));
+ assertEquals(fun(1.11), fun({ toString: function() { return "1.11"; } }));
+ assertEquals(fun(-3.1), fun({ toString: function() { return -3.1; } }));
+ assertEquals(fun(-1.1), fun({ valueOf: function() { return "-1.1"; } }));
+ assertEquals(fun(3.11), fun({ valueOf: function() { return 3.11; } }));
+});
+
+
+function test_id(fun, rev, value) {
+ assertEqualsDelta(1, rev(fun(value))/value, 1E-7);
+}
+
+[Math.PI, 2, 5, 1E-5, 0.3].forEach(function(x) {
+ test_id(Math.sinh, Math.asinh, x);
+ test_id(Math.sinh, Math.asinh, -x);
+ test_id(Math.cosh, Math.acosh, x);
+ test_id(Math.tanh, Math.atanh, x);
+ test_id(Math.tanh, Math.atanh, -x);
+});
+
+
+[Math.sinh, Math.asinh, Math.tanh, Math.atanh].forEach(function(fun) {
+ assertEquals("-Infinity", String(1/fun(-0)));
+ assertEquals("Infinity", String(1/fun(0)));
+});
+
+
+[Math.sinh, Math.asinh].forEach(function(fun) {
+ assertEquals("-Infinity", String(fun(-Infinity)));
+ assertEquals("Infinity", String(fun(Infinity)));
+ assertEquals("-Infinity", String(fun("-Infinity")));
+ assertEquals("Infinity", String(fun("Infinity")));
+});
+
+
+assertEquals("Infinity", String(Math.cosh(-Infinity)));
+assertEquals("Infinity", String(Math.cosh(Infinity)));
+assertEquals("Infinity", String(Math.cosh("-Infinity")));
+assertEquals("Infinity", String(Math.cosh("Infinity")));
+
+
+assertEquals("-Infinity", String(Math.atanh(-1)));
+assertEquals("Infinity", String(Math.atanh(1)));
+
+// Math.atanh(x) is NaN for |x| > 1 and NaN
+[1.000000000001, Math.PI, 10000000, 2, Infinity, NaN].forEach(function(x) {
+ assertTrue(isNaN(Math.atanh(-x)));
+ assertTrue(isNaN(Math.atanh(x)));
+});
+
+
+assertEquals(1, Math.tanh(Infinity));
+assertEquals(-1, Math.tanh(-Infinity));
+assertEquals(1, Math.cosh(0));
+assertEquals(1, Math.cosh(-0));
+
+assertEquals(0, Math.acosh(1));
+assertEquals("Infinity", String(Math.acosh(Infinity)));
+
+// Math.acosh(x) is NaN for x < 1
+[0.99999999999, 0.2, -1000, 0, -0].forEach(function(x) {
+ assertTrue(isNaN(Math.acosh(x)));
+});
+
+
+// Some random samples.
+assertEqualsDelta(0.5210953054937, Math.sinh(0.5), 1E-12);
+assertEqualsDelta(74.203210577788, Math.sinh(5), 1E-12);
+assertEqualsDelta(-0.5210953054937, Math.sinh(-0.5), 1E-12);
+assertEqualsDelta(-74.203210577788, Math.sinh(-5), 1E-12);
+
+assertEqualsDelta(1.1276259652063, Math.cosh(0.5), 1E-12);
+assertEqualsDelta(74.209948524787, Math.cosh(5), 1E-12);
+assertEqualsDelta(1.1276259652063, Math.cosh(-0.5), 1E-12);
+assertEqualsDelta(74.209948524787, Math.cosh(-5), 1E-12);
+
+assertEqualsDelta(0.4621171572600, Math.tanh(0.5), 1E-12);
+assertEqualsDelta(0.9999092042625, Math.tanh(5), 1E-12);
+assertEqualsDelta(-0.4621171572600, Math.tanh(-0.5), 1E-12);
+assertEqualsDelta(-0.9999092042625, Math.tanh(-5), 1E-12);
+
+assertEqualsDelta(0.4812118250596, Math.asinh(0.5), 1E-12);
+assertEqualsDelta(2.3124383412727, Math.asinh(5), 1E-12);
+assertEqualsDelta(-0.4812118250596, Math.asinh(-0.5), 1E-12);
+assertEqualsDelta(-2.3124383412727, Math.asinh(-5), 1E-12);
+
+assertEqualsDelta(0.9624236501192, Math.acosh(1.5), 1E-12);
+assertEqualsDelta(2.2924316695612, Math.acosh(5), 1E-12);
+assertEqualsDelta(0.4435682543851, Math.acosh(1.1), 1E-12);
+assertEqualsDelta(1.3169578969248, Math.acosh(2), 1E-12);
+
+assertEqualsDelta(0.5493061443341, Math.atanh(0.5), 1E-12);
+assertEqualsDelta(0.1003353477311, Math.atanh(0.1), 1E-12);
+assertEqualsDelta(-0.5493061443341, Math.atanh(-0.5), 1E-12);
+assertEqualsDelta(-0.1003353477311, Math.atanh(-0.1), 1E-12);
+
+[0, 1E-50, 1E-10, 1E10, 1E50, 1E100, 1E150].forEach(function(x) {
+ assertEqualsDelta(Math.asinh(x), -Math.asinh(-x), 1E-12);
+});
+
+[1-(1E-16), 0, 1E-10, 1E-50].forEach(function(x) {
+ assertEqualsDelta(Math.atanh(x), -Math.atanh(-x), 1E-12);
+});
diff --git a/deps/v8/test/mjsunit/es6/math-hypot.js b/deps/v8/test/mjsunit/es6/math-hypot.js
new file mode 100644
index 0000000000..1052627213
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-hypot.js
@@ -0,0 +1,94 @@
+// 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-maths
+
+assertTrue(isNaN(Math.hypot({})));
+assertTrue(isNaN(Math.hypot(undefined, 1)));
+assertTrue(isNaN(Math.hypot(1, undefined)));
+assertTrue(isNaN(Math.hypot(Math.hypot, 1)));
+assertEquals(1, Math.hypot(1));
+assertEquals(Math.PI, Math.hypot(Math.PI));
+assertEquals(5, Math.hypot(3, 4));
+assertEquals(13, Math.hypot(3, 4, 12));
+assertEquals(15, Math.hypot(" 2 ",
+ "0x5",
+ { valueOf: function() { return "0xe"; } }));
+assertEquals(17, Math.hypot({ valueOf: function() { return 1; } },
+ { toString: function() { return 12; } },
+ { toString: function() { return "12"; } }));
+
+// Check function length.
+assertEquals(2, Math.hypot.length);
+
+// Check that 0 is returned for no arguments.
+assertEquals(0, Math.hypot());
+
+// Check that Infinity is returned if any of the arguments is +/-Infinity.
+assertEquals("Infinity", String(Math.hypot(NaN, Infinity)));
+assertEquals("Infinity", String(Math.hypot(1, -Infinity, 2)));
+
+// Check that NaN is returned if any argument is NaN and none is +/-Infinity/
+assertTrue(isNaN(Math.hypot(1, 2, NaN)));
+assertTrue(isNaN(Math.hypot(NaN, NaN, 4)));
+
+// Check that +0 is returned if all arguments are +/-0.
+assertEquals("Infinity", String(1/Math.hypot(-0)));
+assertEquals("Infinity", String(1/Math.hypot(0)));
+assertEquals("Infinity", String(1/Math.hypot(-0, -0)));
+assertEquals("Infinity", String(1/Math.hypot(-0, 0)));
+
+// Check that we avoid overflows and underflows.
+assertEqualsDelta(5E300, Math.hypot(3E300, 4E300), 1E285);
+assertEqualsDelta(17E-300, Math.hypot(8E-300, 15E-300), 1E-315);
+assertEqualsDelta(19E300, Math.hypot(6E300, 6E300, 17E300), 1E285);
+
+// Check that we sufficiently account for rounding errors when summing up.
+// For this, we calculate a simple fractal square that recurses in the
+// fourth quarter.
+var fractals = [];
+var edge_length = Math.E * 1E20;
+
+var fractal_length = edge_length;
+while(fractal_length >= 1) {
+ fractal_length *= 0.5;
+ fractals.push(fractal_length);
+ fractals.push(fractal_length);
+ fractals.push(fractal_length);
+}
+
+fractals.push(fractal_length);
+assertEqualsDelta(edge_length, Math.hypot.apply(Math, fractals), 1E-15);
+fractals.reverse();
+assertEqualsDelta(edge_length, Math.hypot.apply(Math, fractals), 1E-15);
+// Also shuffle the array.
+var c = 0;
+function random_sort(a, b) { c++; return (c & 3) - 1.5; }
+fractals.sort(random_sort);
+assertEqualsDelta(edge_length, Math.hypot.apply(Math, fractals), 1E-15);
+fractals.sort(random_sort);
+assertEqualsDelta(edge_length, Math.hypot.apply(Math, fractals), 1E-15);
diff --git a/deps/v8/test/mjsunit/es6/math-log1p.js b/deps/v8/test/mjsunit/es6/math-log1p.js
new file mode 100644
index 0000000000..eefea6ee38
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-log1p.js
@@ -0,0 +1,41 @@
+// 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-maths
+
+assertTrue(isNaN(Math.log1p(NaN)));
+assertTrue(isNaN(Math.log1p(function() {})));
+assertTrue(isNaN(Math.log1p({ toString: function() { return NaN; } })));
+assertTrue(isNaN(Math.log1p({ valueOf: function() { return "abc"; } })));
+assertEquals("Infinity", String(1/Math.log1p(0)));
+assertEquals("-Infinity", String(1/Math.log1p(-0)));
+assertEquals("Infinity", String(Math.log1p(Infinity)));
+assertEquals("-Infinity", String(Math.log1p(-1)));
+assertTrue(isNaN(Math.log1p(-2)));
+assertTrue(isNaN(Math.log1p(-Infinity)));
+
+for (var x = 1E300; x > 1E-1; x *= 0.8) {
+ var expected = Math.log(x + 1);
+ assertEqualsDelta(expected, Math.log1p(x), expected * 1E-14);
+}
+
+// Values close to 0:
+// Use Taylor expansion at 1 for log(x) as test expectation:
+// log1p(x) == log(x + 1) == 0 + x / 1 - x^2 / 2 + x^3 / 3 - ...
+function log1p(x) {
+ var terms = [];
+ var prod = x;
+ for (var i = 1; i <= 20; i++) {
+ terms.push(prod / i);
+ prod *= -x;
+ }
+ var sum = 0;
+ while (terms.length > 0) sum += terms.pop();
+ return sum;
+}
+
+for (var x = 1E-1; x > 1E-300; x *= 0.8) {
+ var expected = log1p(x);
+ assertEqualsDelta(expected, Math.log1p(x), expected * 1E-14);
+}
diff --git a/deps/v8/test/mjsunit/es6/math-log2-log10.js b/deps/v8/test/mjsunit/es6/math-log2-log10.js
new file mode 100644
index 0000000000..2ab496012c
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-log2-log10.js
@@ -0,0 +1,47 @@
+// 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-maths
+
+[Math.log10, Math.log2].forEach( function(fun) {
+ assertTrue(isNaN(fun(NaN)));
+ assertTrue(isNaN(fun(fun)));
+ assertTrue(isNaN(fun({ toString: function() { return NaN; } })));
+ assertTrue(isNaN(fun({ valueOf: function() { return -1; } })));
+ assertTrue(isNaN(fun({ valueOf: function() { return "abc"; } })));
+ assertTrue(isNaN(fun(-0.1)));
+ assertTrue(isNaN(fun(-1)));
+ assertEquals("-Infinity", String(fun(0)));
+ assertEquals("-Infinity", String(fun(-0)));
+ assertEquals(0, fun(1));
+ assertEquals("Infinity", String(fun(Infinity)));
+});
+
+for (var i = -300; i < 300; i += 0.7) {
+ assertEqualsDelta(i, Math.log10(Math.pow(10, i)), 1E-13);
+ assertEqualsDelta(i, Math.log2(Math.pow(2, i)), 1E-13);
+}
diff --git a/deps/v8/test/mjsunit/es6/math-sign.js b/deps/v8/test/mjsunit/es6/math-sign.js
new file mode 100644
index 0000000000..8a89d62828
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-sign.js
@@ -0,0 +1,48 @@
+// 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-maths
+
+assertEquals("Infinity", String(1/Math.sign(0)));
+assertEquals("-Infinity", String(1/Math.sign(-0)));
+assertEquals(1, Math.sign(100));
+assertEquals(-1, Math.sign(-199));
+assertEquals(1, Math.sign(100.1));
+assertTrue(isNaN(Math.sign("abc")));
+assertTrue(isNaN(Math.sign({})));
+assertEquals(0, Math.sign([]));
+assertEquals(1, Math.sign([1]));
+assertEquals(-1, Math.sign([-100.1]));
+assertTrue(isNaN(Math.sign([1, 1])));
+assertEquals(1, Math.sign({ toString: function() { return "100"; } }));
+assertEquals(1, Math.sign({ toString: function() { return 100; } }));
+assertEquals(-1, Math.sign({ valueOf: function() { return -1.1; } }));
+assertEquals(-1, Math.sign({ valueOf: function() { return "-1.1"; } }));
+assertEquals(-1, Math.sign(-Infinity));
+assertEquals(1, Math.sign(Infinity));
+assertEquals(-1, Math.sign("-Infinity"));
+assertEquals(1, Math.sign("Infinity"));
diff --git a/deps/v8/test/mjsunit/es6/math-trunc.js b/deps/v8/test/mjsunit/es6/math-trunc.js
new file mode 100644
index 0000000000..ed91ed1380
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/math-trunc.js
@@ -0,0 +1,51 @@
+// 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-maths
+
+assertEquals("Infinity", String(1/Math.trunc(0)));
+assertEquals("-Infinity", String(1/Math.trunc(-0)));
+assertEquals("Infinity", String(1/Math.trunc(Math.PI/4)));
+assertEquals("-Infinity", String(1/Math.trunc(-Math.sqrt(2)/2)));
+assertEquals(100, Math.trunc(100));
+assertEquals(-199, Math.trunc(-199));
+assertEquals(100, Math.trunc(100.1));
+assertTrue(isNaN(Math.trunc("abc")));
+assertTrue(isNaN(Math.trunc({})));
+assertEquals(0, Math.trunc([]));
+assertEquals(1, Math.trunc([1]));
+assertEquals(-100, Math.trunc([-100.1]));
+assertTrue(isNaN(Math.trunc([1, 1])));
+assertEquals(-100, Math.trunc({ toString: function() { return "-100.3"; } }));
+assertEquals(10, Math.trunc({ toString: function() { return 10.1; } }));
+assertEquals(-1, Math.trunc({ valueOf: function() { return -1.1; } }));
+assertEquals("-Infinity",
+ String(1/Math.trunc({ valueOf: function() { return "-0.1"; } })));
+assertEquals("-Infinity", String(Math.trunc(-Infinity)));
+assertEquals("Infinity", String(Math.trunc(Infinity)));
+assertEquals("-Infinity", String(Math.trunc("-Infinity")));
+assertEquals("Infinity", String(Math.trunc("Infinity")));
diff --git a/deps/v8/test/mjsunit/es6/microtask-delivery.js b/deps/v8/test/mjsunit/es6/microtask-delivery.js
new file mode 100644
index 0000000000..f74385e635
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/microtask-delivery.js
@@ -0,0 +1,168 @@
+// Copyright 2012 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: --allow-natives-syntax
+
+var ordering = [];
+function reset() {
+ ordering = [];
+}
+
+function assertArrayValues(expected, actual) {
+ assertEquals(expected.length, actual.length);
+ for (var i = 0; i < expected.length; i++) {
+ assertEquals(expected[i], actual[i]);
+ }
+}
+
+function assertOrdering(expected) {
+ %RunMicrotasks();
+ assertArrayValues(expected, ordering);
+}
+
+function newPromise(id, fn) {
+ var r;
+ var t = 1;
+ var promise = new Promise(function(resolve) {
+ r = resolve;
+ if (fn) fn();
+ });
+
+ var next = promise.then(function(value) {
+ ordering.push('p' + id);
+ return value;
+ });
+
+ return {
+ resolve: r,
+ then: function(fn) {
+ next = next.then(function(value) {
+ ordering.push('p' + id + ':' + t++);
+ return fn ? fn(value) : value;
+ });
+
+ return this;
+ }
+ };
+}
+
+function newObserver(id, fn, obj) {
+ var observer = {
+ value: 1,
+ recordCounts: []
+ };
+
+ Object.observe(observer, function(records) {
+ ordering.push('o' + id);
+ observer.recordCounts.push(records.length);
+ if (fn) fn();
+ });
+
+ return observer;
+}
+
+
+(function PromiseThens() {
+ reset();
+
+ var p1 = newPromise(1).then();
+ var p2 = newPromise(2).then();
+
+ p1.resolve();
+ p2.resolve();
+
+ assertOrdering(['p1', 'p2', 'p1:1', 'p2:1']);
+})();
+
+
+(function ObserversBatch() {
+ reset();
+
+ var p1 = newPromise(1);
+ var p2 = newPromise(2);
+ var p3 = newPromise(3);
+
+ var ob1 = newObserver(1);
+ var ob2 = newObserver(2, function() {
+ ob3.value++;
+ p3.resolve();
+ ob1.value++;
+ });
+ var ob3 = newObserver(3);
+
+ p1.resolve();
+ ob1.value++;
+ p2.resolve();
+ ob2.value++;
+
+ assertOrdering(['p1', 'o1', 'o2', 'p2', 'o1', 'o3', 'p3']);
+ assertArrayValues([1, 1], ob1.recordCounts);
+ assertArrayValues([1], ob2.recordCounts);
+ assertArrayValues([1], ob3.recordCounts);
+})();
+
+
+(function ObserversGetAllRecords() {
+ reset();
+
+ var p1 = newPromise(1);
+ var p2 = newPromise(2);
+ var ob1 = newObserver(1, function() {
+ ob2.value++;
+ });
+ var ob2 = newObserver(2);
+
+ p1.resolve();
+ ob1.value++;
+ p2.resolve();
+ ob2.value++;
+
+ assertOrdering(['p1', 'o1', 'o2', 'p2']);
+ assertArrayValues([1], ob1.recordCounts);
+ assertArrayValues([2], ob2.recordCounts);
+})();
+
+
+(function NewObserverDeliveryGetsNewMicrotask() {
+ reset();
+
+ var p1 = newPromise(1);
+ var p2 = newPromise(2);
+ var ob1 = newObserver(1);
+ var ob2 = newObserver(2, function() {
+ ob1.value++;
+ });
+
+ p1.resolve();
+ ob1.value++;
+ p2.resolve();
+ ob2.value++;
+
+ assertOrdering(['p1', 'o1', 'o2', 'p2', 'o1']);
+ assertArrayValues([1, 1], ob1.recordCounts);
+ assertArrayValues([1], ob2.recordCounts);
+})();
diff --git a/deps/v8/test/mjsunit/es6/promises.js b/deps/v8/test/mjsunit/es6/promises.js
new file mode 100644
index 0000000000..96a7bbbf3f
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/promises.js
@@ -0,0 +1,801 @@
+// 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: --allow-natives-syntax
+
+var asyncAssertsExpected = 0;
+
+function assertAsyncRan() { ++asyncAssertsExpected }
+
+function assertAsync(b, s) {
+ if (b) {
+ print(s, "succeeded")
+ } else {
+ %AbortJS(s + " FAILED!") // Simply throwing here will have no effect.
+ }
+ --asyncAssertsExpected
+}
+
+function assertAsyncDone(iteration) {
+ var iteration = iteration || 0
+ var dummy = {}
+ Object.observe(dummy,
+ function() {
+ if (asyncAssertsExpected === 0)
+ assertAsync(true, "all")
+ else if (iteration > 10) // Shouldn't take more.
+ assertAsync(false, "all")
+ else
+ assertAsyncDone(iteration + 1)
+ }
+ )
+ dummy.dummy = dummy
+}
+
+
+(function() {
+ assertThrows(function() { Promise(function() {}) }, TypeError)
+})();
+
+(function() {
+ assertTrue(new Promise(function() {}) instanceof Promise)
+})();
+
+(function() {
+ assertThrows(function() { new Promise(5) }, TypeError)
+})();
+
+(function() {
+ assertDoesNotThrow(function() { new Promise(function() { throw 5 }) })
+})();
+
+(function() {
+ (new Promise(function() { throw 5 })).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r === 5, "new-throw") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.accept(5);
+ Promise.accept(5).chain(undefined, assertUnreachable).chain(
+ function(x) { assertAsync(x === 5, "resolved/chain-nohandler") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.reject(5).chain(assertUnreachable, undefined).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r === 5, "rejected/chain-nohandler") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.accept(5).then(undefined, assertUnreachable).chain(
+ function(x) { assertAsync(x === 5, "resolved/then-nohandler-undefined") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+ Promise.accept(6).then(null, assertUnreachable).chain(
+ function(x) { assertAsync(x === 6, "resolved/then-nohandler-null") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.reject(5).then(assertUnreachable, undefined).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r === 5, "rejected/then-nohandler-undefined") }
+ )
+ assertAsyncRan()
+ Promise.reject(6).then(assertUnreachable, null).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r === 6, "rejected/then-nohandler-null") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "resolved/chain") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(
+ function(x) { assertAsync(x === 5, "resolved/then") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.reject(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "rejected/chain") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.reject(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5, "rejected/then") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(function(x) { return x }, assertUnreachable).chain(
+ function(x) { assertAsync(x === p1, "resolved/chain/chain") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(function(x) { return x }, assertUnreachable).then(
+ function(x) { assertAsync(x === 5, "resolved/chain/then") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(function(x) { return 6 }, assertUnreachable).chain(
+ function(x) { assertAsync(x === 6, "resolved/chain/chain2") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(function(x) { return 6 }, assertUnreachable).then(
+ function(x) { assertAsync(x === 6, "resolved/chain/then2") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x) { return x + 1 }, assertUnreachable).chain(
+ function(x) { assertAsync(x === 6, "resolved/then/chain") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x) { return x + 1 }, assertUnreachable).then(
+ function(x) { assertAsync(x === 6, "resolved/then/then") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x){ return Promise.accept(x+1) }, assertUnreachable).chain(
+ function(x) { assertAsync(x === 6, "resolved/then/chain2") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x) { return Promise.accept(x+1) }, assertUnreachable).then(
+ function(x) { assertAsync(x === 6, "resolved/then/then2") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(function(x) { throw 6 }, assertUnreachable).chain(
+ assertUnreachable,
+ function(x) { assertAsync(x === 6, "resolved/chain-throw/chain") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(function(x) { throw 6 }, assertUnreachable).then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 6, "resolved/chain-throw/then") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x) { throw 6 }, assertUnreachable).chain(
+ assertUnreachable,
+ function(x) { assertAsync(x === 6, "resolved/then-throw/chain") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(function(x) { throw 6 }, assertUnreachable).then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 6, "resolved/then-throw/then") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "resolved/thenable/chain") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.then(
+ function(x) { assertAsync(x === 5, "resolved/thenable/then") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.reject(5)
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "rejected/thenable/chain") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.reject(5)
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5, "rejected/thenable/then") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "chain/resolve") },
+ assertUnreachable
+ )
+ deferred.resolve(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(
+ function(x) { assertAsync(x === 5, "then/resolve") },
+ assertUnreachable
+ )
+ deferred.resolve(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "chain/reject") },
+ assertUnreachable
+ )
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = Promise.accept(p1)
+ var p3 = Promise.accept(p2)
+ p3.then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5, "then/reject") }
+ )
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "chain/resolve/thenable") },
+ assertUnreachable
+ )
+ deferred.resolve(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.then(
+ function(x) { assertAsync(x === 5, "then/resolve/thenable") },
+ assertUnreachable
+ )
+ deferred.resolve(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.chain(
+ function(x) { assertAsync(x === p2, "chain/reject/thenable") },
+ assertUnreachable
+ )
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var p3 = Promise.accept(p2)
+ p3.then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5, "then/reject/thenable") }
+ )
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var deferred = Promise.defer()
+ var p3 = deferred.promise
+ p3.chain(
+ function(x) { assertAsync(x === p2, "chain/resolve2") },
+ assertUnreachable
+ )
+ deferred.resolve(p2)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var deferred = Promise.defer()
+ var p3 = deferred.promise
+ p3.then(
+ function(x) { assertAsync(x === 5, "then/resolve2") },
+ assertUnreachable
+ )
+ deferred.resolve(p2)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var deferred = Promise.defer()
+ var p3 = deferred.promise
+ p3.chain(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5, "chain/reject2") }
+ )
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = Promise.accept(p1)
+ var deferred = Promise.defer()
+ var p3 = deferred.promise
+ p3.then(
+ assertUnreachable,
+ function(x) { assertAsync(x === 5, "then/reject2") }
+ )
+ deferred.reject(5)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var deferred = Promise.defer()
+ var p3 = deferred.promise
+ p3.chain(
+ function(x) { assertAsync(x === p2, "chain/resolve/thenable2") },
+ assertUnreachable
+ )
+ deferred.resolve(p2)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(5)
+ var p2 = {then: function(onResolve, onReject) { onResolve(p1) }}
+ var deferred = Promise.defer()
+ var p3 = deferred.promise
+ p3.then(
+ function(x) { assertAsync(x === 5, "then/resolve/thenable2") },
+ assertUnreachable
+ )
+ deferred.resolve(p2)
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(0)
+ var p2 = p1.chain(function(x) { return p2 }, assertUnreachable)
+ p2.chain(
+ assertUnreachable,
+ function(r) { assertAsync(r instanceof TypeError, "cyclic/chain") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(0)
+ var p2 = p1.then(function(x) { return p2 }, assertUnreachable)
+ p2.chain(
+ assertUnreachable,
+ function(r) { assertAsync(r instanceof TypeError, "cyclic/then") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p = deferred.promise
+ deferred.resolve(p)
+ p.chain(
+ function(x) { assertAsync(x === p, "cyclic/deferred/chain") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p = deferred.promise
+ deferred.resolve(p)
+ p.then(
+ assertUnreachable,
+ function(r) { assertAsync(r instanceof TypeError, "cyclic/deferred/then") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.all({}).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r instanceof TypeError, "all/no-array") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.all([]).chain(
+ function(x) { assertAsync(x.length === 0, "all/resolve/empty") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred1 = Promise.defer()
+ var p1 = deferred1.promise
+ var deferred2 = Promise.defer()
+ var p2 = deferred2.promise
+ var deferred3 = Promise.defer()
+ var p3 = deferred3.promise
+ Promise.all([p1, p2, p3]).chain(
+ function(x) {
+ assertAsync(x.length === 3, "all/resolve")
+ assertAsync(x[0] === 1, "all/resolve/0")
+ assertAsync(x[1] === 2, "all/resolve/1")
+ assertAsync(x[2] === 3, "all/resolve/2")
+ },
+ assertUnreachable
+ )
+ deferred1.resolve(1)
+ deferred3.resolve(3)
+ deferred2.resolve(2)
+ assertAsyncRan()
+ assertAsyncRan()
+ assertAsyncRan()
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = Promise.accept(2)
+ var p3 = Promise.defer().promise
+ Promise.all([p1, p2, p3]).chain(
+ assertUnreachable,
+ assertUnreachable
+ )
+ deferred.resolve(1)
+})();
+
+(function() {
+ var deferred1 = Promise.defer()
+ var p1 = deferred1.promise
+ var deferred2 = Promise.defer()
+ var p2 = deferred2.promise
+ var deferred3 = Promise.defer()
+ var p3 = deferred3.promise
+ Promise.all([p1, p2, p3]).chain(
+ assertUnreachable,
+ function(x) { assertAsync(x === 2, "all/reject") }
+ )
+ deferred1.resolve(1)
+ deferred3.resolve(3)
+ deferred2.reject(2)
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.race([]).chain(
+ assertUnreachable,
+ assertUnreachable
+ )
+})();
+
+(function() {
+ var p1 = Promise.accept(1)
+ var p2 = Promise.accept(2)
+ var p3 = Promise.accept(3)
+ Promise.race([p1, p2, p3]).chain(
+ function(x) { assertAsync(x === 1, "resolved/one") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var p1 = Promise.accept(1)
+ var p2 = Promise.accept(2)
+ var p3 = Promise.accept(3)
+ Promise.race([0, p1, p2, p3]).chain(
+ function(x) { assertAsync(x === 0, "resolved-const/one") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ Promise.race({}).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r instanceof TypeError, "one/no-array") }
+ )
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred1 = Promise.defer()
+ var p1 = deferred1.promise
+ var deferred2 = Promise.defer()
+ var p2 = deferred2.promise
+ var deferred3 = Promise.defer()
+ var p3 = deferred3.promise
+ Promise.race([p1, p2, p3]).chain(
+ function(x) { assertAsync(x === 3, "one/resolve") },
+ assertUnreachable
+ )
+ deferred3.resolve(3)
+ deferred1.resolve(1)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred = Promise.defer()
+ var p1 = deferred.promise
+ var p2 = Promise.accept(2)
+ var p3 = Promise.defer().promise
+ Promise.race([p1, p2, p3]).chain(
+ function(x) { assertAsync(x === 2, "resolved/one") },
+ assertUnreachable
+ )
+ deferred.resolve(1)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred1 = Promise.defer()
+ var p1 = deferred1.promise
+ var deferred2 = Promise.defer()
+ var p2 = deferred2.promise
+ var deferred3 = Promise.defer()
+ var p3 = deferred3.promise
+ Promise.race([p1, p2, p3]).chain(
+ function(x) { assertAsync(x === 3, "one/resolve/reject") },
+ assertUnreachable
+ )
+ deferred3.resolve(3)
+ deferred1.reject(1)
+ assertAsyncRan()
+})();
+
+(function() {
+ var deferred1 = Promise.defer()
+ var p1 = deferred1.promise
+ var deferred2 = Promise.defer()
+ var p2 = deferred2.promise
+ var deferred3 = Promise.defer()
+ var p3 = deferred3.promise
+ Promise.race([p1, p2, p3]).chain(
+ assertUnreachable,
+ function(x) { assertAsync(x === 3, "one/reject/resolve") }
+ )
+ deferred3.reject(3)
+ deferred1.resolve(1)
+ assertAsyncRan()
+})();
+
+(function() {
+ var log
+ function MyPromise(resolver) {
+ log += "n"
+ var promise = new Promise(function(resolve, reject) {
+ resolver(
+ function(x) { log += "x" + x; resolve(x) },
+ function(r) { log += "r" + r; reject(r) }
+ )
+ })
+ promise.__proto__ = MyPromise.prototype
+ return promise
+ }
+
+ MyPromise.__proto__ = Promise
+ MyPromise.defer = function() {
+ log += "d"
+ return this.__proto__.defer.call(this)
+ }
+
+ MyPromise.prototype.__proto__ = Promise.prototype
+ MyPromise.prototype.chain = function(resolve, reject) {
+ log += "c"
+ return this.__proto__.__proto__.chain.call(this, resolve, reject)
+ }
+
+ log = ""
+ var p1 = new MyPromise(function(resolve, reject) { resolve(1) })
+ var p2 = new MyPromise(function(resolve, reject) { reject(2) })
+ var d3 = MyPromise.defer()
+ assertTrue(d3.promise instanceof Promise, "subclass/instance")
+ assertTrue(d3.promise instanceof MyPromise, "subclass/instance-my3")
+ assertTrue(log === "nx1nr2dn", "subclass/create")
+
+ log = ""
+ var p4 = MyPromise.resolve(4)
+ var p5 = MyPromise.reject(5)
+ assertTrue(p4 instanceof Promise, "subclass/instance4")
+ assertTrue(p4 instanceof MyPromise, "subclass/instance-my4")
+ assertTrue(p5 instanceof Promise, "subclass/instance5")
+ assertTrue(p5 instanceof MyPromise, "subclass/instance-my5")
+ d3.resolve(3)
+ assertTrue(log === "nx4nr5x3", "subclass/resolve")
+
+ log = ""
+ var d6 = MyPromise.defer()
+ d6.promise.chain(function(x) {
+ return new Promise(function(resolve) { resolve(x) })
+ }).chain(function() {})
+ d6.resolve(6)
+ assertTrue(log === "dncncnx6", "subclass/chain")
+
+ log = ""
+ Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16])
+ assertTrue(log === "nx14n", "subclass/all/arg")
+
+ log = ""
+ MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26])
+ assertTrue(log === "nx24nnx21nnx23nnnx25nnx26n", "subclass/all/self")
+})();
+
+
+assertAsyncDone()
diff --git a/deps/v8/test/mjsunit/es6/regress/regress-2034.js b/deps/v8/test/mjsunit/es6/regress/regress-2034.js
new file mode 100644
index 0000000000..5c738bf84d
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/regress/regress-2034.js
@@ -0,0 +1,44 @@
+// Copyright 2012 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.
+
+var key = {};
+var map = new WeakMap;
+Object.preventExtensions(key);
+
+// Try querying using frozen key.
+assertFalse(map.has(key));
+assertSame(undefined, map.get(key));
+
+// Try adding using frozen key.
+map.set(key, 1);
+assertTrue(map.has(key));
+assertSame(1, map.get(key));
+
+// Try deleting using frozen key.
+map.delete(key, 1);
+assertFalse(map.has(key));
+assertSame(undefined, map.get(key));
diff --git a/deps/v8/test/mjsunit/es6/regress/regress-2156.js b/deps/v8/test/mjsunit/es6/regress/regress-2156.js
new file mode 100644
index 0000000000..fba2a29867
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/regress/regress-2156.js
@@ -0,0 +1,39 @@
+// Copyright 2012 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: --allow-natives-syntax
+
+var key1 = {};
+var key2 = {};
+var map = new WeakMap;
+
+// Adding hidden properties preserves map sharing. Putting the key into
+// a WeakMap will cause the first hidden property to be added.
+assertTrue(%HaveSameMap(key1, key2));
+map.set(key1, 1);
+map.set(key2, 2);
+assertTrue(%HaveSameMap(key1, key2));
diff --git a/deps/v8/test/mjsunit/es6/regress/regress-2829.js b/deps/v8/test/mjsunit/es6/regress/regress-2829.js
new file mode 100644
index 0000000000..b48039cf0b
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/regress/regress-2829.js
@@ -0,0 +1,51 @@
+// 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.
+
+(function test1() {
+ var wm1 = new WeakMap();
+ wm1.set(Object.prototype, 23);
+ assertTrue(wm1.has(Object.prototype));
+ Object.freeze(Object.prototype);
+
+ var wm2 = new WeakMap();
+ var o = {};
+ wm2.set(o, 42);
+ assertEquals(42, wm2.get(o));
+})();
+
+(function test2() {
+ var wm1 = new WeakMap();
+ var o1 = {};
+ wm1.set(o1, 23);
+ assertTrue(wm1.has(o1));
+ Object.freeze(o1);
+
+ var wm2 = new WeakMap();
+ var o2 = Object.create(o1);
+ wm2.set(o2, 42);
+ assertEquals(42, wm2.get(o2));
+})();
diff --git a/deps/v8/test/mjsunit/es6/weak_collections.js b/deps/v8/test/mjsunit/es6/weak_collections.js
new file mode 100644
index 0000000000..74235e7d2c
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/weak_collections.js
@@ -0,0 +1,333 @@
+// Copyright 2012 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: --expose-gc --allow-natives-syntax
+
+
+// Note: this test is superseded by harmony/collections.js.
+// IF YOU CHANGE THIS FILE, apply the same changes to harmony/collections.js!
+// TODO(rossberg): Remove once non-weak collections have caught up.
+
+// Test valid getter and setter calls on WeakSets.
+function TestValidSetCalls(m) {
+ assertDoesNotThrow(function () { m.add(new Object) });
+ assertDoesNotThrow(function () { m.has(new Object) });
+ assertDoesNotThrow(function () { m.delete(new Object) });
+}
+TestValidSetCalls(new WeakSet);
+
+
+// Test valid getter and setter calls on WeakMaps
+function TestValidMapCalls(m) {
+ assertDoesNotThrow(function () { m.get(new Object) });
+ assertDoesNotThrow(function () { m.set(new Object) });
+ assertDoesNotThrow(function () { m.has(new Object) });
+ assertDoesNotThrow(function () { m.delete(new Object) });
+}
+TestValidMapCalls(new WeakMap);
+
+
+// Test invalid getter and setter calls for WeakMap
+function TestInvalidCalls(m) {
+ assertThrows(function () { m.get(undefined) }, TypeError);
+ assertThrows(function () { m.set(undefined, 0) }, TypeError);
+ assertThrows(function () { m.get(null) }, TypeError);
+ assertThrows(function () { m.set(null, 0) }, TypeError);
+ assertThrows(function () { m.get(0) }, TypeError);
+ assertThrows(function () { m.set(0, 0) }, TypeError);
+ assertThrows(function () { m.get('a-key') }, TypeError);
+ assertThrows(function () { m.set('a-key', 0) }, TypeError);
+}
+TestInvalidCalls(new WeakMap);
+
+
+// Test expected behavior for WeakSets
+function TestSet(set, key) {
+ assertFalse(set.has(key));
+ assertSame(undefined, set.add(key));
+ assertTrue(set.has(key));
+ assertTrue(set.delete(key));
+ assertFalse(set.has(key));
+ assertFalse(set.delete(key));
+ assertFalse(set.has(key));
+}
+function TestSetBehavior(set) {
+ for (var i = 0; i < 20; i++) {
+ TestSet(set, new Object);
+ TestSet(set, i);
+ TestSet(set, i / 100);
+ TestSet(set, 'key-' + i);
+ }
+ var keys = [ +0, -0, +Infinity, -Infinity, true, false, null, undefined ];
+ for (var i = 0; i < keys.length; i++) {
+ TestSet(set, keys[i]);
+ }
+}
+TestSet(new WeakSet, new Object);
+
+
+// Test expected mapping behavior for WeakMaps
+function TestMapping(map, key, value) {
+ assertSame(undefined, map.set(key, value));
+ assertSame(value, map.get(key));
+}
+function TestMapBehavior1(m) {
+ TestMapping(m, new Object, 23);
+ TestMapping(m, new Object, 'the-value');
+ TestMapping(m, new Object, new Object);
+}
+TestMapBehavior1(new WeakMap);
+
+
+// Test expected querying behavior of WeakMaps
+function TestQuery(m) {
+ var key = new Object;
+ var values = [ 'x', 0, +Infinity, -Infinity, true, false, null, undefined ];
+ for (var i = 0; i < values.length; i++) {
+ TestMapping(m, key, values[i]);
+ assertTrue(m.has(key));
+ assertFalse(m.has(new Object));
+ }
+}
+TestQuery(new WeakMap);
+
+
+// Test expected deletion behavior of WeakMaps
+function TestDelete(m) {
+ var key = new Object;
+ TestMapping(m, key, 'to-be-deleted');
+ assertTrue(m.delete(key));
+ assertFalse(m.delete(key));
+ assertFalse(m.delete(new Object));
+ assertSame(m.get(key), undefined);
+}
+TestDelete(new WeakMap);
+
+
+// Test GC of WeakMaps with entry
+function TestGC1(m) {
+ var key = new Object;
+ m.set(key, 'not-collected');
+ gc();
+ assertSame('not-collected', m.get(key));
+}
+TestGC1(new WeakMap);
+
+
+// Test GC of WeakMaps with chained entries
+function TestGC2(m) {
+ var head = new Object;
+ for (key = head, i = 0; i < 10; i++, key = m.get(key)) {
+ m.set(key, new Object);
+ }
+ gc();
+ var count = 0;
+ for (key = head; key != undefined; key = m.get(key)) {
+ count++;
+ }
+ assertEquals(11, count);
+}
+TestGC2(new WeakMap);
+
+
+// Test property attribute [[Enumerable]]
+function TestEnumerable(func) {
+ function props(x) {
+ var array = [];
+ for (var p in x) array.push(p);
+ return array.sort();
+ }
+ assertArrayEquals([], props(func));
+ assertArrayEquals([], props(func.prototype));
+ assertArrayEquals([], props(new func()));
+}
+TestEnumerable(WeakMap);
+TestEnumerable(WeakSet);
+
+
+// Test arbitrary properties on WeakMaps
+function TestArbitrary(m) {
+ function TestProperty(map, property, value) {
+ map[property] = value;
+ assertEquals(value, map[property]);
+ }
+ for (var i = 0; i < 20; i++) {
+ TestProperty(m, i, 'val' + i);
+ TestProperty(m, 'foo' + i, 'bar' + i);
+ }
+ TestMapping(m, new Object, 'foobar');
+}
+TestArbitrary(new WeakMap);
+
+
+// Test direct constructor call
+assertThrows(function() { WeakMap(); }, TypeError);
+assertThrows(function() { WeakSet(); }, TypeError);
+
+
+// Test some common JavaScript idioms for WeakMaps
+var m = new WeakMap;
+assertTrue(m instanceof WeakMap);
+assertTrue(WeakMap.prototype.set instanceof Function)
+assertTrue(WeakMap.prototype.get instanceof Function)
+assertTrue(WeakMap.prototype.has instanceof Function)
+assertTrue(WeakMap.prototype.delete instanceof Function)
+assertTrue(WeakMap.prototype.clear instanceof Function)
+
+
+// Test some common JavaScript idioms for WeakSets
+var s = new WeakSet;
+assertTrue(s instanceof WeakSet);
+assertTrue(WeakSet.prototype.add instanceof Function)
+assertTrue(WeakSet.prototype.has instanceof Function)
+assertTrue(WeakSet.prototype.delete instanceof Function)
+assertTrue(WeakSet.prototype.clear instanceof Function)
+
+
+// Test class of instance and prototype.
+assertEquals("WeakMap", %_ClassOf(new WeakMap))
+assertEquals("Object", %_ClassOf(WeakMap.prototype))
+assertEquals("WeakSet", %_ClassOf(new WeakSet))
+assertEquals("Object", %_ClassOf(WeakMap.prototype))
+
+
+// Test name of constructor.
+assertEquals("WeakMap", WeakMap.name);
+assertEquals("WeakSet", WeakSet.name);
+
+
+// Test prototype property of WeakMap and WeakSet.
+function TestPrototype(C) {
+ assertTrue(C.prototype instanceof Object);
+ assertEquals({
+ value: {},
+ writable: false,
+ enumerable: false,
+ configurable: false
+ }, Object.getOwnPropertyDescriptor(C, "prototype"));
+}
+TestPrototype(WeakMap);
+TestPrototype(WeakSet);
+
+
+// Test constructor property of the WeakMap and WeakSet prototype.
+function TestConstructor(C) {
+ assertFalse(C === Object.prototype.constructor);
+ assertSame(C, C.prototype.constructor);
+ assertSame(C, (new C).__proto__.constructor);
+}
+TestConstructor(WeakMap);
+TestConstructor(WeakSet);
+
+
+// Test the WeakMap and WeakSet global properties themselves.
+function TestDescriptor(global, C) {
+ assertEquals({
+ value: C,
+ writable: true,
+ enumerable: false,
+ configurable: true
+ }, Object.getOwnPropertyDescriptor(global, C.name));
+}
+TestDescriptor(this, WeakMap);
+TestDescriptor(this, WeakSet);
+
+
+// Regression test for WeakMap prototype.
+assertTrue(WeakMap.prototype.constructor === WeakMap)
+assertTrue(Object.getPrototypeOf(WeakMap.prototype) === Object.prototype)
+
+
+// Regression test for issue 1617: The prototype of the WeakMap constructor
+// needs to be unique (i.e. different from the one of the Object constructor).
+assertFalse(WeakMap.prototype === Object.prototype);
+var o = Object.create({});
+assertFalse("get" in o);
+assertFalse("set" in o);
+assertEquals(undefined, o.get);
+assertEquals(undefined, o.set);
+var o = Object.create({}, { myValue: {
+ value: 10,
+ enumerable: false,
+ configurable: true,
+ writable: true
+}});
+assertEquals(10, o.myValue);
+
+
+// Regression test for issue 1884: Invoking any of the methods for Harmony
+// maps, sets, or weak maps, with a wrong type of receiver should be throwing
+// a proper TypeError.
+var alwaysBogus = [ undefined, null, true, "x", 23, {} ];
+var bogusReceiversTestSet = [
+ { proto: WeakMap.prototype,
+ funcs: [ 'get', 'set', 'has', 'delete' ],
+ receivers: alwaysBogus.concat([ new WeakSet ]),
+ },
+ { proto: WeakSet.prototype,
+ funcs: [ 'add', 'has', 'delete' ],
+ receivers: alwaysBogus.concat([ new WeakMap ]),
+ },
+];
+function TestBogusReceivers(testSet) {
+ for (var i = 0; i < testSet.length; i++) {
+ var proto = testSet[i].proto;
+ var funcs = testSet[i].funcs;
+ var receivers = testSet[i].receivers;
+ for (var j = 0; j < funcs.length; j++) {
+ var func = proto[funcs[j]];
+ for (var k = 0; k < receivers.length; k++) {
+ assertThrows(function () { func.call(receivers[k], {}) }, TypeError);
+ }
+ }
+ }
+}
+TestBogusReceivers(bogusReceiversTestSet);
+
+
+// Test WeakMap clear
+(function() {
+ var k = new Object();
+ var w = new WeakMap();
+ w.set(k, 23);
+ assertTrue(w.has(k));
+ assertEquals(23, w.get(k));
+ w.clear();
+ assertFalse(w.has(k));
+ assertEquals(undefined, w.get(k));
+})();
+
+
+// Test WeakSet clear
+(function() {
+ var k = new Object();
+ var w = new WeakSet();
+ w.add(k);
+ assertTrue(w.has(k));
+ w.clear();
+ assertFalse(w.has(k));
+})();