summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit')
-rw-r--r--deps/v8/test/mjsunit/accessors-no-prototype.js51
-rw-r--r--deps/v8/test/mjsunit/array-push12.js23
-rw-r--r--deps/v8/test/mjsunit/asm/int32modb.js26
-rw-r--r--deps/v8/test/mjsunit/asm/redundancy1.js26
-rw-r--r--deps/v8/test/mjsunit/asm/redundancy2.js29
-rw-r--r--deps/v8/test/mjsunit/asm/switch.js120
-rw-r--r--deps/v8/test/mjsunit/big-array-literal.js1
-rw-r--r--deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js22
-rw-r--r--deps/v8/test/mjsunit/compiler/opt-next-call.js9
-rw-r--r--deps/v8/test/mjsunit/compiler/optimized-for-in.js12
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-alignment.js17
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-backedges1.js31
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-block-scope-func.js27
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-block-scope-id.js40
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-block-scope.js116
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-follow.js61
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-for-let.js82
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-forin.js26
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-forof.js35
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-function-id.js33
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-function-id2.js28
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-function.js31
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-manual1.js35
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-manual2.js35
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-maze1.js51
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-maze2.js63
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-multiple.js44
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-multiple2.js51
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-multiple3.js57
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-nested2.js24
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-nested2b.js25
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-nested3.js26
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-nested3b.js28
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-regex-id.js54
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-sar.js2
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-simple.js34
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-top1.js16
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-top2.js19
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-top3.js22
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-warm.js2
-rw-r--r--deps/v8/test/mjsunit/compiler/osr-while-let.js58
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-3812.js19
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-416359.js10
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-445907.js14
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-446647.js11
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-447567.js15
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-451012.js12
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-452427.js18
-rw-r--r--deps/v8/test/mjsunit/compiler/regress-to-number-binop-deopt.js25
-rw-r--r--deps/v8/test/mjsunit/count-based-osr.js5
-rw-r--r--deps/v8/test/mjsunit/d8-os.js2
-rw-r--r--deps/v8/test/mjsunit/debug-script.js6
-rw-r--r--deps/v8/test/mjsunit/es6/array-tostring.js157
-rw-r--r--deps/v8/test/mjsunit/es6/iteration-syntax.js48
-rw-r--r--deps/v8/test/mjsunit/es6/object-tostring.js14
-rw-r--r--deps/v8/test/mjsunit/harmony/array-concat.js4
-rw-r--r--deps/v8/test/mjsunit/harmony/array-from.js54
-rw-r--r--deps/v8/test/mjsunit/harmony/array-of.js24
-rw-r--r--deps/v8/test/mjsunit/harmony/class-computed-property-names-super.js76
-rw-r--r--deps/v8/test/mjsunit/harmony/class-property-name-eval-arguments.js79
-rw-r--r--deps/v8/test/mjsunit/harmony/classes-experimental.js339
-rw-r--r--deps/v8/test/mjsunit/harmony/classes-lazy-parsing.js21
-rw-r--r--deps/v8/test/mjsunit/harmony/classes-subclass-arrays.js150
-rw-r--r--deps/v8/test/mjsunit/harmony/classes.js76
-rw-r--r--deps/v8/test/mjsunit/harmony/computed-property-names-classes.js390
-rw-r--r--deps/v8/test/mjsunit/harmony/computed-property-names-object-literals-methods.js121
-rw-r--r--deps/v8/test/mjsunit/harmony/computed-property-names-super.js79
-rw-r--r--deps/v8/test/mjsunit/harmony/computed-property-names.js279
-rw-r--r--deps/v8/test/mjsunit/harmony/method-name-eval-arguments.js35
-rw-r--r--deps/v8/test/mjsunit/harmony/module-parsing-eval.js (renamed from deps/v8/test/mjsunit/regress/regress-1145.js)35
-rw-r--r--deps/v8/test/mjsunit/harmony/module-parsing.js190
-rw-r--r--deps/v8/test/mjsunit/harmony/modules.js8
-rw-r--r--deps/v8/test/mjsunit/harmony/object-literals-method.js24
-rw-r--r--deps/v8/test/mjsunit/harmony/object-literals-property-shorthand.js22
-rw-r--r--deps/v8/test/mjsunit/harmony/object-literals-super.js35
-rw-r--r--deps/v8/test/mjsunit/harmony/regexp-flags.js11
-rw-r--r--deps/v8/test/mjsunit/harmony/regress/regress-455141.js15
-rw-r--r--deps/v8/test/mjsunit/harmony/regress/regress-typedarray-out-of-bounds.js10
-rw-r--r--deps/v8/test/mjsunit/harmony/rest-params-lazy-parsing.js17
-rw-r--r--deps/v8/test/mjsunit/harmony/rest-params.js182
-rw-r--r--deps/v8/test/mjsunit/harmony/super.js2497
-rw-r--r--deps/v8/test/mjsunit/harmony/templates.js13
-rw-r--r--deps/v8/test/mjsunit/harmony/toMethod.js23
-rw-r--r--deps/v8/test/mjsunit/harmony/unicode-escapes-in-regexps.js212
-rw-r--r--deps/v8/test/mjsunit/mirror-object.js6
-rw-r--r--deps/v8/test/mjsunit/mirror-regexp.js4
-rw-r--r--deps/v8/test/mjsunit/mjsunit.js28
-rw-r--r--deps/v8/test/mjsunit/mjsunit.status63
-rw-r--r--deps/v8/test/mjsunit/object-literal-multiple-fields.js96
-rw-r--r--deps/v8/test/mjsunit/object-literal-multiple-proto-fields.js21
-rw-r--r--deps/v8/test/mjsunit/osr-elements-kind.js3
-rw-r--r--deps/v8/test/mjsunit/property-name-eval-arguments.js59
-rw-r--r--deps/v8/test/mjsunit/regress-sync-optimized-lists.js4
-rw-r--r--deps/v8/test/mjsunit/regress/binop-in-effect-context-deopt.js2
-rw-r--r--deps/v8/test/mjsunit/regress/call-function-in-effect-context-deopt.js2
-rw-r--r--deps/v8/test/mjsunit/regress/regress-1118.js18
-rw-r--r--deps/v8/test/mjsunit/regress/regress-2618.js6
-rw-r--r--deps/v8/test/mjsunit/regress/regress-2825.js40
-rw-r--r--deps/v8/test/mjsunit/regress/regress-3032.js4
-rw-r--r--deps/v8/test/mjsunit/regress/regress-3501.js11
-rw-r--r--deps/v8/test/mjsunit/regress/regress-379770.js4
-rw-r--r--deps/v8/test/mjsunit/regress/regress-3859.js6
-rw-r--r--deps/v8/test/mjsunit/regress/regress-3865.js14
-rw-r--r--deps/v8/test/mjsunit/regress/regress-3884.js27
-rw-r--r--deps/v8/test/mjsunit/regress/regress-437713.js26
-rw-r--r--deps/v8/test/mjsunit/regress/regress-444805.js8
-rw-r--r--deps/v8/test/mjsunit/regress/regress-444805.js-script11
-rw-r--r--deps/v8/test/mjsunit/regress/regress-446389.js12
-rw-r--r--deps/v8/test/mjsunit/regress/regress-447526.js25
-rw-r--r--deps/v8/test/mjsunit/regress/regress-447561.js10
-rw-r--r--deps/v8/test/mjsunit/regress/regress-448711.js15
-rw-r--r--deps/v8/test/mjsunit/regress/regress-449070.js10
-rw-r--r--deps/v8/test/mjsunit/regress/regress-449291.js19
-rw-r--r--deps/v8/test/mjsunit/regress/regress-450895.js9
-rw-r--r--deps/v8/test/mjsunit/regress/regress-451322.js17
-rw-r--r--deps/v8/test/mjsunit/regress/regress-451958.js31
-rw-r--r--deps/v8/test/mjsunit/regress/regress-453481.js127
-rw-r--r--deps/v8/test/mjsunit/regress/regress-454725.js42
-rw-r--r--deps/v8/test/mjsunit/regress/regress-455212.js (renamed from deps/v8/test/mjsunit/regress/regress-634.js)13
-rw-r--r--deps/v8/test/mjsunit/regress/regress-457935.js26
-rw-r--r--deps/v8/test/mjsunit/regress/regress-458876.js16
-rw-r--r--deps/v8/test/mjsunit/regress/regress-458987.js16
-rw-r--r--deps/v8/test/mjsunit/regress/regress-459955.js10
-rw-r--r--deps/v8/test/mjsunit/regress/regress-arg-materialize-store.js22
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-150545.js5
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-387599.js4
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-448730.js14
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-450642.js5
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-450960.js20
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-451013.js11
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-451016.js10
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-451770.js15
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-454091.js9
-rw-r--r--deps/v8/test/mjsunit/regress/regress-crbug-455644.js12
-rw-r--r--deps/v8/test/mjsunit/regress/regress-deoptimize-constant-keyed-load.js22
-rw-r--r--deps/v8/test/mjsunit/regress/regress-merge-descriptors.js2
-rw-r--r--deps/v8/test/mjsunit/regress/regress-undefined-nan.js35
-rw-r--r--deps/v8/test/mjsunit/regress/regress-undefined-nan2.js12
-rw-r--r--deps/v8/test/mjsunit/regress/regress-undefined-nan3.js32
-rw-r--r--deps/v8/test/mjsunit/regress/string-set-char-deopt.js2
-rw-r--r--deps/v8/test/mjsunit/strict-mode.js89
-rw-r--r--deps/v8/test/mjsunit/strong/classes.js17
-rw-r--r--deps/v8/test/mjsunit/strong/delete.js11
-rw-r--r--deps/v8/test/mjsunit/strong/empty-statement.js18
-rw-r--r--deps/v8/test/mjsunit/strong/equality.js10
-rw-r--r--deps/v8/test/mjsunit/strong/for-in.js17
-rw-r--r--deps/v8/test/mjsunit/strong/functions.js33
-rw-r--r--deps/v8/test/mjsunit/strong/mutually-recursive-funcs.js25
-rw-r--r--deps/v8/test/mjsunit/strong/use-strong.js27
-rw-r--r--deps/v8/test/mjsunit/strong/var-let-const.js22
-rw-r--r--deps/v8/test/mjsunit/testcfg.py8
-rw-r--r--deps/v8/test/mjsunit/tools/tickprocessor-test.default10
-rw-r--r--deps/v8/test/mjsunit/tools/tickprocessor-test.ignore-unknown10
-rw-r--r--deps/v8/test/mjsunit/tools/tickprocessor-test.separate-ic10
-rw-r--r--deps/v8/test/mjsunit/tools/tickprocessor.js8
155 files changed, 6539 insertions, 1738 deletions
diff --git a/deps/v8/test/mjsunit/accessors-no-prototype.js b/deps/v8/test/mjsunit/accessors-no-prototype.js
new file mode 100644
index 0000000000..9c429fc48a
--- /dev/null
+++ b/deps/v8/test/mjsunit/accessors-no-prototype.js
@@ -0,0 +1,51 @@
+// 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 TestGetter() {
+ var o = {
+ get x() {}
+ };
+ var desc = Object.getOwnPropertyDescriptor(o, 'x');
+ assertEquals('function', typeof desc.get);
+ assertFalse('prototype' in desc.get);
+
+ assertThrows(function() {
+ new desc.get();
+ }, TypeError);
+})();
+
+
+(function TestSetter() {
+ var o = {
+ set x(_) {}
+ };
+ var desc = Object.getOwnPropertyDescriptor(o, 'x');
+ assertEquals('function', typeof desc.set);
+ assertFalse('prototype' in desc.set);
+
+ assertThrows(function() {
+ new desc.set();
+ }, TypeError);
+})();
+
+
+(function TestBoth() {
+ var o = {
+ get x() {},
+ set x(_) {}
+ };
+ var desc = Object.getOwnPropertyDescriptor(o, 'x');
+ assertEquals('function', typeof desc.get);
+ assertEquals('function', typeof desc.set);
+ assertFalse('prototype' in desc.get);
+ assertFalse('prototype' in desc.set);
+
+ assertThrows(function() {
+ new desc.get();
+ }, TypeError);
+ assertThrows(function() {
+ new desc.set();
+ }, TypeError);
+})();
diff --git a/deps/v8/test/mjsunit/array-push12.js b/deps/v8/test/mjsunit/array-push12.js
new file mode 100644
index 0000000000..f4c15b484b
--- /dev/null
+++ b/deps/v8/test/mjsunit/array-push12.js
@@ -0,0 +1,23 @@
+// 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: --allow-natives-syntax
+
+var a = [];
+for (var i = -20; i < 0; ++i) {
+ a[i] = 0;
+}
+
+function g() {
+ [].push.apply(a, arguments);
+}
+
+function f() {
+ g();
+}
+
+g();
+g();
+%OptimizeFunctionOnNextCall(f);
+f();
diff --git a/deps/v8/test/mjsunit/asm/int32modb.js b/deps/v8/test/mjsunit/asm/int32modb.js
new file mode 100644
index 0000000000..5081b49ae5
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/int32modb.js
@@ -0,0 +1,26 @@
+// 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 stdlib = {};
+var foreign = {};
+var heap = new ArrayBuffer(64 * 1024);
+
+var mod = (function Module(stdlib, foreign, heap) {
+ "use asm";
+ function mod(dividend, divisor) {
+ dividend = dividend|0;
+ divisor = divisor|0;
+ return (dividend % divisor) | 0;
+ }
+ return { mod: mod };
+})(stdlib, foreign, heap).mod;
+
+var divisors = [-2147483648, -32 * 1024, -1000, -16, -7, -2, -1, 0,
+ 1, 3, 4, 10, 64, 99, 1023, 1024, 2147483647];
+for (var i = 0; i < divisors.length; i++) {
+ var divisor = divisors[i];
+ for (var dividend = -2147483648; dividend < 2147483648; dividend += 3999773) {
+ assertEquals((dividend % divisor) | 0, mod(dividend, divisor));
+ }
+}
diff --git a/deps/v8/test/mjsunit/asm/redundancy1.js b/deps/v8/test/mjsunit/asm/redundancy1.js
new file mode 100644
index 0000000000..c7e0e37453
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/redundancy1.js
@@ -0,0 +1,26 @@
+// 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: --turbo-splitting
+
+function module(stdlib, foreign, heap) {
+ "use asm";
+ function foo(i) {
+ var j = 0;
+ i = i|0;
+ if (i < 0) {
+ j = i+1|0;
+ }
+ if (i > 0) {
+ j = i+1|0;
+ }
+ return j;
+ }
+ return { foo: foo };
+}
+
+var foo = module(this, {}, new ArrayBuffer(64*1024)).foo;
+assertEquals(0, foo(0));
+assertEquals(0, foo(-1));
+assertEquals(12, foo(11));
diff --git a/deps/v8/test/mjsunit/asm/redundancy2.js b/deps/v8/test/mjsunit/asm/redundancy2.js
new file mode 100644
index 0000000000..95a55b533e
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/redundancy2.js
@@ -0,0 +1,29 @@
+// 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: --turbo-splitting
+
+function module(stdlib, foreign, heap) {
+ "use asm";
+ function foo(i) {
+ var j = 0;
+ i = i|0;
+ switch (i) {
+ case 0:
+ j = i+1|0;
+ break;
+ case 1:
+ j = i+1|0;
+ break;
+ default:
+ j = i;
+ break;
+ }
+ return j;
+ }
+ return { foo: foo };
+}
+
+var foo = module(this, {}, new ArrayBuffer(64*1024)).foo;
+print(foo(1));
diff --git a/deps/v8/test/mjsunit/asm/switch.js b/deps/v8/test/mjsunit/asm/switch.js
new file mode 100644
index 0000000000..5cb6329e43
--- /dev/null
+++ b/deps/v8/test/mjsunit/asm/switch.js
@@ -0,0 +1,120 @@
+// 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 stdlib = this;
+var foreign = {};
+var heap = new ArrayBuffer(64 * 1024);
+
+
+var switch1 = (function(stdlib, foreign, heap) {
+ "use asm";
+ function switch1(i) {
+ i = i|0;
+ switch (i) {
+ case 0: return 1;
+ case 1: return 2;
+ default: return i|0;
+ }
+ }
+ return { switch1: switch1 };
+})(stdlib, foreign, heap).switch1;
+
+assertEquals(1, switch1(0));
+assertEquals(2, switch1(1));
+for (var i = -2147483648; i < 2147483648; i += 3999773) {
+ assertEquals(i, switch1(i));
+}
+
+
+var switch2 = (function(stdlib, foreign, heap) {
+ "use asm";
+ function switch2(i) {
+ i = i|0;
+ var j = 0;
+ switch (i) {
+ case 0: j = 1; break;
+ case 1: j = 2; break;
+ case 2: j = 3; break;
+ default: j = i|0; break;
+ }
+ return j|0;
+ }
+ return { switch2: switch2 };
+})(stdlib, foreign, heap).switch2;
+
+assertEquals(1, switch2(0));
+assertEquals(2, switch2(1));
+assertEquals(3, switch2(2));
+for (var i = -2147483648; i < 2147483648; i += 3999773) {
+ assertEquals(i, switch2(i));
+}
+
+
+var switch3 = (function(stdlib, foreign, heap) {
+ "use asm";
+ function switch3(i) {
+ i = i|0;
+ var j = 0;
+ switch (i) {
+ case 0:
+ case 1: j = 1; break;
+ case 2:
+ case 3: j = 2; break;
+ case 4:
+ case 5: j = 3; break;
+ default: j = 0; break;
+ }
+ return j|0;
+ }
+ return { switch3: switch3 };
+})(stdlib, foreign, heap).switch3;
+
+assertEquals(1, switch3(0));
+assertEquals(1, switch3(1));
+assertEquals(2, switch3(2));
+assertEquals(2, switch3(3));
+assertEquals(3, switch3(4));
+assertEquals(3, switch3(5));
+for (var i = -2147483648; i < 2147483648; i += 3999773) {
+ assertEquals(0, switch3(i));
+}
+
+
+var switch4 = (function(stdlib, foreign, heap) {
+ "use asm";
+ function switch4(i) {
+ i = i|0;
+ switch (i) {
+ case -1:
+ case 1:
+ return 0;
+
+ case -2:
+ case 2:
+ return 1;
+
+ case -3:
+ case 3:
+ return 2;
+
+ case -8:
+ case 8:
+ return 3;
+
+ default:
+ return 4;
+ }
+ }
+ return { switch4: switch4 };
+})(stdlib, foreign, heap).switch4;
+
+assertEquals(4, switch4(0));
+assertEquals(0, switch4(-1));
+assertEquals(0, switch4(1));
+assertEquals(1, switch4(-2));
+assertEquals(1, switch4(2));
+assertEquals(3, switch4(-8));
+assertEquals(3, switch4(8));
+assertEquals(4, switch4(-123456789));
+assertEquals(4, switch4(123456789));
diff --git a/deps/v8/test/mjsunit/big-array-literal.js b/deps/v8/test/mjsunit/big-array-literal.js
index 401807f684..7e19c0a2dc 100644
--- a/deps/v8/test/mjsunit/big-array-literal.js
+++ b/deps/v8/test/mjsunit/big-array-literal.js
@@ -26,6 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// On MacOS X 10.7.5, this test needs a stack size of at least 788 kBytes.
+// On PPC64, this test needs a stack size of at least 698 kBytes.
// Flags: --stack-size=800
// Flags: --turbo-deoptimization
diff --git a/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js b/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js
new file mode 100644
index 0000000000..d4beff9f6e
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/opt-next-call-turbo.js
@@ -0,0 +1,22 @@
+// 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: --allow-natives-syntax --turbo-filter=*
+
+function foo() {
+ with ({ value:"fooed" }) { return value; }
+}
+
+%OptimizeFunctionOnNextCall(foo);
+assertEquals("fooed", foo());
+assertOptimized(foo);
+
+function bar() {
+ with ({ value:"bared" }) { return value; }
+}
+
+assertEquals("bared", bar());
+%OptimizeFunctionOnNextCall(bar);
+assertEquals("bared", bar());
+assertOptimized(bar);
diff --git a/deps/v8/test/mjsunit/compiler/opt-next-call.js b/deps/v8/test/mjsunit/compiler/opt-next-call.js
index 6366c7d72e..3d7e74f626 100644
--- a/deps/v8/test/mjsunit/compiler/opt-next-call.js
+++ b/deps/v8/test/mjsunit/compiler/opt-next-call.js
@@ -11,3 +11,12 @@ function foo() {
%OptimizeFunctionOnNextCall(foo);
assertEquals("fooed", foo());
assertOptimized(foo);
+
+function bar() {
+ return "bared";
+}
+
+assertEquals("bared", bar());
+%OptimizeFunctionOnNextCall(bar);
+assertEquals("bared", bar());
+assertOptimized(bar);
diff --git a/deps/v8/test/mjsunit/compiler/optimized-for-in.js b/deps/v8/test/mjsunit/compiler/optimized-for-in.js
index 9c756aafa7..f3ff6beb05 100644
--- a/deps/v8/test/mjsunit/compiler/optimized-for-in.js
+++ b/deps/v8/test/mjsunit/compiler/optimized-for-in.js
@@ -251,9 +251,7 @@ function osr_inner(t, limit) {
if (t.hasOwnProperty(x)) {
for (var i = 0; i < t[x].length; i++) {
r += t[x][i];
- if (i === limit) {
- %OptimizeFunctionOnNextCall(osr_inner, "osr");
- }
+ if (i === limit) %OptimizeOsr();
}
r += x;
}
@@ -267,9 +265,7 @@ function osr_outer(t, osr_after) {
for (var i = 0; i < t[x].length; i++) {
r += t[x][i];
}
- if (x === osr_after) {
- %OptimizeFunctionOnNextCall(osr_outer, "osr");
- }
+ if (x === osr_after) %OptimizeOsr();
r += x;
}
return r;
@@ -279,9 +275,7 @@ function osr_outer_and_deopt(t, osr_after) {
var r = 1;
for (var x in t) {
r += x;
- if (x == osr_after) {
- %OptimizeFunctionOnNextCall(osr_outer_and_deopt, "osr");
- }
+ if (x == osr_after) %OptimizeOsr();
}
return r;
}
diff --git a/deps/v8/test/mjsunit/compiler/osr-alignment.js b/deps/v8/test/mjsunit/compiler/osr-alignment.js
index 30d72d0614..085d6c4d68 100644
--- a/deps/v8/test/mjsunit/compiler/osr-alignment.js
+++ b/deps/v8/test/mjsunit/compiler/osr-alignment.js
@@ -25,37 +25,40 @@
// (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: --use-osr
+// Flags: --allow-natives-syntax --use-osr --turbo-osr
function f1() {
var sum = 0;
- for (var i = 0; i < 1000000; i++) {
+ for (var i = 0; i < 1000; i++) {
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
+ if (i == 18) %OptimizeOsr();
}
return sum;
}
function f2() {
var sum = 0;
- for (var i = 0; i < 1000000; i++) {
+ for (var i = 0; i < 1000; i++) {
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
+ if (i == 19) %OptimizeOsr();
}
return sum;
}
function f3() {
var sum = 0;
- for (var i = 0; i < 1000000; i++) {
+ for (var i = 0; i < 1000; i++) {
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
+ if (i == 20) %OptimizeOsr();
}
return sum;
}
@@ -63,21 +66,21 @@ function f3() {
function test1() {
var j = 11;
for (var i = 0; i < 2; i++) {
- assertEquals(500009500000, f1());
+ assertEquals(509500, f1());
}
}
function test2() {
for (var i = 0; i < 2; i++) {
var j = 11, k = 12;
- assertEquals(500009500000, f2());
+ assertEquals(509500, f2());
}
}
function test3() {
for (var i = 0; i < 2; i++) {
var j = 11, k = 13, m = 14;
- assertEquals(500009500000, f3());
+ assertEquals(509500, f3());
}
}
diff --git a/deps/v8/test/mjsunit/compiler/osr-backedges1.js b/deps/v8/test/mjsunit/compiler/osr-backedges1.js
new file mode 100644
index 0000000000..d415f4a107
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-backedges1.js
@@ -0,0 +1,31 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+function foo(a) {
+ var i = a | 0;
+ while (true) {
+ if (i == 0) { i = 1; continue; }
+ if (i == 1) { i = 2; continue; }
+ if (i == 2) { i = 3; continue; }
+ if (i == 3) { i = 4; continue; }
+ if (i == 4) { i = 5; continue; }
+ if (i == 5) { i = 6; continue; }
+ if (i == 6) { i = 7; continue; }
+ if (i == 7) { i = 8; continue; }
+ for (var j = 0; j < 10; j++) { if (i == 5) %OptimizeOsr(); }
+ break;
+ }
+ return j;
+}
+
+function test(func, tv, fv) {
+ assertEquals(tv, func(0));
+ assertEquals(tv, func(0));
+ assertEquals(fv, func(9));
+ assertEquals(fv, func(9));
+}
+
+test(foo, 10, 10);
diff --git a/deps/v8/test/mjsunit/compiler/osr-block-scope-func.js b/deps/v8/test/mjsunit/compiler/osr-block-scope-func.js
new file mode 100644
index 0000000000..df4076c411
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-block-scope-func.js
@@ -0,0 +1,27 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+"use strict";
+
+function foo() {
+ var result;
+ {
+ let sum = 0;
+ for (var i = 0; i < 100; i++) {
+ if (i == 50) %OptimizeOsr();
+ sum += i;
+ }
+ result = ret;
+ function ret() {
+ return sum;
+ }
+ }
+ return result;
+}
+
+assertEquals(4950, foo()());
+assertEquals(4950, foo()());
+assertEquals(4950, foo()());
diff --git a/deps/v8/test/mjsunit/compiler/osr-block-scope-id.js b/deps/v8/test/mjsunit/compiler/osr-block-scope-id.js
new file mode 100644
index 0000000000..923c72f422
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-block-scope-id.js
@@ -0,0 +1,40 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+"use strict";
+
+function foo() {
+ var result = new Array();
+ var out;
+ {
+ let sum = 0;
+ for (var i = 0; i < 10; i++) {
+ {
+ let x = i;
+ if (i == 5) %OptimizeOsr();
+ sum += i;
+ result.push(function() { return x; });
+ }
+ }
+ out = sum;
+ }
+ result.push(out);
+ return result;
+}
+
+
+function check() {
+ var r = foo();
+ assertEquals(45, r.pop());
+ for (var i = 9; i >= 0; i--) {
+ assertEquals(i, r.pop()());
+ }
+ assertEquals(0, r.length);
+}
+
+check();
+check();
+check();
diff --git a/deps/v8/test/mjsunit/compiler/osr-block-scope.js b/deps/v8/test/mjsunit/compiler/osr-block-scope.js
new file mode 100644
index 0000000000..0d78cdcb64
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-block-scope.js
@@ -0,0 +1,116 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+"use strict";
+
+function nest(body, name, depth) {
+ var header = "";
+ for (var i = 0; i < depth; i++) {
+ var x = "x" + (i + 1);
+ header += " for(var " + x + " = 0; " + x + " < 2; " + x + " = " + x + " + 1 | 0) {\n";
+ body = body + "}"
+ }
+
+ return body.replace(new RegExp("function " + name + "\\(\\) {"),
+ "function " + name + "_" + x + "() {\n" + header);
+}
+
+function test(expected, func, depth) {
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+
+ var orig = func.toString();
+ var name = func.name;
+ for (var depth = 1; depth < 4; depth++) {
+ var body = nest(orig, name, depth);
+ func = eval("(" + body + ")");
+
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+ }
+}
+
+function foo() {
+ var result;
+ {
+ let sum = 0;
+ for (var i = 0; i < 10; i++) {
+ %OptimizeOsr();
+ sum += i;
+ }
+ result = sum;
+ }
+ return result;
+}
+
+test(45, foo);
+
+function bar() {
+ let sum = 0;
+ for (var i = 0; i < 10; i++) {
+ %OptimizeOsr();
+ sum += i;
+ }
+ return sum;
+}
+
+test(45, bar);
+
+function bon() {
+ {
+ let sum = 0;
+ for (var i = 0; i < 10; i++) {
+ if (i == 5) %OptimizeOsr();
+ sum += i;
+ }
+ return sum;
+ }
+}
+
+test(45, bon);
+
+function row() {
+ var i = 0;
+ {
+ let sum = 0;
+ while (true) {
+ if (i == 8) return sum;
+ %OptimizeOsr();
+ sum = i;
+ i = i + 1 | 0;
+ }
+ }
+ return 11;
+}
+
+test(7, row);
+
+function nub() {
+ let i = 0;
+ while (i < 2) {
+ %OptimizeOsr();
+ i++;
+ }
+ return i;
+}
+
+test(2, nub);
+
+function kub() {
+ var result = 0;
+ let i = 0;
+ while (i < 2) {
+ let x = i;
+ %OptimizeOsr();
+ i++;
+ result = x;
+ }
+ return result;
+}
+
+test(1, kub);
diff --git a/deps/v8/test/mjsunit/compiler/osr-follow.js b/deps/v8/test/mjsunit/compiler/osr-follow.js
new file mode 100644
index 0000000000..b6a2e8e4be
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-follow.js
@@ -0,0 +1,61 @@
+// 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: --use-osr --turbo-osr
+
+function foo(a) {
+ var sum = 0;
+ var inc = a ? 100 : 200;
+ for (var i = 0; i < 100000; i++) {
+ sum += inc;
+ }
+ return sum + inc;
+}
+
+function bar(a) {
+ var sum = 0;
+ var inc = a ? 100 : 200;
+ var x = a ? 5 : 6;
+ var y = a ? 7 : 8;
+ for (var i = 0; i < 100000; i++) {
+ sum += inc;
+ }
+ return sum ? x : y;
+}
+
+function baz(a) {
+ var limit = a ? 100001 : 100002;
+ var r = 1;
+ var x = a ? 1 : 2;
+ var y = a ? 3 : 4;
+ for (var i = 0; i < limit; i++) {
+ r = r * -1;
+ }
+ return r > 0 ? x == y : x != y;
+}
+
+function qux(a) {
+ var limit = a ? 100001 : 100002;
+ var r = 1;
+ var x = a ? 1 : 2;
+ var y = a ? 3 : 4;
+ for (var i = 0; i < limit; i++) {
+ r = r * -1;
+ }
+ var w = r > 0 ? x : y;
+ var z = r > 0 ? y : x;
+ return w === z;
+}
+
+function test(func, tv, fv) {
+ assertEquals(tv, func(true));
+ assertEquals(fv, func(false));
+ assertEquals(tv, func(true));
+ assertEquals(fv, func(false));
+}
+
+test(foo, 10000100, 20000200);
+test(bar, 5, 6);
+test(baz, true, false);
+test(qux, false, false);
diff --git a/deps/v8/test/mjsunit/compiler/osr-for-let.js b/deps/v8/test/mjsunit/compiler/osr-for-let.js
new file mode 100644
index 0000000000..4b2fa3e532
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-for-let.js
@@ -0,0 +1,82 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+"use strict";
+
+function test(expected, func) {
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+}
+
+function bar() {
+ var result;
+ {
+ let sum = 0;
+ for (let i = 0; i < 90; i++) {
+ sum += i;
+ if (i == 45) %OptimizeOsr();
+ }
+ result = sum;
+ }
+ return result;
+}
+
+test(4005, bar);
+
+function baz() {
+ let sum = 0;
+ for (let i = 0; i < 2; i++) {
+ sum = 2;
+ %OptimizeOsr();
+ }
+ return sum;
+}
+
+test(2, baz);
+
+function qux() {
+ var result = 0;
+ for (let i = 0; i < 2; i++) {
+ result = i;
+ %OptimizeOsr();
+ }
+ return result;
+}
+
+test(1, qux);
+
+function nux() {
+ var result = 0;
+ for (let i = 0; i < 2; i++) {
+ {
+ let sum = i;
+ %OptimizeOsr();
+ result = sum;
+ }
+ }
+ return result;
+}
+
+test(1, nux);
+
+function blo() {
+ var result;
+ {
+ let sum = 0;
+ for (let i = 0; i < 90; i++) {
+ sum += i;
+ if (i == 45) %OptimizeOsr();
+ }
+ result = ret;
+ function ret() {
+ return sum;
+ }
+ }
+ return result;
+}
+
+test(4005, blo());
diff --git a/deps/v8/test/mjsunit/compiler/osr-forin.js b/deps/v8/test/mjsunit/compiler/osr-forin.js
new file mode 100644
index 0000000000..8d1678224c
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-forin.js
@@ -0,0 +1,26 @@
+// 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: --use-osr --turbo-osr
+
+function f(a) {
+ var sum = 0;
+ for (var j in a) {
+ var i = a[j];
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ }
+ return sum;
+}
+
+var a = new Array(10000);
+for (var i = 0; i < 10000; i++) {
+ a[i] = (i * 999) % 77;
+}
+
+for (var i = 0; i < 3; i++) {
+ assertEquals(480270, f(a));
+}
diff --git a/deps/v8/test/mjsunit/compiler/osr-forof.js b/deps/v8/test/mjsunit/compiler/osr-forof.js
new file mode 100644
index 0000000000..36bff09c58
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-forof.js
@@ -0,0 +1,35 @@
+// 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: --use-osr --turbo-osr
+
+function f(a) {
+ var sum = 0;
+ for (var i of a) {
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ }
+ return sum;
+}
+
+var a = new Array(10000);
+for (var i = 0; i < 10000; i++) {
+ a[i] = (i * 999) % 77;
+}
+
+for (var i = 0; i < 3; i++) {
+ assertEquals(480270, f(wrap(a)));
+}
+
+function wrap(array) {
+ var iterable = {};
+ var i = 0;
+ function next() {
+ return { done: i >= array.length, value: array[i++] };
+ };
+ iterable[Symbol.iterator] = function() { return { next:next }; };
+ return iterable;
+}
diff --git a/deps/v8/test/mjsunit/compiler/osr-function-id.js b/deps/v8/test/mjsunit/compiler/osr-function-id.js
new file mode 100644
index 0000000000..c506ae8282
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-function-id.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.
+
+// Flags: --use-osr --turbo-osr
+
+function id(f) { return f; }
+
+function foo() {
+ var sum = 0;
+ var r = id(foo);
+ for (var i = 0; i < 100000; i++) {
+ sum += i;
+ }
+ return foo == r;
+}
+
+assertEquals(true, foo());
+assertEquals(true, foo());
+assertEquals(true, foo());
+
+
+function bar() {
+ var sum = 0;
+ for (var i = 0; i < 90000; i++) {
+ sum += i;
+ }
+ return id(bar,sum);
+}
+
+assertEquals(bar, bar());
+assertEquals(bar, bar());
+assertEquals(bar, bar());
diff --git a/deps/v8/test/mjsunit/compiler/osr-function-id2.js b/deps/v8/test/mjsunit/compiler/osr-function-id2.js
new file mode 100644
index 0000000000..561c62e1bc
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-function-id2.js
@@ -0,0 +1,28 @@
+// 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: --use-osr --turbo-osr
+
+function id(f) { return f; }
+
+var x = (function foo() {
+ var sum = 0;
+ var r = id(foo);
+ for (var i = 0; i < 100000; i++) {
+ sum += i;
+ }
+ return foo == r;
+})();
+
+assertEquals(true, x);
+
+var x = (function bar() {
+ var sum = 0;
+ for (var i = 0; i < 90000; i++) {
+ sum += i;
+ }
+ return bar;
+})();
+
+assertEquals("function", typeof x);
diff --git a/deps/v8/test/mjsunit/compiler/osr-function.js b/deps/v8/test/mjsunit/compiler/osr-function.js
new file mode 100644
index 0000000000..06d137b62c
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-function.js
@@ -0,0 +1,31 @@
+// 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: --use-osr --turbo-osr
+
+function foo() {
+ var sum = 0;
+ for (var i = 0; i < 100000; i++) {
+ sum += i;
+ }
+ return function() { return sum; }
+}
+
+assertEquals(4999950000, foo()());
+assertEquals(4999950000, foo()());
+assertEquals(4999950000, foo()());
+
+function bar() {
+ var sum = 0;
+ var ret = 0;
+ for (var i = 0; i < 90000; i++) {
+ sum += i;
+ if (i == 0) ret = function() { return sum; }
+ }
+ return ret;
+}
+
+assertEquals(4049955000, bar()());
+assertEquals(4049955000, bar()());
+assertEquals(4049955000, bar()());
diff --git a/deps/v8/test/mjsunit/compiler/osr-manual1.js b/deps/v8/test/mjsunit/compiler/osr-manual1.js
new file mode 100644
index 0000000000..29a4948a65
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-manual1.js
@@ -0,0 +1,35 @@
+// 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-osr --turbo-osr
+
+var counter = 111;
+
+function gen(w) { // defeat compiler cache.
+ var num = counter++;
+ var Z = [ "", "", "", ];
+ Z[w] = "%OptimizeOsr()";
+ var src =
+ "function f" + num + "(a,b,c) {" +
+ " var x = 0;" +
+ " var y = 0;" +
+ " var z = 0;" +
+ " while (a > 0) { " + Z[0] + "; x += 19; a--; }" +
+ " while (b > 0) { " + Z[1] + "; y += 23; b--; }" +
+ " while (c > 0) { " + Z[2] + "; z += 29; c--; }" +
+ " return x + y + z;" +
+ "} f" + num;
+ return eval(src);
+}
+
+function check(x,a,b,c) {
+ for (var i = 0; i < 3; i++) {
+ var f = gen(i);
+ assertEquals(x, f(a, b, c));
+ }
+}
+
+check(213, 3,3,3);
+check(365, 4,5,6);
+check(6948, 99,98,97);
diff --git a/deps/v8/test/mjsunit/compiler/osr-manual2.js b/deps/v8/test/mjsunit/compiler/osr-manual2.js
new file mode 100644
index 0000000000..8aa5d69db3
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-manual2.js
@@ -0,0 +1,35 @@
+// 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-osr --turbo-osr
+
+var counter = 188;
+
+function gen(w) { // defeat compiler cache.
+ var num = counter++;
+ var Z = [ "", "", "", ];
+ Z[w] = "%OptimizeOsr()";
+ var src =
+ "function f" + num + "(a,b,c) {" +
+ " var x = 0;" +
+ " var y = 0;" +
+ " var z = 0;" +
+ " while (a > 0) { " + Z[0] + "; x += 19; a--; var j=2; while(j--); }" +
+ " while (b > 0) { " + Z[1] + "; y += 23; b--; var j=2; while(j--); }" +
+ " while (c > 0) { " + Z[2] + "; z += 29; c--; var j=2; while(j--); }" +
+ " return x + y + z;" +
+ "} f" + num;
+ return eval(src);
+}
+
+function check(x,a,b,c) {
+ for (var i = 0; i < 3; i++) {
+ var f = gen(i);
+ assertEquals(x, f(a, b, c));
+ }
+}
+
+check(213, 3,3,3);
+check(365, 4,5,6);
+check(6948, 99,98,97);
diff --git a/deps/v8/test/mjsunit/compiler/osr-maze1.js b/deps/v8/test/mjsunit/compiler/osr-maze1.js
new file mode 100644
index 0000000000..6e192c17b7
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-maze1.js
@@ -0,0 +1,51 @@
+// 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: --allow-natives-syntax --use-osr --turbo-deoptimization
+
+function bar(goal) {
+ var count = 0;
+ var sum = 11;
+ var i = 35;
+ while (i-- > 33) {
+ if (count++ == goal) %OptimizeOsr();
+ sum = sum + i;
+ }
+ while (i-- > 31) {
+ if (count++ == goal) %OptimizeOsr();
+ j = 9;
+ while (j-- > 7) {
+ if (count++ == goal) %OptimizeOsr();
+ sum = sum + j * 3;
+ }
+ while (j-- > 5) {
+ if (count++ == goal) %OptimizeOsr();
+ sum = sum + j * 5;
+ }
+ }
+ while (i-- > 29) {
+ if (count++ == goal) %OptimizeOsr();
+ while (j-- > 3) {
+ var k = 10;
+ if (count++ == goal) %OptimizeOsr();
+ while (k-- > 8) {
+ if (count++ == goal) %OptimizeOsr();
+ sum = sum + k * 11;
+ }
+ }
+ while (j-- > 1) {
+ if (count++ == goal) %OptimizeOsr();
+ while (k-- > 6) {
+ if (count++ == goal) %OptimizeOsr();
+ sum = sum + j * 13;
+ }
+ }
+ }
+ return sum;
+}
+
+for (var i = 0; i < 13; i++) {
+ %DeoptimizeFunction(bar);
+ assertEquals(348, bar(i));
+}
diff --git a/deps/v8/test/mjsunit/compiler/osr-maze2.js b/deps/v8/test/mjsunit/compiler/osr-maze2.js
new file mode 100644
index 0000000000..96838a4c34
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-maze2.js
@@ -0,0 +1,63 @@
+// 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: --allow-natives-syntax --use-osr --turbo-deoptimization
+
+function bar() {
+ var sum = 11;
+ var i = 35;
+ while (i-- > 31) {
+ LOOP1();
+ j = 9;
+ while (j-- > 7) {
+ LOOP2();
+ sum = sum + j * 5;
+ var k = 7;
+ while (k-- > 5) {
+ LOOP3();
+ sum = sum + j * 5;
+ }
+ }
+ }
+ while (i-- > 29) {
+ LOOP4();
+ while (j-- > 3) {
+ LOOP5();
+ var k = 10;
+ while (k-- > 8) {
+ LOOP6();
+ sum = sum + k * 11;
+ }
+ }
+ while (j-- > 1) {
+ LOOP7();
+ var k = 8;
+ while (k-- > 6) {
+ LOOP8();
+ var m = 9;
+ while (m-- > 6) {
+ LOOP9();
+ sum = sum + k * 13;
+ }
+ }
+ }
+ }
+ return sum;
+}
+
+function gen(i) {
+ var body = bar.toString();
+ body = body.replace(new RegExp("bar"), "bar" + i);
+ for (var j = 1; j < 10; j++) {
+ var r = new RegExp("LOOP" + j + "\\(\\);");
+ if (i == j) body = body.replace(r, "%OptimizeOsr();");
+ else body = body.replace(r, "");
+ }
+ return eval("(" + body + ")");
+}
+
+for (var i = 1; i < 10; i++) {
+ var f = gen(i);
+ assertEquals(1979, f());
+}
diff --git a/deps/v8/test/mjsunit/compiler/osr-multiple.js b/deps/v8/test/mjsunit/compiler/osr-multiple.js
new file mode 100644
index 0000000000..c318645d32
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-multiple.js
@@ -0,0 +1,44 @@
+// 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: --use-osr --turbo-osr
+
+function f1(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ return x + y + z;
+}
+
+function f2(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ return x + y + z;
+}
+
+
+function f3(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ return x + y + z;
+}
+
+function check(f,a,b,c) {
+ assertEquals(a * 19 + b * 23 + c * 29, f(a,b,c));
+}
+
+check(f1, 50000, 5, 6);
+check(f2, 4, 50000, 6);
+check(f3, 11, 12, 50000);
diff --git a/deps/v8/test/mjsunit/compiler/osr-multiple2.js b/deps/v8/test/mjsunit/compiler/osr-multiple2.js
new file mode 100644
index 0000000000..9a81bfb658
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-multiple2.js
@@ -0,0 +1,51 @@
+// 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: --use-osr
+// TODO(titzer): enable --turbo-osr when nested OSR works.
+
+function f1(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ for (var i = 0; i < 2; i++) {
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ }
+ return x + y + z;
+}
+
+function f2(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ for (var i = 0; i < 2; i++) {
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ }
+ return x + y + z;
+}
+
+
+function f3(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ for (var i = 0; i < 2; i++) {
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ }
+ return x + y + z;
+}
+
+function check(f,a,b,c) {
+ assertEquals(a * 19 + b * 23 + c * 29, f(a,b,c));
+}
+
+check(f1, 50000, 5, 6);
+check(f2, 4, 50000, 6);
+check(f3, 11, 12, 50000);
diff --git a/deps/v8/test/mjsunit/compiler/osr-multiple3.js b/deps/v8/test/mjsunit/compiler/osr-multiple3.js
new file mode 100644
index 0000000000..0fb1ac73a3
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-multiple3.js
@@ -0,0 +1,57 @@
+// 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: --use-osr
+// TODO(titzer): enable --turbo-osr when nested OSR works.
+
+function f1(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ for (var i = 0; i < 2; i++) {
+ for (var j = 0; j < 2; j++) {
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ }
+ }
+ return x + y + z;
+}
+
+function f2(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ for (var i = 0; i < 2; i++) {
+ for (var j = 0; j < 2; j++) {
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ }
+ }
+ return x + y + z;
+}
+
+
+function f3(a,b,c) {
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ for (var i = 0; i < 2; i++) {
+ for (var j = 0; j < 2; j++) {
+ while (a > 0) { x += 19; a--; }
+ while (b > 0) { y += 23; b--; }
+ while (c > 0) { z += 29; c--; }
+ }
+ }
+ return x + y + z;
+}
+
+function check(f,a,b,c) {
+ assertEquals(a * 19 + b * 23 + c * 29, f(a,b,c));
+}
+
+check(f1, 50000, 5, 6);
+check(f2, 4, 50000, 6);
+check(f3, 11, 12, 50000);
diff --git a/deps/v8/test/mjsunit/compiler/osr-nested2.js b/deps/v8/test/mjsunit/compiler/osr-nested2.js
new file mode 100644
index 0000000000..41bd9b247b
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-nested2.js
@@ -0,0 +1,24 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+function f() {
+ var sum = 0;
+ for (var i = 5; i < 6; i++) {
+ for (var j = 0; j < 1000; j++) {
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ if (i == 21) %OptimizeOsr();
+ }
+ }
+ return sum;
+}
+
+
+assertEquals(15000, f());
+assertEquals(15000, f());
+assertEquals(15000, f());
diff --git a/deps/v8/test/mjsunit/compiler/osr-nested2b.js b/deps/v8/test/mjsunit/compiler/osr-nested2b.js
new file mode 100644
index 0000000000..e64c10ccb4
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-nested2b.js
@@ -0,0 +1,25 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+function f() {
+ var sum = 0;
+ for (var i = 5; i < 6; i++) {
+ for (var j = 0; j < 1000; j++) {
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ if (i == 25) %OptimizeOsr();
+ }
+ if (true) break;
+ }
+ return sum;
+}
+
+
+assertEquals(15000, f());
+assertEquals(15000, f());
+assertEquals(15000, f());
diff --git a/deps/v8/test/mjsunit/compiler/osr-nested3.js b/deps/v8/test/mjsunit/compiler/osr-nested3.js
new file mode 100644
index 0000000000..f5d09ba166
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-nested3.js
@@ -0,0 +1,26 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+function f() {
+ var sum = 0;
+ for (var m = 99; m < 100; m++) {
+ for (var i = 5; i < 6; i++) {
+ for (var j = 0; j < 1000; j++) {
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ if (i == 19) %OptimizeOsr();
+ }
+ }
+ }
+ return sum;
+}
+
+
+assertEquals(15000, f());
+assertEquals(15000, f());
+assertEquals(15000, f());
diff --git a/deps/v8/test/mjsunit/compiler/osr-nested3b.js b/deps/v8/test/mjsunit/compiler/osr-nested3b.js
new file mode 100644
index 0000000000..32ac2a7058
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-nested3b.js
@@ -0,0 +1,28 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+function f() {
+ var sum = 0;
+ for (var m = 99; m < 100; m++) {
+ for (var i = 5; i < 6; i++) {
+ for (var j = 0; j < 1000; j++) {
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ if (i == 25) %OptimizeOsr();
+ }
+ if (true) break;
+ }
+ if (true) break;
+ }
+ return sum;
+}
+
+
+assertEquals(15000, f());
+assertEquals(15000, f());
+assertEquals(15000, f());
diff --git a/deps/v8/test/mjsunit/compiler/osr-regex-id.js b/deps/v8/test/mjsunit/compiler/osr-regex-id.js
new file mode 100644
index 0000000000..7831b14840
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-regex-id.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.
+
+// Flags: --allow-natives-syntax --use-osr --turbo-osr
+
+function id(f) { return f; }
+
+function foo(a) {
+ var r = /\0/;
+ for (var i = 0; i < 10; i++) {
+ if (a) %OptimizeOsr();
+ }
+ return r;
+}
+
+function bar(a) {
+ for (var i = 0; i < 10; i++) {
+ if (a) %OptimizeOsr();
+ var r = /\0/;
+ }
+ return r;
+}
+
+function baz(a) {
+ for (var i = 0; i < 10; i++) {
+ if (a) %OptimizeOsr();
+ }
+ return /\0/;
+}
+
+function qux(a) {
+ for (var i = 0; i < 10; i++) {
+ if (i > 5 && a) {
+ %OptimizeOsr();
+ } else {
+ var r = /\0/;
+ }
+ }
+ return r;
+}
+
+function test(f) {
+ // Test the reference equality of regex's created in OSR'd function.
+ var x = f(false);
+ assertEquals(x, f(true));
+ assertEquals(x, f(true));
+ assertEquals(x, f(true));
+}
+
+test(foo);
+test(bar);
+test(baz);
+test(qux);
diff --git a/deps/v8/test/mjsunit/compiler/osr-sar.js b/deps/v8/test/mjsunit/compiler/osr-sar.js
index fd68b98a45..cc04adca8a 100644
--- a/deps/v8/test/mjsunit/compiler/osr-sar.js
+++ b/deps/v8/test/mjsunit/compiler/osr-sar.js
@@ -25,7 +25,7 @@
// (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
+// Flags: --allow-natives-syntax --use-osr --turbo-osr
function test() {
// Loop to force OSR.
diff --git a/deps/v8/test/mjsunit/compiler/osr-simple.js b/deps/v8/test/mjsunit/compiler/osr-simple.js
index 8ec1b2b936..ddbc5f8867 100644
--- a/deps/v8/test/mjsunit/compiler/osr-simple.js
+++ b/deps/v8/test/mjsunit/compiler/osr-simple.js
@@ -1,44 +1,22 @@
// Copyright 2010 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.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
-// Flags: --use-osr
+// Flags: --allow-natives-syntax --use-osr
function f() {
var sum = 0;
- for (var i = 0; i < 1000000; i++) {
+ for (var i = 0; i < 1000; i++) {
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
+ if (i == 11) %OptimizeOsr();
}
return sum;
}
for (var i = 0; i < 2; i++) {
- assertEquals(500009500000, f());
+ assertEquals(509500, f());
}
diff --git a/deps/v8/test/mjsunit/compiler/osr-top1.js b/deps/v8/test/mjsunit/compiler/osr-top1.js
new file mode 100644
index 0000000000..742b71d86e
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-top1.js
@@ -0,0 +1,16 @@
+// 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: --use-osr --allow-natives-syntax
+
+var sum = 0;
+for (var i = 0; i < 10000; i++) {
+ if (i == 100) %OptimizeOsr();
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+}
+
+assertEquals(50095000, sum);
diff --git a/deps/v8/test/mjsunit/compiler/osr-top2.js b/deps/v8/test/mjsunit/compiler/osr-top2.js
new file mode 100644
index 0000000000..a15aa15d04
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-top2.js
@@ -0,0 +1,19 @@
+// 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: --use-osr --allow-natives-syntax
+
+for (var j = 0; j < 3; j++) {
+ var sum = 0;
+ for (var i = 0; i < 1000; i++) {
+ if (i == 100) %OptimizeOsr();
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ }
+ assertEquals(509500, sum);
+}
+
+assertEquals(509500, sum);
diff --git a/deps/v8/test/mjsunit/compiler/osr-top3.js b/deps/v8/test/mjsunit/compiler/osr-top3.js
new file mode 100644
index 0000000000..4c4a364be0
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-top3.js
@@ -0,0 +1,22 @@
+// 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: --use-osr --allow-natives-syntax
+
+for (var k = 0; k < 2; k++) {
+ for (var j = 0; j < 3; j++) {
+ var sum = 0;
+ for (var i = 0; i < 1000; i++) {
+ if (i == 100) %OptimizeOsr();
+ var x = i + 2;
+ var y = x + 5;
+ var z = y + 3;
+ sum += z;
+ }
+ assertEquals(509500, sum);
+ }
+ assertEquals(509500, sum);
+}
+
+assertEquals(509500, sum);
diff --git a/deps/v8/test/mjsunit/compiler/osr-warm.js b/deps/v8/test/mjsunit/compiler/osr-warm.js
index 73e1fd5cd2..7c30c07f20 100644
--- a/deps/v8/test/mjsunit/compiler/osr-warm.js
+++ b/deps/v8/test/mjsunit/compiler/osr-warm.js
@@ -25,7 +25,7 @@
// (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: --use-osr
+// Flags: --use-osr --turbo-osr
function f1(x) {
while (x > 0) {
diff --git a/deps/v8/test/mjsunit/compiler/osr-while-let.js b/deps/v8/test/mjsunit/compiler/osr-while-let.js
new file mode 100644
index 0000000000..c19cf6cb24
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/osr-while-let.js
@@ -0,0 +1,58 @@
+// 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: --allow-natives-syntax --use-osr --turbo-osr
+
+"use strict";
+
+function test(expected, func) {
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+ assertEquals(expected, func());
+}
+
+function foo() {
+ var result = 0;
+ {
+ let x = 0;
+ var temp_x = x;
+ var first = 1;
+ outer: while (true) {
+ let x = temp_x;
+ if (first == 1) first = 0;
+ else x = x + 1 | 0;
+ var flag = 1;
+ for (; flag == 1; (flag = 0, temp_x = x)) {
+ if (x < 2) {
+ result = x; %OptimizeOsr();
+ } else {
+ break outer;
+ }
+ }
+ if (flag == 1) break;
+ }
+ }
+ return result;
+}
+
+test(1, foo);
+
+
+function smo() {
+ var result = 0;
+ {
+ let x = 11;
+ outer: while (true) {
+ let y = x;
+ for (var i = 0; i < 5; i++) {
+ %OptimizeOsr();
+ if (i) break outer;
+ else result = y;
+ }
+ }
+ }
+ return result;
+}
+
+test(11, smo);
diff --git a/deps/v8/test/mjsunit/compiler/regress-3812.js b/deps/v8/test/mjsunit/compiler/regress-3812.js
new file mode 100644
index 0000000000..cfc8febc9a
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-3812.js
@@ -0,0 +1,19 @@
+// 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 stdlib = this;
+var buffer = new ArrayBuffer(64 * 1024);
+var foreign = {}
+
+var foo = (function Module(stdlib, foreign, heap) {
+ "use asm";
+ function foo(i) {
+ var x = i ? (i&1) : true;
+ if (x) return x;
+ return false;
+ }
+ return {foo:foo};
+})(stdlib, foreign, buffer).foo;
+
+assertEquals(1, foo(1));
diff --git a/deps/v8/test/mjsunit/compiler/regress-416359.js b/deps/v8/test/mjsunit/compiler/regress-416359.js
new file mode 100644
index 0000000000..18cdc5e728
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-416359.js
@@ -0,0 +1,10 @@
+// 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 f() {
+ for (x in {a:0});
+}
+
+assertThrows(f);
diff --git a/deps/v8/test/mjsunit/compiler/regress-445907.js b/deps/v8/test/mjsunit/compiler/regress-445907.js
new file mode 100644
index 0000000000..c820753eec
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-445907.js
@@ -0,0 +1,14 @@
+// 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: --turbo-deoptimization
+
+v = [];
+v.length = (1 << 30);
+
+function f() {
+ v++;
+}
+
+assertThrows(f);
diff --git a/deps/v8/test/mjsunit/compiler/regress-446647.js b/deps/v8/test/mjsunit/compiler/regress-446647.js
new file mode 100644
index 0000000000..77757abd66
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-446647.js
@@ -0,0 +1,11 @@
+// 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: --always-opt --turbo-filter=* --turbo-deoptimization --allow-natives-syntax
+
+function f(a,b) {
+ a%b
+};
+
+f({ toString : function() { %DeoptimizeFunction(f); }});
diff --git a/deps/v8/test/mjsunit/compiler/regress-447567.js b/deps/v8/test/mjsunit/compiler/regress-447567.js
new file mode 100644
index 0000000000..b6dc653709
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-447567.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: --turbo-deoptimization
+
+assertThrows(function() {
+ [0].every(function(){ Object.seal((new Int8Array())); });
+})
+
+assertThrows(function() {
+ "use strict";
+ const v = 42;
+ v += 1;
+});
diff --git a/deps/v8/test/mjsunit/compiler/regress-451012.js b/deps/v8/test/mjsunit/compiler/regress-451012.js
new file mode 100644
index 0000000000..bffc8bc5bd
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-451012.js
@@ -0,0 +1,12 @@
+// 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 f() {
+ for (let v; v; ) {
+ let x;
+ }
+}
+
+f();
diff --git a/deps/v8/test/mjsunit/compiler/regress-452427.js b/deps/v8/test/mjsunit/compiler/regress-452427.js
new file mode 100644
index 0000000000..f798b9cc79
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-452427.js
@@ -0,0 +1,18 @@
+// 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 stdlib = {};
+var foreign = {};
+var heap = new ArrayBuffer(64 * 1024);
+
+var rol = (function Module(stdlib, foreign, heap) {
+ "use asm";
+ function rol() {
+ y = "a" > false;
+ return y + (1 - y);
+ }
+ return { rol: rol };
+})(stdlib, foreign, heap).rol;
+
+assertEquals(1, rol());
diff --git a/deps/v8/test/mjsunit/compiler/regress-to-number-binop-deopt.js b/deps/v8/test/mjsunit/compiler/regress-to-number-binop-deopt.js
new file mode 100644
index 0000000000..f6b77d9082
--- /dev/null
+++ b/deps/v8/test/mjsunit/compiler/regress-to-number-binop-deopt.js
@@ -0,0 +1,25 @@
+// 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: --allow-natives-syntax
+
+function deopt(f) {
+ return { valueOf : function() { %DeoptimizeFunction(f); return 1.1; } };
+}
+
+function or_zero(o) {
+ return o|0;
+}
+
+function multiply_one(o) {
+ return +o;
+}
+
+function multiply_one_symbol() {
+ return +Symbol();
+}
+
+assertThrows(multiply_one_symbol, TypeError);
+assertEquals(1, or_zero(deopt(or_zero)));
+assertEquals(1.1, multiply_one(deopt(multiply_one)));
diff --git a/deps/v8/test/mjsunit/count-based-osr.js b/deps/v8/test/mjsunit/count-based-osr.js
index f06013083f..2df0b644f6 100644
--- a/deps/v8/test/mjsunit/count-based-osr.js
+++ b/deps/v8/test/mjsunit/count-based-osr.js
@@ -31,9 +31,8 @@
function osr_this() {
var a = 1;
- // Trigger OSR. First check if optimization is disabled.
- if (%GetOptimizationStatus(osr_this) == 4) return 1;
- while (%GetOptimizationCount(osr_this) == 0) {}
+ while (%GetOptimizationCount(osr_this) == 2) ;
return a;
}
assertEquals(1, osr_this());
+assertEquals(1, osr_this());
diff --git a/deps/v8/test/mjsunit/d8-os.js b/deps/v8/test/mjsunit/d8-os.js
index f6b98396e5..29d31032e7 100644
--- a/deps/v8/test/mjsunit/d8-os.js
+++ b/deps/v8/test/mjsunit/d8-os.js
@@ -135,7 +135,7 @@ if (this.os && os.system) {
assertThrows("os.system('sleep', ['2000'], -1, 20);", "sleep 2");
// Check that -1 means no timeout.
- os.system('sleep', ['0.1'], -1, -1);
+ os.system('sleep', ['1'], -1, -1);
}
diff --git a/deps/v8/test/mjsunit/debug-script.js b/deps/v8/test/mjsunit/debug-script.js
index 07f0e3c459..af1eb454d6 100644
--- a/deps/v8/test/mjsunit/debug-script.js
+++ b/deps/v8/test/mjsunit/debug-script.js
@@ -96,9 +96,9 @@ if (extension_gc_script) {
}
// Test a normal script.
-var mjsunit_js_script = Debug.findScript(/mjsunit.js/);
-assertTrue(/mjsunit.js/.test(mjsunit_js_script.name));
-assertEquals(Debug.ScriptType.Normal, mjsunit_js_script.type);
+var debug_script = Debug.findScript(/debug-script.js/);
+assertTrue(/debug-script.js/.test(debug_script.name));
+assertEquals(Debug.ScriptType.Normal, debug_script.type);
// Check a nonexistent script.
var dummy_script = Debug.findScript('dummy.js');
diff --git a/deps/v8/test/mjsunit/es6/array-tostring.js b/deps/v8/test/mjsunit/es6/array-tostring.js
new file mode 100644
index 0000000000..8a9198ca16
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/array-tostring.js
@@ -0,0 +1,157 @@
+// 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-tostring
+
+var global = this;
+
+var funs = {
+ Object: [ Object ],
+ Function: [ Function ],
+ String: [ String ],
+ Boolean: [ Boolean ],
+ Number: [ Number ],
+ Date: [ Date ],
+ RegExp: [ RegExp ],
+ Error: [ Error, TypeError, RangeError, SyntaxError, ReferenceError,
+ EvalError, URIError ]
+}
+for (f in funs) {
+ for (i in funs[f]) {
+ assertEquals("[object " + f + "]",
+ Array.prototype.toString.call(new funs[f][i]),
+ funs[f][i]);
+ assertEquals("[object Function]",
+ Array.prototype.toString.call(funs[f][i]),
+ funs[f][i]);
+ }
+}
+
+
+function testToStringTag(className) {
+ // Using builtin toStringTags
+ var obj = {};
+ obj[Symbol.toStringTag] = className;
+ assertEquals("[object " + className + "]",
+ Array.prototype.toString.call(obj));
+
+ // Getter throws
+ obj = {};
+ Object.defineProperty(obj, Symbol.toStringTag, {
+ get: function() { throw className; }
+ });
+ assertThrows(function() {
+ Array.prototype.toString.call(obj);
+ }, className);
+
+ // Getter does not throw
+ obj = {};
+ Object.defineProperty(obj, Symbol.toStringTag, {
+ get: function() { return className; }
+ });
+ assertEquals("[object " + className + "]",
+ Array.prototype.toString.call(obj));
+
+ // Custom, non-builtin toStringTags
+ obj = {};
+ obj[Symbol.toStringTag] = "X" + className;
+ assertEquals("[object X" + className + "]",
+ Array.prototype.toString.call(obj));
+
+ // With getter
+ obj = {};
+ Object.defineProperty(obj, Symbol.toStringTag, {
+ get: function() { return "X" + className; }
+ });
+ assertEquals("[object X" + className + "]",
+ Array.prototype.toString.call(obj));
+
+ // Undefined toStringTag should return [object className]
+ var obj = className === "Arguments" ?
+ (function() { return arguments; })() : new global[className];
+ obj[Symbol.toStringTag] = undefined;
+ assertEquals("[object " + className + "]",
+ Array.prototype.toString.call(obj));
+
+ // With getter
+ var obj = className === "Arguments" ?
+ (function() { return arguments; })() : new global[className];
+ Object.defineProperty(obj, Symbol.toStringTag, {
+ get: function() { return undefined; }
+ });
+ assertEquals("[object " + className + "]",
+ Array.prototype.toString.call(obj));
+}
+
+
+[
+ "Arguments",
+ "Boolean",
+ "Date",
+ "Error",
+ "Function",
+ "Number",
+ "RegExp",
+ "String"
+].forEach(testToStringTag);
+
+
+function testToStringTagNonString(value) {
+ var obj = {};
+ obj[Symbol.toStringTag] = value;
+ assertEquals("[object Object]", Array.prototype.toString.call(obj));
+
+ // With getter
+ obj = {};
+ Object.defineProperty(obj, Symbol.toStringTag, {
+ get: function() { return value; }
+ });
+ assertEquals("[object Object]", Array.prototype.toString.call(obj));
+}
+
+
+[
+ null,
+ function() {},
+ [],
+ {},
+ /regexp/,
+ 42,
+ Symbol("sym"),
+ new Date(),
+ (function() { return arguments; })(),
+ true,
+ new Error("oops"),
+ new String("str")
+].forEach(testToStringTagNonString);
+
+
+function testArrayToStringPropertyDesc() {
+ var desc = Object.getOwnPropertyDescriptor(Object.prototype, "toString");
+ assertTrue(desc.writable);
+ assertFalse(desc.enumerable);
+ assertTrue(desc.configurable);
+}
+testArrayToStringPropertyDesc();
+
+
+function testArrayToStringOwnNonStringValue() {
+ var obj = Object.defineProperty({}, Symbol.toStringTag, { value: 1 });
+ assertEquals("[object Object]", ([]).toString.call(obj));
+}
+testArrayToStringOwnNonStringValue();
+
+
+function testArrayToStringBasic() {
+ assertEquals("1,2,3", [1,2,3].toString());
+ assertEquals(",,3", [,,3].toString());
+}
+testArrayToStringBasic();
+
+
+function testArrayToStringObjectWithCallableJoin() {
+ var obj = { join: function() { return "CallableJoin"; } };
+ assertEquals("CallableJoin", Array.prototype.toString.call(obj));
+}
+testArrayToStringObjectWithCallableJoin();
diff --git a/deps/v8/test/mjsunit/es6/iteration-syntax.js b/deps/v8/test/mjsunit/es6/iteration-syntax.js
index 356a97898a..4be94c5db4 100644
--- a/deps/v8/test/mjsunit/es6/iteration-syntax.js
+++ b/deps/v8/test/mjsunit/es6/iteration-syntax.js
@@ -25,7 +25,7 @@
// (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-scoping --use-strict
+// Flags: --harmony-scoping
// Test for-of syntax.
@@ -35,28 +35,38 @@ function f() { for (x of y) { } }
function f() { for (var x of y) { } }
function f() { for (let x of y) { } }
-assertThrows("function f() { for (x of) { } }", SyntaxError);
-assertThrows("function f() { for (x of y z) { } }", SyntaxError);
-assertThrows("function f() { for (x of y;) { } }", SyntaxError);
+function StrictSyntaxError(s) {
+ try {
+ eval(s);
+ } catch (e) {
+ assertInstanceof(e, SyntaxError);
+ return;
+ }
+ throw "did not throw";
+}
-assertThrows("function f() { for (var x of) { } }", SyntaxError);
-assertThrows("function f() { for (var x of y z) { } }", SyntaxError);
-assertThrows("function f() { for (var x of y;) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (x of) { } }");
+StrictSyntaxError("function f() { for (x of y z) { } }");
+StrictSyntaxError("function f() { for (x of y;) { } }");
-assertThrows("function f() { for (let x of) { } }", SyntaxError);
-assertThrows("function f() { for (let x of y z) { } }", SyntaxError);
-assertThrows("function f() { for (let x of y;) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (var x of) { } }");
+StrictSyntaxError("function f() { for (var x of y z) { } }");
+StrictSyntaxError("function f() { for (var x of y;) { } }");
-assertThrows("function f() { for (of y) { } }", SyntaxError);
-assertThrows("function f() { for (of of) { } }", SyntaxError);
-assertThrows("function f() { for (var of y) { } }", SyntaxError);
-assertThrows("function f() { for (var of of) { } }", SyntaxError);
-assertThrows("function f() { for (let of y) { } }", SyntaxError);
-assertThrows("function f() { for (let of of) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (let x of) { } }");
+StrictSyntaxError("function f() { for (let x of y z) { } }");
+StrictSyntaxError("function f() { for (let x of y;) { } }");
-assertThrows("function f() { for (x = 3 of y) { } }", SyntaxError);
-assertThrows("function f() { for (var x = 3 of y) { } }", SyntaxError);
-assertThrows("function f() { for (let x = 3 of y) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (of y) { } }");
+StrictSyntaxError("function f() { for (of of) { } }");
+StrictSyntaxError("function f() { for (var of y) { } }");
+StrictSyntaxError("function f() { for (var of of) { } }");
+StrictSyntaxError("function f() { for (let of y) { } }");
+StrictSyntaxError("function f() { for (let of of) { } }");
+
+StrictSyntaxError("function f() { for (x = 3 of y) { } }");
+StrictSyntaxError("function f() { for (var x = 3 of y) { } }");
+StrictSyntaxError("function f() { for (let x = 3 of y) { } }");
// Alack, this appears to be valid.
diff --git a/deps/v8/test/mjsunit/es6/object-tostring.js b/deps/v8/test/mjsunit/es6/object-tostring.js
index 26dff14b9d..c73a7686cd 100644
--- a/deps/v8/test/mjsunit/es6/object-tostring.js
+++ b/deps/v8/test/mjsunit/es6/object-tostring.js
@@ -33,7 +33,7 @@ function testToStringTag(className) {
// Using builtin toStringTags
var obj = {};
obj[Symbol.toStringTag] = className;
- assertEquals("[object ~" + className + "]",
+ assertEquals("[object " + className + "]",
Object.prototype.toString.call(obj));
// Getter throws
@@ -50,7 +50,7 @@ function testToStringTag(className) {
Object.defineProperty(obj, Symbol.toStringTag, {
get: function() { return className; }
});
- assertEquals("[object ~" + className + "]",
+ assertEquals("[object " + className + "]",
Object.prototype.toString.call(obj));
// Custom, non-builtin toStringTags
@@ -99,14 +99,14 @@ function testToStringTag(className) {
function testToStringTagNonString(value) {
var obj = {};
obj[Symbol.toStringTag] = value;
- assertEquals("[object ???]", Object.prototype.toString.call(obj));
+ assertEquals("[object Object]", Object.prototype.toString.call(obj));
// With getter
obj = {};
Object.defineProperty(obj, Symbol.toStringTag, {
get: function() { return value; }
});
- assertEquals("[object ???]", Object.prototype.toString.call(obj));
+ assertEquals("[object Object]", Object.prototype.toString.call(obj));
}
[
@@ -131,3 +131,9 @@ function testObjectToStringPropertyDesc() {
assertTrue(desc.configurable);
}
testObjectToStringPropertyDesc();
+
+function testObjectToStringOwnNonStringValue() {
+ var obj = Object.defineProperty({}, Symbol.toStringTag, { value: 1 });
+ assertEquals("[object Object]", ({}).toString.call(obj));
+}
+testObjectToStringOwnNonStringValue();
diff --git a/deps/v8/test/mjsunit/harmony/array-concat.js b/deps/v8/test/mjsunit/harmony/array-concat.js
index 286aefd29a..c1ff92c8c3 100644
--- a/deps/v8/test/mjsunit/harmony/array-concat.js
+++ b/deps/v8/test/mjsunit/harmony/array-concat.js
@@ -245,7 +245,7 @@ function testConcatTypedArray(type, elems, modulo) {
}
(function testConcatSmallTypedArray() {
- var max = [2^8, 2^16, 2^32, false, false];
+ var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false];
[
Uint8Array,
Uint16Array,
@@ -259,7 +259,7 @@ function testConcatTypedArray(type, elems, modulo) {
(function testConcatLargeTypedArray() {
- var max = [2^8, 2^16, 2^32, false, false];
+ var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false];
[
Uint8Array,
Uint16Array,
diff --git a/deps/v8/test/mjsunit/harmony/array-from.js b/deps/v8/test/mjsunit/harmony/array-from.js
index e7c9fef7d5..c294786c46 100644
--- a/deps/v8/test/mjsunit/harmony/array-from.js
+++ b/deps/v8/test/mjsunit/harmony/array-from.js
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-arrays --harmony-generators
+// Flags: --harmony-arrays
(function() {
assertEquals(1, Array.from.length);
@@ -91,21 +91,48 @@ function testArrayFrom(thisArg, constructor) {
return x.toUpperCase();
}), ['T', 'E', 'S', 'T'], constructor);
- this.thisArg = thisArg;
- assertThrows('Array.from.call(thisArg, null)', TypeError);
- assertThrows('Array.from.call(thisArg, undefined)', TypeError);
- assertThrows('Array.from.call(thisArg, [], null)', TypeError);
- assertThrows('Array.from.call(thisArg, [], "noncallable")', TypeError);
+ assertThrows(function() { Array.from.call(thisArg, null); }, TypeError);
+ assertThrows(function() { Array.from.call(thisArg, undefined); }, TypeError);
+ assertThrows(function() { Array.from.call(thisArg, [], null); }, TypeError);
+ assertThrows(function() { Array.from.call(thisArg, [], "noncallable"); },
+ TypeError);
- this.nullIterator = {};
+ var nullIterator = {};
nullIterator[Symbol.iterator] = null;
- assertThrows('Array.from.call(thisArg, nullIterator)', TypeError);
+ assertArrayLikeEquals(Array.from.call(thisArg, nullIterator), [],
+ constructor);
- this.nonObjIterator = {};
+ var nonObjIterator = {};
nonObjIterator[Symbol.iterator] = function() { return "nonObject"; };
- assertThrows('Array.from.call(thisArg, nonObjIterator)', TypeError);
-
- assertThrows('Array.from.call(thisArg, [], null)', TypeError);
+ assertThrows(function() { Array.from.call(thisArg, nonObjIterator); },
+ TypeError);
+
+ assertThrows(function() { Array.from.call(thisArg, [], null); }, TypeError);
+
+ // Ensure iterator is only accessed once, and only invoked once
+ var called = false;
+ var arr = [1, 2, 3];
+ var obj = {};
+
+ // Test order --- only get iterator method once
+ function testIterator() {
+ assertFalse(called, "@@iterator should be called only once");
+ called = true;
+ assertEquals(obj, this);
+ return arr[Symbol.iterator]();
+ }
+ var getCalled = false;
+ Object.defineProperty(obj, Symbol.iterator, {
+ get: function() {
+ assertFalse(getCalled, "@@iterator should be accessed only once");
+ getCalled = true;
+ return testIterator;
+ },
+ set: function() {
+ assertUnreachable("@@iterator should not be set");
+ }
+ });
+ assertArrayLikeEquals(Array.from.call(thisArg, obj), [1, 2, 3], constructor);
}
function Other() {}
@@ -118,6 +145,7 @@ testArrayFrom({}, Array);
testArrayFrom(Object, Object);
testArrayFrom(Other, Other);
testArrayFrom(Math.cos, Array);
-testArrayFrom(boundFn, Array);
+testArrayFrom(Math.cos.bind(Math), Array);
+testArrayFrom(boundFn, boundFn);
})();
diff --git a/deps/v8/test/mjsunit/harmony/array-of.js b/deps/v8/test/mjsunit/harmony/array-of.js
index c0a8ed183e..adf7cb547c 100644
--- a/deps/v8/test/mjsunit/harmony/array-of.js
+++ b/deps/v8/test/mjsunit/harmony/array-of.js
@@ -159,6 +159,26 @@ assertEquals(Array.of.length, 0);
assertThrows(function() { new Array.of() }, TypeError); // not a constructor
// When the this-value passed in is not a constructor, the result is an array.
-[undefined, null, false, "cow"].forEach(function(val) {
- assertEquals(Array.isArray(Array.of(val)), true);
+[
+ undefined,
+ null,
+ false,
+ "cow",
+ NaN,
+ 67,
+ Infinity,
+ -Infinity,
+ Math.cos, // builtin functions with no [[Construct]] slot
+ Math.cos.bind(Math) // bound builtin functions with no [[Construct]] slot
+].forEach(function(val) {
+ assertEquals(Array.isArray(Array.of.call(val, val)), true);
});
+
+
+(function testBoundConstructor() {
+ var boundFn = (function() {}).bind(null);
+ var instance = Array.of.call(boundFn, 1, 2, 3);
+ assertEquals(instance.length, 3);
+ assertEquals(instance instanceof boundFn, true);
+ assertEquals(Array.isArray(instance), false);
+})();
diff --git a/deps/v8/test/mjsunit/harmony/class-computed-property-names-super.js b/deps/v8/test/mjsunit/harmony/class-computed-property-names-super.js
new file mode 100644
index 0000000000..5a5db67d48
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/class-computed-property-names-super.js
@@ -0,0 +1,76 @@
+// 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-computed-property-names --harmony-sloppy
+// Flags: --harmony-classes --allow-natives-syntax
+
+
+function ID(x) {
+ return x;
+}
+
+
+(function TestComputedMethodSuper() {
+ class Base {
+ m() {
+ return ' base m';
+ }
+ }
+ class Derived extends Base {
+ ['a']() { return 'a' + super.m(); }
+ [ID('b')]() { return 'b' + super.m(); }
+ [0]() { return '0' + super.m(); }
+ [ID(1)]() { return '1' + super.m(); }
+ }
+
+ assertSame(Derived.prototype, Derived.prototype.a[%HomeObjectSymbol()]);
+
+ assertEquals('a base m', new Derived().a());
+ assertEquals('b base m', new Derived().b());
+ assertEquals('0 base m', new Derived()[0]());
+ assertEquals('1 base m', new Derived()[1]());
+})();
+
+
+(function TestComputedGetterSuper() {
+ class Base {
+ m() {
+ return ' base m';
+ }
+ }
+ class Derived extends Base {
+ get ['a']() { return 'a' + super.m(); }
+ get [ID('b')]() { return 'b' + super.m(); }
+ get [0]() { return '0' + super.m(); }
+ get [ID(1)]() { return '1' + super.m(); }
+ }
+ assertEquals('a base m', new Derived().a);
+ assertEquals('b base m', new Derived().b);
+ assertEquals('0 base m', new Derived()[0]);
+ assertEquals('1 base m', new Derived()[1]);
+})();
+
+
+(function TestComputedSetterSuper() {
+ var value;
+ class Base {
+ m(name, v) {
+ value = name + ' ' + v;
+ }
+ }
+ class Derived extends Base {
+ set ['a'](v) { super.m('a', v); }
+ set [ID('b')](v) { super.m('b', v); }
+ set [0](v) { super.m('0', v); }
+ set [ID(1)](v) { super.m('1', v); }
+ }
+ new Derived().a = 2;
+ assertEquals('a 2', value);
+ new Derived().b = 3;
+ assertEquals('b 3', value);
+ new Derived()[0] = 4;
+ assertEquals('0 4', value);
+ new Derived()[1] = 5;
+ assertEquals('1 5', value);
+})();
diff --git a/deps/v8/test/mjsunit/harmony/class-property-name-eval-arguments.js b/deps/v8/test/mjsunit/harmony/class-property-name-eval-arguments.js
new file mode 100644
index 0000000000..cc53030920
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/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-classes --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/harmony/classes-experimental.js b/deps/v8/test/mjsunit/harmony/classes-experimental.js
new file mode 100644
index 0000000000..e7ebbda735
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/classes-experimental.js
@@ -0,0 +1,339 @@
+// 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-classes
+
+'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/harmony/classes-lazy-parsing.js b/deps/v8/test/mjsunit/harmony/classes-lazy-parsing.js
new file mode 100644
index 0000000000..2c0301957a
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/classes-lazy-parsing.js
@@ -0,0 +1,21 @@
+// 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-classes --min-preparse-length=0
+
+'use strict';
+
+class Base {
+ m() {
+ return 42;
+ }
+}
+
+class Derived extends Base {
+ m() {
+ return super.m();
+ }
+}
+
+assertEquals(42, new Derived().m());
diff --git a/deps/v8/test/mjsunit/harmony/classes-subclass-arrays.js b/deps/v8/test/mjsunit/harmony/classes-subclass-arrays.js
new file mode 100644
index 0000000000..e0363c715b
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/classes-subclass-arrays.js
@@ -0,0 +1,150 @@
+// 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-classes
+'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/harmony/classes.js b/deps/v8/test/mjsunit/harmony/classes.js
index 29ffbf8d7d..1b19a13193 100644
--- a/deps/v8/test/mjsunit/harmony/classes.js
+++ b/deps/v8/test/mjsunit/harmony/classes.js
@@ -139,6 +139,7 @@
class C extends B {
constructor() {
+ super();
calls++;
assertEquals(42, super.x);
}
@@ -186,7 +187,7 @@
function assertMethodDescriptor(object, name) {
var descr = Object.getOwnPropertyDescriptor(object, name);
assertTrue(descr.configurable);
- assertTrue(descr.enumerable);
+ assertFalse(descr.enumerable);
assertTrue(descr.writable);
assertEquals('function', typeof descr.value);
assertFalse('prototype' in descr.value);
@@ -196,8 +197,9 @@ function assertMethodDescriptor(object, name) {
function assertGetterDescriptor(object, name) {
var descr = Object.getOwnPropertyDescriptor(object, name);
assertTrue(descr.configurable);
- assertTrue(descr.enumerable);
+ assertFalse(descr.enumerable);
assertEquals('function', typeof descr.get);
+ assertFalse('prototype' in descr.get);
assertEquals(undefined, descr.set);
}
@@ -205,18 +207,21 @@ function assertGetterDescriptor(object, name) {
function assertSetterDescriptor(object, name) {
var descr = Object.getOwnPropertyDescriptor(object, name);
assertTrue(descr.configurable);
- assertTrue(descr.enumerable);
+ 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);
- assertTrue(descr.enumerable);
+ assertFalse(descr.enumerable);
assertEquals('function', typeof descr.get);
assertEquals('function', typeof descr.set);
+ assertFalse('prototype' in descr.get);
+ assertFalse('prototype' in descr.set);
}
@@ -609,8 +614,8 @@ function assertAccessorDescriptor(object, name) {
(function TestDefaultConstructorNoCrash() {
// Regression test for https://code.google.com/p/v8/issues/detail?id=3661
class C {}
- assertEquals(undefined, C());
- assertEquals(undefined, C(1));
+ assertThrows(function () {C();}, TypeError);
+ assertThrows(function () {C(1);}, TypeError);
assertTrue(new C() instanceof C);
assertTrue(new C(1) instanceof C);
})();
@@ -628,8 +633,8 @@ function assertAccessorDescriptor(object, name) {
assertEquals(1, calls);
calls = 0;
- Derived();
- assertEquals(1, calls);
+ assertThrows(function() { Derived(); }, TypeError);
+ assertEquals(0, calls);
})();
@@ -652,9 +657,7 @@ function assertAccessorDescriptor(object, name) {
var arr = new Array(100);
var obj = {};
- Derived.apply(obj, arr);
- assertEquals(100, args.length);
- assertEquals(obj, self);
+ assertThrows(function() {Derived.apply(obj, arr);}, TypeError);
})();
@@ -779,72 +782,73 @@ function assertAccessorDescriptor(object, name) {
})();
-(function TestSuperCallSyntacticRestriction() {
- assertThrows(function() {
- class C {
+(function TestThisAccessRestriction() {
+ class Base {}
+ (function() {
+ class C extends Base {
constructor() {
var y;
super();
}
}; new C();
- }, TypeError);
+ }());
assertThrows(function() {
- class C {
+ class C extends Base {
constructor() {
super(this.x);
}
}; new C();
- }, TypeError);
+ }, ReferenceError);
assertThrows(function() {
- class C {
+ class C extends Base {
constructor() {
super(this);
}
}; new C();
- }, TypeError);
+ }, ReferenceError);
assertThrows(function() {
- class C {
+ class C extends Base {
constructor() {
super.method();
super(this);
}
}; new C();
- }, TypeError);
+ }, ReferenceError);
assertThrows(function() {
- class C {
+ class C extends Base {
constructor() {
super(super.method());
}
}; new C();
- }, TypeError);
+ }, ReferenceError);
assertThrows(function() {
- class C {
+ class C extends Base {
constructor() {
super(super());
}
}; new C();
- }, TypeError);
+ }, ReferenceError);
assertThrows(function() {
- class C {
+ class C extends Base {
constructor() {
super(1, 2, Object.getPrototypeOf(this));
}
}; new C();
- }, TypeError);
- assertThrows(function() {
- class C {
+ }, ReferenceError);
+ (function() {
+ class C extends Base {
constructor() {
{ super(1, 2); }
}
}; new C();
- }, TypeError);
- assertThrows(function() {
- class C {
+ }());
+ (function() {
+ class C extends Base {
constructor() {
if (1) super();
}
}; new C();
- }, TypeError);
+ }());
class C1 extends Object {
constructor() {
@@ -870,10 +874,4 @@ function assertAccessorDescriptor(object, name) {
}
};
new C3();
-
- class C4 extends Object {
- constructor() {
- super(new super());
- }
- }; new C4();
}());
diff --git a/deps/v8/test/mjsunit/harmony/computed-property-names-classes.js b/deps/v8/test/mjsunit/harmony/computed-property-names-classes.js
new file mode 100644
index 0000000000..4e50f8a461
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/computed-property-names-classes.js
@@ -0,0 +1,390 @@
+// 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';
+
+// Flags: --harmony-computed-property-names --harmony-classes
+
+
+function ID(x) {
+ return x;
+}
+
+
+(function TestClassMethodString() {
+ class C {
+ a() { return 'A'}
+ ['b']() { return 'B'; }
+ c() { return 'C'; }
+ [ID('d')]() { return 'D'; }
+ }
+ assertEquals('A', new C().a());
+ assertEquals('B', new C().b());
+ assertEquals('C', new C().c());
+ assertEquals('D', new C().d());
+ assertArrayEquals([], Object.keys(C.prototype));
+ assertArrayEquals(['constructor', 'a', 'b', 'c', 'd'],
+ Object.getOwnPropertyNames(C.prototype));
+})();
+
+
+(function TestClassMethodNumber() {
+ class C {
+ a() { return 'A'; }
+ [1]() { return 'B'; }
+ c() { return 'C'; }
+ [ID(2)]() { return 'D'; }
+ }
+ assertEquals('A', new C().a());
+ assertEquals('B', new C()[1]());
+ assertEquals('C', new C().c());
+ assertEquals('D', new C()[2]());
+ // Array indexes first.
+ assertArrayEquals([], Object.keys(C.prototype));
+ assertArrayEquals(['1', '2', 'constructor', 'a', 'c'],
+ Object.getOwnPropertyNames(C.prototype));
+})();
+
+
+(function TestClassMethodSymbol() {
+ var sym1 = Symbol();
+ var sym2 = Symbol();
+ class C {
+ a() { return 'A'; }
+ [sym1]() { return 'B'; }
+ c() { return 'C'; }
+ [ID(sym2)]() { return 'D'; }
+ }
+ assertEquals('A', new C().a());
+ assertEquals('B', new C()[sym1]());
+ assertEquals('C', new C().c());
+ assertEquals('D', new C()[sym2]());
+ assertArrayEquals([], Object.keys(C.prototype));
+ assertArrayEquals(['constructor', 'a', 'c'],
+ Object.getOwnPropertyNames(C.prototype));
+ assertArrayEquals([sym1, sym2], Object.getOwnPropertySymbols(C.prototype));
+})();
+
+
+
+(function TestStaticClassMethodString() {
+ class C {
+ static a() { return 'A'}
+ static ['b']() { return 'B'; }
+ static c() { return 'C'; }
+ static ['d']() { return 'D'; }
+ }
+ assertEquals('A', C.a());
+ assertEquals('B', C.b());
+ assertEquals('C', C.c());
+ assertEquals('D', C.d());
+ assertArrayEquals([], Object.keys(C));
+ // TODO(arv): It is not clear that we are adding the "standard" properties
+ // in the right order. As far as I can tell the spec adds them in alphabetical
+ // order.
+ assertArrayEquals(['length', 'name', 'arguments', 'caller', 'prototype',
+ 'a', 'b', 'c', 'd'],
+ Object.getOwnPropertyNames(C));
+})();
+
+
+(function TestStaticClassMethodNumber() {
+ class C {
+ static a() { return 'A'; }
+ static [1]() { return 'B'; }
+ static c() { return 'C'; }
+ static [2]() { return 'D'; }
+ }
+ assertEquals('A', C.a());
+ assertEquals('B', C[1]());
+ assertEquals('C', C.c());
+ assertEquals('D', C[2]());
+ // Array indexes first.
+ assertArrayEquals([], Object.keys(C));
+ assertArrayEquals(['1', '2', 'length', 'name', 'arguments', 'caller',
+ 'prototype', 'a', 'c'], Object.getOwnPropertyNames(C));
+})();
+
+
+(function TestStaticClassMethodSymbol() {
+ var sym1 = Symbol();
+ var sym2 = Symbol();
+ class C {
+ static a() { return 'A'; }
+ static [sym1]() { return 'B'; }
+ static c() { return 'C'; }
+ static [sym2]() { return 'D'; }
+ }
+ assertEquals('A', C.a());
+ assertEquals('B', C[sym1]());
+ assertEquals('C', C.c());
+ assertEquals('D', C[sym2]());
+ assertArrayEquals([], Object.keys(C));
+ assertArrayEquals(['length', 'name', 'arguments', 'caller', 'prototype',
+ 'a', 'c'],
+ Object.getOwnPropertyNames(C));
+ assertArrayEquals([sym1, sym2], Object.getOwnPropertySymbols(C));
+})();
+
+
+
+function assertIteratorResult(value, done, result) {
+ assertEquals({ value: value, done: done}, result);
+}
+
+
+(function TestGeneratorComputedName() {
+ class C {
+ *['a']() {
+ yield 1;
+ yield 2;
+ }
+ }
+ var iter = new C().a();
+ assertIteratorResult(1, false, iter.next());
+ assertIteratorResult(2, false, iter.next());
+ assertIteratorResult(undefined, true, iter.next());
+ assertArrayEquals([], Object.keys(C.prototype));
+ assertArrayEquals(['constructor', 'a'],
+ Object.getOwnPropertyNames(C.prototype));
+})();
+
+
+(function TestToNameSideEffects() {
+ var counter = 0;
+ var key1 = {
+ toString: function() {
+ assertEquals(0, counter++);
+ return 'b';
+ }
+ };
+ var key2 = {
+ toString: function() {
+ assertEquals(1, counter++);
+ return 'd';
+ }
+ };
+ class C {
+ a() { return 'A'; }
+ [key1]() { return 'B'; }
+ c() { return 'C'; }
+ [key2]() { return 'D'; }
+ }
+ assertEquals(2, counter);
+ assertEquals('A', new C().a());
+ assertEquals('B', new C().b());
+ assertEquals('C', new C().c());
+ assertEquals('D', new C().d());
+ assertArrayEquals([], Object.keys(C.prototype));
+ assertArrayEquals(['constructor', 'a', 'b', 'c', 'd'],
+ Object.getOwnPropertyNames(C.prototype));
+})();
+
+
+(function TestToNameSideEffectsNumbers() {
+ var counter = 0;
+ var key1 = {
+ valueOf: function() {
+ assertEquals(0, counter++);
+ return 1;
+ },
+ toString: null
+ };
+ var key2 = {
+ valueOf: function() {
+ assertEquals(1, counter++);
+ return 2;
+ },
+ toString: null
+ };
+
+ class C {
+ a() { return 'A'; }
+ [key1]() { return 'B'; }
+ c() { return 'C'; }
+ [key2]() { return 'D'; }
+ }
+ assertEquals(2, counter);
+ assertEquals('A', new C().a());
+ assertEquals('B', new C()[1]());
+ assertEquals('C', new C().c());
+ assertEquals('D', new C()[2]());
+ // Array indexes first.
+ assertArrayEquals([], Object.keys(C.prototype));
+ assertArrayEquals(['1', '2', 'constructor', 'a', 'c'],
+ Object.getOwnPropertyNames(C.prototype));
+})();
+
+
+(function TestGetter() {
+ class C {
+ get ['a']() {
+ return 'A';
+ }
+ }
+ assertEquals('A', new C().a);
+
+ class C2 {
+ get b() {
+ assertUnreachable();
+ }
+ get ['b']() {
+ return 'B';
+ }
+ }
+ assertEquals('B', new C2().b);
+
+ class C3 {
+ get c() {
+ assertUnreachable();
+ }
+ get ['c']() {
+ assertUnreachable();
+ }
+ get ['c']() {
+ return 'C';
+ }
+ }
+ assertEquals('C', new C3().c);
+
+ class C4 {
+ get ['d']() {
+ assertUnreachable();
+ }
+ get d() {
+ return 'D';
+ }
+ }
+ assertEquals('D', new C4().d);
+})();
+
+
+(function TestSetter() {
+ var calls = 0;
+ class C {
+ set ['a'](_) {
+ calls++;
+ }
+ }
+ new C().a = 'A';
+ assertEquals(1, calls);
+
+ calls = 0;
+ class C2 {
+ set b(_) {
+ assertUnreachable();
+ }
+ set ['b'](_) {
+ calls++;
+ }
+ }
+ new C2().b = 'B';
+ assertEquals(1, calls);
+
+ calls = 0;
+ class C3 {
+ set c(_) {
+ assertUnreachable()
+ }
+ set ['c'](_) {
+ assertUnreachable()
+ }
+ set ['c'](_) {
+ calls++
+ }
+ }
+ new C3().c = 'C';
+ assertEquals(1, calls);
+
+ calls = 0;
+ class C4 {
+ set ['d'](_) {
+ assertUnreachable()
+ }
+ set d(_) {
+ calls++
+ }
+ }
+ new C4().d = 'D';
+ assertEquals(1, calls);
+})();
+
+
+(function TestPrototype() {
+ // Normally a static prototype property is not allowed.
+ class C {
+ static ['prototype']() {
+ return 1;
+ }
+ }
+ assertEquals(1, C.prototype());
+
+ class C2 {
+ static get ['prototype']() {
+ return 2;
+ }
+ }
+ assertEquals(2, C2.prototype);
+
+ var calls = 0;
+ class C3 {
+ static set ['prototype'](x) {
+ assertEquals(3, x);
+ calls++;
+ }
+ }
+ C3.prototype = 3;
+ assertEquals(1, calls);
+
+ class C4 {
+ static *['prototype']() {
+ yield 1;
+ yield 2;
+ }
+ }
+ var iter = C4.prototype();
+ assertIteratorResult(1, false, iter.next());
+ assertIteratorResult(2, false, iter.next());
+ assertIteratorResult(undefined, true, iter.next());
+})();
+
+
+(function TestConstructor() {
+ // Normally a constructor property is not allowed.
+ class C {
+ ['constructor']() {
+ return 1;
+ }
+ }
+ assertTrue(C !== C.prototype.constructor);
+ assertEquals(1, new C().constructor());
+
+ class C2 {
+ get ['constructor']() {
+ return 2;
+ }
+ }
+ assertEquals(2, new C2().constructor);
+
+ var calls = 0;
+ class C3 {
+ set ['constructor'](x) {
+ assertEquals(3, x);
+ calls++;
+ }
+ }
+ new C3().constructor = 3;
+ assertEquals(1, calls);
+
+ class C4 {
+ *['constructor']() {
+ yield 1;
+ yield 2;
+ }
+ }
+ var iter = new C4().constructor();
+ assertIteratorResult(1, false, iter.next());
+ assertIteratorResult(2, false, iter.next());
+ assertIteratorResult(undefined, true, iter.next());
+})();
diff --git a/deps/v8/test/mjsunit/harmony/computed-property-names-object-literals-methods.js b/deps/v8/test/mjsunit/harmony/computed-property-names-object-literals-methods.js
new file mode 100644
index 0000000000..135d09854e
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/computed-property-names-object-literals-methods.js
@@ -0,0 +1,121 @@
+// 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-computed-property-names --harmony-object-literals
+
+
+function ID(x) {
+ return x;
+}
+
+
+(function TestMethodComputedNameString() {
+ var object = {
+ a() { return 'A'},
+ ['b']() { return 'B'; },
+ c() { return 'C'; },
+ [ID('d')]() { return 'D'; },
+ };
+ assertEquals('A', object.a());
+ assertEquals('B', object.b());
+ assertEquals('C', object.c());
+ assertEquals('D', object.d());
+ assertArrayEquals(['a', 'b', 'c', 'd'], Object.keys(object));
+})();
+
+
+(function TestMethodComputedNameNumber() {
+ var object = {
+ a() { return 'A'; },
+ [1]() { return 'B'; },
+ c() { return 'C'; },
+ [ID(2)]() { return 'D'; },
+ };
+ assertEquals('A', object.a());
+ assertEquals('B', object[1]());
+ assertEquals('C', object.c());
+ assertEquals('D', object[2]());
+ // Array indexes first.
+ assertArrayEquals(['1', '2', 'a', 'c'], Object.keys(object));
+})();
+
+
+(function TestMethodComputedNameSymbol() {
+ var sym1 = Symbol();
+ var sym2 = Symbol();
+ var object = {
+ a() { return 'A'; },
+ [sym1]() { return 'B'; },
+ c() { return 'C'; },
+ [ID(sym2)]() { return 'D'; },
+ };
+ assertEquals('A', object.a());
+ assertEquals('B', object[sym1]());
+ assertEquals('C', object.c());
+ assertEquals('D', object[sym2]());
+ assertArrayEquals(['a', 'c'], Object.keys(object));
+ assertArrayEquals([sym1, sym2], Object.getOwnPropertySymbols(object));
+})();
+
+
+function assertIteratorResult(value, done, result) {
+ assertEquals({ value: value, done: done}, result);
+}
+
+
+(function TestGeneratorComputedName() {
+ var object = {
+ *['a']() {
+ yield 1;
+ yield 2;
+ }
+ };
+ var iter = object.a();
+ assertIteratorResult(1, false, iter.next());
+ assertIteratorResult(2, false, iter.next());
+ assertIteratorResult(undefined, true, iter.next());
+ assertArrayEquals(['a'], Object.keys(object));
+})();
+
+
+(function TestToNameSideEffects() {
+ var counter = 0;
+ var key1 = {
+ toString: function() {
+ assertEquals(0, counter++);
+ return 'b';
+ }
+ };
+ var key2 = {
+ toString: function() {
+ assertEquals(1, counter++);
+ return 'd';
+ }
+ };
+ var object = {
+ a() { return 'A'; },
+ [key1]() { return 'B'; },
+ c() { return 'C'; },
+ [key2]() { return 'D'; },
+ };
+ assertEquals(2, counter);
+ assertEquals('A', object.a());
+ assertEquals('B', object.b());
+ assertEquals('C', object.c());
+ assertEquals('D', object.d());
+ assertArrayEquals(['a', 'b', 'c', 'd'], Object.keys(object));
+})();
+
+
+(function TestDuplicateKeys() {
+ 'use strict';
+ // ES5 does not allow duplicate keys.
+ // ES6 does but we haven't changed our code yet.
+
+ var object = {
+ a() { return 1; },
+ ['a']() { return 2; },
+ };
+ assertEquals(2, object.a());
+})();
diff --git a/deps/v8/test/mjsunit/harmony/computed-property-names-super.js b/deps/v8/test/mjsunit/harmony/computed-property-names-super.js
new file mode 100644
index 0000000000..096e010317
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/computed-property-names-super.js
@@ -0,0 +1,79 @@
+// 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-computed-property-names --harmony-object-literals
+// Flags: --harmony-classes --allow-natives-syntax
+
+
+function ID(x) {
+ return x;
+}
+
+
+(function TestComputedMethodSuper() {
+ var proto = {
+ m() {
+ return ' proto m';
+ }
+ };
+ var object = {
+ __proto__: proto,
+ ['a']() { return 'a' + super.m(); },
+ [ID('b')]() { return 'b' + super.m(); },
+ [0]() { return '0' + super.m(); },
+ [ID(1)]() { return '1' + super.m(); },
+ };
+
+ assertSame(object, object.a[%HomeObjectSymbol()]);
+
+ assertEquals('a proto m', object.a());
+ assertEquals('b proto m', object.b());
+ assertEquals('0 proto m', object[0]());
+ assertEquals('1 proto m', object[1]());
+})();
+
+
+(function TestComputedGetterSuper() {
+ var proto = {
+ m() {
+ return ' proto m';
+ }
+ };
+ var object = {
+ __proto__: proto,
+ get ['a']() { return 'a' + super.m(); },
+ get [ID('b')]() { return 'b' + super.m(); },
+ get [0]() { return '0' + super.m(); },
+ get [ID(1)]() { return '1' + super.m(); },
+ };
+ assertEquals('a proto m', object.a);
+ assertEquals('b proto m', object.b);
+ assertEquals('0 proto m', object[0]);
+ assertEquals('1 proto m', object[1]);
+})();
+
+
+(function TestComputedSetterSuper() {
+ var value;
+ var proto = {
+ m(name, v) {
+ value = name + ' ' + v;
+ }
+ };
+ var object = {
+ __proto__: proto,
+ set ['a'](v) { super.m('a', v); },
+ set [ID('b')](v) { super.m('b', v); },
+ set [0](v) { super.m('0', v); },
+ set [ID(1)](v) { super.m('1', v); },
+ };
+ object.a = 2;
+ assertEquals('a 2', value);
+ object.b = 3;
+ assertEquals('b 3', value);
+ object[0] = 4;
+ assertEquals('0 4', value);
+ object[1] = 5;
+ assertEquals('1 5', value);
+})();
diff --git a/deps/v8/test/mjsunit/harmony/computed-property-names.js b/deps/v8/test/mjsunit/harmony/computed-property-names.js
new file mode 100644
index 0000000000..69360771c1
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/computed-property-names.js
@@ -0,0 +1,279 @@
+// 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-computed-property-names
+
+
+function ID(x) {
+ return x;
+}
+
+
+
+(function TestBasicsString() {
+ var object = {
+ a: 'A',
+ ['b']: 'B',
+ c: 'C',
+ [ID('d')]: 'D',
+ };
+ assertEquals('A', object.a);
+ assertEquals('B', object.b);
+ assertEquals('C', object.c);
+ assertEquals('D', object.d);
+ assertArrayEquals(['a', 'b', 'c', 'd'], Object.keys(object));
+})();
+
+
+(function TestBasicsNumber() {
+ var object = {
+ a: 'A',
+ [1]: 'B',
+ c: 'C',
+ [ID(2)]: 'D',
+ };
+ assertEquals('A', object.a);
+ assertEquals('B', object[1]);
+ assertEquals('C', object.c);
+ assertEquals('D', object[2]);
+ // Array indexes first.
+ assertArrayEquals(['1', '2', 'a', 'c'], Object.keys(object));
+})();
+
+
+(function TestBasicsSymbol() {
+ var sym1 = Symbol();
+ var sym2 = Symbol();
+ var object = {
+ a: 'A',
+ [sym1]: 'B',
+ c: 'C',
+ [ID(sym2)]: 'D',
+ };
+ assertEquals('A', object.a);
+ assertEquals('B', object[sym1]);
+ assertEquals('C', object.c);
+ assertEquals('D', object[sym2]);
+ assertArrayEquals(['a', 'c'], Object.keys(object));
+ assertArrayEquals([sym1, sym2], Object.getOwnPropertySymbols(object));
+})();
+
+
+(function TestToNameSideEffects() {
+ var counter = 0;
+ var key1 = {
+ toString: function() {
+ assertEquals(0, counter++);
+ return 'b';
+ }
+ };
+ var key2 = {
+ toString: function() {
+ assertEquals(1, counter++);
+ return 'd';
+ }
+ };
+ var object = {
+ a: 'A',
+ [key1]: 'B',
+ c: 'C',
+ [key2]: 'D',
+ };
+ assertEquals(2, counter);
+ assertEquals('A', object.a);
+ assertEquals('B', object.b);
+ assertEquals('C', object.c);
+ assertEquals('D', object.d);
+ assertArrayEquals(['a', 'b', 'c', 'd'], Object.keys(object));
+})();
+
+
+(function TestToNameSideEffectsNumbers() {
+ var counter = 0;
+ var key1 = {
+ valueOf: function() {
+ assertEquals(0, counter++);
+ return 1;
+ },
+ toString: null
+ };
+ var key2 = {
+ valueOf: function() {
+ assertEquals(1, counter++);
+ return 2;
+ },
+ toString: null
+ };
+
+ var object = {
+ a: 'A',
+ [key1]: 'B',
+ c: 'C',
+ [key2]: 'D',
+ };
+ assertEquals(2, counter);
+ assertEquals('A', object.a);
+ assertEquals('B', object[1]);
+ assertEquals('C', object.c);
+ assertEquals('D', object[2]);
+ // Array indexes first.
+ assertArrayEquals(['1', '2', 'a', 'c'], Object.keys(object));
+})();
+
+
+(function TestDoubleName() {
+ var object = {
+ [1.2]: 'A',
+ [1e55]: 'B',
+ [0.000001]: 'C',
+ [-0]: 'D',
+ // TODO(arv): https://code.google.com/p/v8/issues/detail?id=3815
+ // [Infinity]: 'E',
+ // [-Infinity]: 'F',
+ [NaN]: 'G',
+ };
+ assertEquals('A', object['1.2']);
+ assertEquals('B', object['1e+55']);
+ assertEquals('C', object['0.000001']);
+ assertEquals('D', object[0]);
+ // TODO(arv): https://code.google.com/p/v8/issues/detail?id=3815
+ // assertEquals('E', object[Infinity]);
+ // assertEquals('F', object[-Infinity]);
+ assertEquals('G', object[NaN]);
+})();
+
+
+(function TestGetter() {
+ var object = {
+ get ['a']() {
+ return 'A';
+ }
+ };
+ assertEquals('A', object.a);
+
+ object = {
+ get b() {
+ assertUnreachable();
+ },
+ get ['b']() {
+ return 'B';
+ }
+ };
+ assertEquals('B', object.b);
+
+ object = {
+ get c() {
+ assertUnreachable();
+ },
+ get ['c']() {
+ assertUnreachable();
+ },
+ get ['c']() {
+ return 'C';
+ }
+ };
+ assertEquals('C', object.c);
+
+ object = {
+ get ['d']() {
+ assertUnreachable();
+ },
+ get d() {
+ return 'D';
+ }
+ };
+ assertEquals('D', object.d);
+})();
+
+
+(function TestSetter() {
+ var calls = 0;
+ var object = {
+ set ['a'](_) {
+ calls++;
+ }
+ };
+ object.a = 'A';
+ assertEquals(1, calls);
+
+ calls = 0;
+ object = {
+ set b(_) {
+ assertUnreachable();
+ },
+ set ['b'](_) {
+ calls++;
+ }
+ };
+ object.b = 'B';
+ assertEquals(1, calls);
+
+ calls = 0;
+ object = {
+ set c(_) {
+ assertUnreachable()
+ },
+ set ['c'](_) {
+ assertUnreachable()
+ },
+ set ['c'](_) {
+ calls++
+ }
+ };
+ object.c = 'C';
+ assertEquals(1, calls);
+
+ calls = 0;
+ object = {
+ set ['d'](_) {
+ assertUnreachable()
+ },
+ set d(_) {
+ calls++
+ }
+ };
+ object.d = 'D';
+ assertEquals(1, calls);
+})();
+
+
+(function TestDuplicateKeys() {
+ 'use strict';
+ // ES5 does not allow duplicate keys.
+ // ES6 does but we haven't changed our code yet.
+
+ var object = {
+ a: 1,
+ ['a']: 2,
+ };
+ assertEquals(2, object.a);
+})();
+
+
+(function TestProto() {
+ var proto = {};
+ var object = {
+ __proto__: proto
+ };
+ assertEquals(proto, Object.getPrototypeOf(object));
+
+ object = {
+ '__proto__': proto
+ };
+ assertEquals(proto, Object.getPrototypeOf(object));
+
+ object = {
+ ['__proto__']: proto
+ };
+ assertEquals(Object.prototype, Object.getPrototypeOf(object));
+ assertEquals(proto, object.__proto__);
+ assertTrue(object.hasOwnProperty('__proto__'));
+
+ object = {
+ [ID('x')]: 'X',
+ __proto__: proto
+ };
+ assertEquals('X', object.x);
+ assertEquals(proto, Object.getPrototypeOf(object));
+})();
diff --git a/deps/v8/test/mjsunit/harmony/method-name-eval-arguments.js b/deps/v8/test/mjsunit/harmony/method-name-eval-arguments.js
new file mode 100644
index 0000000000..360aadbca9
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/method-name-eval-arguments.js
@@ -0,0 +1,35 @@
+// 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-object-literals
+
+(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/regress/regress-1145.js b/deps/v8/test/mjsunit/harmony/module-parsing-eval.js
index 16d5527bbb..fa9e5ec35c 100644
--- a/deps/v8/test/mjsunit/regress/regress-1145.js
+++ b/deps/v8/test/mjsunit/harmony/module-parsing-eval.js
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// 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:
@@ -25,30 +25,17 @@
// (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: --opt-eagerly --debug-code --lazy
+// Flags: --harmony-modules
-// See: http://code.google.com/p/v8/issues/detail?id=1145
-// Should not throw a syntax error exception (change this if we make lazily
-// compiled functions with syntax errors into early errors).
-// Should not hit an assertion in debug mode.
+// Check that import/export declarations are rejected in eval or local scope.
+assertThrows("export let x;", SyntaxError);
+assertThrows("import x from 'http://url';", SyntaxError);
-// A lazily compiled function with a syntax error that is attempted inlined
-// would set a pending exception that is then ignored (until it triggers
-// an assert).
-// This file must be at least 1024 bytes long to trigger lazy compilation.
+assertThrows("{ export let x; }", SyntaxError);
+assertThrows("{ import x from 'http://url'; }", SyntaxError);
-function f() { return 1; }
+assertThrows("function f() { export let x; }", SyntaxError);
+assertThrows("function f() { import x from 'http://url'; }", SyntaxError);
-// Must be lazy. Must throw SyntaxError during compilation.
-function fail() { continue; }
-
-function opt_me() {
- var x = 1;
- // Do lots of function calls and hope to be optimized.
- for (var i = 0; i < 1000000; i++) {
- x = f();
- }
- if (x == 0) fail(); // Hope to be inlined during optimization.
-}
-
-opt_me();
+assertThrows("function f() { { export let x; } }", SyntaxError);
+assertThrows("function f() { { import x from 'http://url'; } }", SyntaxError);
diff --git a/deps/v8/test/mjsunit/harmony/module-parsing.js b/deps/v8/test/mjsunit/harmony/module-parsing.js
deleted file mode 100644
index 8a9103d132..0000000000
--- a/deps/v8/test/mjsunit/harmony/module-parsing.js
+++ /dev/null
@@ -1,190 +0,0 @@
-// 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: --harmony-modules
-
-// Test basic module syntax, with and without automatic semicolon insertion.
-
-module A {}
-
-module A1 = A
-module A2 = A;
-module A3 = A2
-
-module B {
- export vx
- export vy, lz, c, f
-
- var vx
- var vx, vy;
- var vx = 0, vy
- let lx, ly
- let lz = 1
- const c = 9
- function f() {}
-
- module C0 {}
-
- export module C {
- let x
- export module D { export let x }
- let y
- }
-
- let zz = ""
-
- export var x0
- export var x1, x2 = 6, x3
- export let y0
- export let y1 = 0, y2
- export const z0 = 0
- export const z1 = 2, z2 = 3
- export function f0() {}
- export module M1 {}
- export module M2 = C.D
- export module M3 at "http://where"
-
- import i0 from I
- import i1, i2, i3, M from I
- //import i4, i5 from "http://where"
-}
-
-module I {
- export let i0, i1, i2, i3;
- export module M {}
-}
-
-module C1 = B.C;
-module D1 = B.C.D
-module D2 = C1.D
-module D3 = D2
-
-module E1 at "http://where"
-module E2 at "http://where";
-module E3 = E1
-
-// Check that ASI does not interfere.
-
-module X
-{
-let x
-}
-
-module Y
-=
-X
-
-module Z
-at
-"file://local"
-
-import
-vx
-,
-vy
-from
-B
-
-
-module Wrap {
-export
-x
-,
-y
-
-var
-x
-,
-y
-
-export
-var
-v1 = 1
-
-export
-let
-v2 = 2
-
-export
-const
-v3 = 3
-
-export
-function
-f
-(
-)
-{
-}
-
-export
-module V
-{
-}
-}
-
-export A, A1, A2, A3, B, I, C1, D1, D2, D3, E1, E2, E3, X, Y, Z, Wrap, x, y, UU
-
-
-
-// Check that 'module' still works as an identifier.
-
-var module
-module = {}
-module["a"] = 6
-function module() {}
-function f(module) { return module }
-try {} catch (module) {}
-
-module
-v = 20
-
-
-
-// Check that module declarations are rejected in eval or local scope.
-
-module M { export let x; }
-
-assertThrows("export x;", SyntaxError); // It's using eval, so should throw.
-assertThrows("export let x;", SyntaxError);
-assertThrows("import x from M;", SyntaxError);
-assertThrows("module M {};", SyntaxError);
-
-assertThrows("{ export x; }", SyntaxError);
-assertThrows("{ export let x; }", SyntaxError);
-assertThrows("{ import x from M; }", SyntaxError);
-assertThrows("{ module M {}; }", SyntaxError);
-
-assertThrows("function f() { export x; }", SyntaxError);
-assertThrows("function f() { export let x; }", SyntaxError);
-assertThrows("function f() { import x from M; }", SyntaxError);
-assertThrows("function f() { module M {}; }", SyntaxError);
-
-assertThrows("function f() { { export x; } }", SyntaxError);
-assertThrows("function f() { { export let x; } }", SyntaxError);
-assertThrows("function f() { { import x from M; } }", SyntaxError);
-assertThrows("function f() { { module M {}; } }", SyntaxError);
diff --git a/deps/v8/test/mjsunit/harmony/modules.js b/deps/v8/test/mjsunit/harmony/modules.js
new file mode 100644
index 0000000000..e56880500b
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/modules.js
@@ -0,0 +1,8 @@
+// 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.
+//
+// MODULE
+
+export let a = 42;
+assertEquals(42, a);
diff --git a/deps/v8/test/mjsunit/harmony/object-literals-method.js b/deps/v8/test/mjsunit/harmony/object-literals-method.js
index 71f44d10bc..605e269fcb 100644
--- a/deps/v8/test/mjsunit/harmony/object-literals-method.js
+++ b/deps/v8/test/mjsunit/harmony/object-literals-method.js
@@ -246,3 +246,27 @@ function assertIteratorResult(value, done, result) {
};
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/harmony/object-literals-property-shorthand.js b/deps/v8/test/mjsunit/harmony/object-literals-property-shorthand.js
index 2921495d89..9756da46c1 100644
--- a/deps/v8/test/mjsunit/harmony/object-literals-property-shorthand.js
+++ b/deps/v8/test/mjsunit/harmony/object-literals-property-shorthand.js
@@ -49,3 +49,25 @@
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/harmony/object-literals-super.js b/deps/v8/test/mjsunit/harmony/object-literals-super.js
index ec22b8a8a3..c2d456c877 100644
--- a/deps/v8/test/mjsunit/harmony/object-literals-super.js
+++ b/deps/v8/test/mjsunit/harmony/object-literals-super.js
@@ -22,15 +22,6 @@
set accessor(v) {
super.accessor = v;
},
- property: function() {
- super.property();
- },
- propertyWithParen: (function() {
- super.property();
- }),
- propertyWithParens: ((function() {
- super.property();
- })),
methodNoSuper() {},
get getterNoSuper() {},
@@ -50,9 +41,6 @@
desc = Object.getOwnPropertyDescriptor(object, 'accessor');
assertEquals(object, desc.get[%HomeObjectSymbol()]);
assertEquals(object, desc.set[%HomeObjectSymbol()]);
- assertEquals(object, object.property[%HomeObjectSymbol()]);
- assertEquals(object, object.propertyWithParen[%HomeObjectSymbol()]);
- assertEquals(object, object.propertyWithParens[%HomeObjectSymbol()]);
assertEquals(undefined, object.methodNoSuper[%HomeObjectSymbol()]);
desc = Object.getOwnPropertyDescriptor(object, 'getterNoSuper');
@@ -118,21 +106,6 @@
})();
-(function TestMethodAsProperty() {
- var object = {
- __proto__: {
- method: function(x) {
- return 'proto' + x;
- }
- },
- method: function(x) {
- return super.method(x);
- }
- };
- assertEquals('proto42', object.method(42));
-})();
-
-
(function TestOptimized() {
// Object literals without any accessors get optimized.
var object = {
@@ -154,15 +127,7 @@
*g() {
yield super.m();
},
- g2: function*() {
- yield super.m() + 1;
- },
- g3: (function*() {
- yield super.m() + 2;
- })
};
assertEquals(42, o.g().next().value);
- assertEquals(43, o.g2().next().value);
- assertEquals(44, o.g3().next().value);
})();
diff --git a/deps/v8/test/mjsunit/harmony/regexp-flags.js b/deps/v8/test/mjsunit/harmony/regexp-flags.js
index 475fda493c..fae88610e4 100644
--- a/deps/v8/test/mjsunit/harmony/regexp-flags.js
+++ b/deps/v8/test/mjsunit/harmony/regexp-flags.js
@@ -2,19 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-regexps
+// Flags: --harmony-regexps --harmony-unicode-regexps
RegExp.prototype.flags = 'setter should be undefined';
assertEquals('', RegExp('').flags);
assertEquals('', /./.flags);
-assertEquals('gimy', RegExp('', 'ygmi').flags);
-assertEquals('gimy', /foo/ymig.flags);
-
-// TODO(dslomov): When support for the `u` flag is added, uncomment the first
-// line below and remove the second line.
-//assertEquals(RegExp('', 'yumig').flags, 'gimuy');
-assertThrows(function() { RegExp('', 'yumig').flags; }, SyntaxError);
+assertEquals('gimuy', RegExp('', 'yugmi').flags);
+assertEquals('gimuy', /foo/yumig.flags);
var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
assertTrue(descriptor.configurable);
diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-455141.js b/deps/v8/test/mjsunit/harmony/regress/regress-455141.js
new file mode 100644
index 0000000000..cf2141f903
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/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: --harmony-classes --no-lazy
+"use strict";
+class Base {
+}
+class Subclass extends Base {
+ constructor() {
+ this.prp1 = 3;
+ }
+}
+function __f_1(){
+}
diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-typedarray-out-of-bounds.js b/deps/v8/test/mjsunit/harmony/regress/regress-typedarray-out-of-bounds.js
new file mode 100644
index 0000000000..4db280aac9
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/regress/regress-typedarray-out-of-bounds.js
@@ -0,0 +1,10 @@
+// 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 a = new Int32Array(10);
+function f(a) { a["-1"] = 15; }
+for (var i = 0; i < 3; i++) {
+ f(a);
+}
+assertEquals(undefined, a[-1]);
diff --git a/deps/v8/test/mjsunit/harmony/rest-params-lazy-parsing.js b/deps/v8/test/mjsunit/harmony/rest-params-lazy-parsing.js
new file mode 100644
index 0000000000..ba8e3008b9
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/rest-params-lazy-parsing.js
@@ -0,0 +1,17 @@
+// 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-rest-parameters --min-preparse-length=0
+
+function variadic(co, ...values) {
+ var sum = 0;
+ while (values.length) {
+ sum += co * values.pop();
+ }
+ return sum;
+}
+
+assertEquals(90, variadic(2, 1, 2, 3, 4, 5, 6, 7, 8, 9));
+assertEquals(74, variadic(2, 1, 2, 3, 4, 5, 6, 7, 9));
+assertEquals(110, variadic(2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
diff --git a/deps/v8/test/mjsunit/harmony/rest-params.js b/deps/v8/test/mjsunit/harmony/rest-params.js
new file mode 100644
index 0000000000..5bb258ee68
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/rest-params.js
@@ -0,0 +1,182 @@
+// 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-rest-parameters
+
+(function testRestIndex() {
+ assertEquals(5, (function(...args) { return args.length; })(1,2,3,4,5));
+ assertEquals(4, (function(a, ...args) { return args.length; })(1,2,3,4,5));
+ assertEquals(3, (function(a, b, ...args) { return args.length; })(1,2,3,4,5));
+ assertEquals(2, (function(a, b, c, ...args) {
+ return args.length; })(1,2,3,4,5));
+ assertEquals(1, (function(a, b, c, d, ...args) {
+ return args.length; })(1,2,3,4,5));
+ assertEquals(0, (function(a, b, c, d, e, ...args) {
+ return args.length; })(1,2,3,4,5));
+})();
+
+function strictTest(a, b, ...c) {
+ "use strict";
+ assertEquals(Array, c.constructor);
+ assertTrue(Array.isArray(c));
+
+ var expectedLength = arguments.length >= 3 ? arguments.length - 2 : 0;
+ assertEquals(expectedLength, c.length);
+
+ for (var i = 2, j = 0; i < arguments.length; ++i) {
+ assertEquals(c[j++], arguments[i]);
+ }
+}
+
+function sloppyTest(a, b, ...c) {
+ assertEquals(Array, c.constructor);
+ assertTrue(Array.isArray(c));
+
+ var expectedLength = arguments.length >= 3 ? arguments.length - 2 : 0;
+ assertEquals(expectedLength, c.length);
+
+ for (var i = 2, j = 0; i < arguments.length; ++i) {
+ assertEquals(c[j++], arguments[i]);
+ }
+}
+
+
+var O = {
+ strict: strictTest,
+ sloppy: sloppyTest
+};
+
+(function testStrictRestParamArity() {
+ assertEquals(2, strictTest.length);
+ assertEquals(2, O.strict.length);
+})();
+
+
+(function testRestParamsStrictMode() {
+ strictTest();
+ strictTest(1, 2);
+ strictTest(1, 2, 3, 4, 5, 6);
+ strictTest(1, 2, 3);
+ O.strict();
+ O.strict(1, 2);
+ O.strict(1, 2, 3, 4, 5, 6);
+ O.strict(1, 2, 3);
+})();
+
+
+(function testRestParamsStrictModeApply() {
+ strictTest.apply(null, []);
+ strictTest.apply(null, [1, 2]);
+ strictTest.apply(null, [1, 2, 3, 4, 5, 6]);
+ strictTest.apply(null, [1, 2, 3]);
+ O.strict.apply(O, []);
+ O.strict.apply(O, [1, 2]);
+ O.strict.apply(O, [1, 2, 3, 4, 5, 6]);
+ O.strict.apply(O, [1, 2, 3]);
+})();
+
+
+(function testRestParamsStrictModeCall() {
+ strictTest.call(null);
+ strictTest.call(null, 1, 2);
+ strictTest.call(null, 1, 2, 3, 4, 5, 6);
+ strictTest.call(null, 1, 2, 3);
+ O.strict.call(O);
+ O.strict.call(O, 1, 2);
+ O.strict.call(O, 1, 2, 3, 4, 5, 6);
+ O.strict.call(O, 1, 2, 3);
+})();
+
+
+(function testsloppyRestParamArity() {
+ assertEquals(2, sloppyTest.length);
+ assertEquals(2, O.sloppy.length);
+})();
+
+
+(function testRestParamssloppyMode() {
+ sloppyTest();
+ sloppyTest(1, 2);
+ sloppyTest(1, 2, 3, 4, 5, 6);
+ sloppyTest(1, 2, 3);
+ O.sloppy();
+ O.sloppy(1, 2);
+ O.sloppy(1, 2, 3, 4, 5, 6);
+ O.sloppy(1, 2, 3);
+})();
+
+
+(function testRestParamssloppyModeApply() {
+ sloppyTest.apply(null, []);
+ sloppyTest.apply(null, [1, 2]);
+ sloppyTest.apply(null, [1, 2, 3, 4, 5, 6]);
+ sloppyTest.apply(null, [1, 2, 3]);
+ O.sloppy.apply(O, []);
+ O.sloppy.apply(O, [1, 2]);
+ O.sloppy.apply(O, [1, 2, 3, 4, 5, 6]);
+ O.sloppy.apply(O, [1, 2, 3]);
+})();
+
+
+(function testRestParamssloppyModeCall() {
+ sloppyTest.call(null);
+ sloppyTest.call(null, 1, 2);
+ sloppyTest.call(null, 1, 2, 3, 4, 5, 6);
+ sloppyTest.call(null, 1, 2, 3);
+ O.sloppy.call(O);
+ O.sloppy.call(O, 1, 2);
+ O.sloppy.call(O, 1, 2, 3, 4, 5, 6);
+ O.sloppy.call(O, 1, 2, 3);
+})();
+
+
+(function testUnmappedArguments() {
+ // Strict/Unmapped arguments should always be used for functions with rest
+ // parameters
+ assertThrows(function(...rest) { return arguments.caller; }, TypeError);
+ assertThrows(function(...rest) { return arguments.callee; }, TypeError);
+ // TODO(caitp): figure out why this doesn't throw sometimes, even though the
+ // getter always does =)
+ // assertThrows(function(...rest) { arguments.caller = 1; }, TypeError);
+ // assertThrows(function(...rest) { arguments.callee = 1; }, TypeError);
+})();
+
+
+(function testNoAliasArgumentsStrict() {
+ function strictF(a, ...rest) {
+ "use strict";
+ arguments[0] = 1;
+ assertEquals(3, a);
+ arguments[1] = 2;
+ assertArrayEquals([4, 5], rest);
+ }
+ strictF(3, 4, 5);
+})();
+
+
+(function testNoAliasArgumentsSloppy() {
+ function sloppyF(a, ...rest) {
+ arguments[0] = 1;
+ assertEquals(3, a);
+ arguments[1] = 2;
+ assertArrayEquals([4, 5], rest);
+ }
+ sloppyF(3, 4, 5);
+})();
+
+
+/* TODO(caitp): support arrow functions (blocked on spread operator support)
+(function testRestParamsArrowFunctions() {
+ "use strict";
+
+ var fn = (a, b, ...c) => c;
+ assertEquals([], fn());
+ assertEquals([], fn(1, 2));
+ assertEquals([3], fn(1, 2, 3));
+ assertEquals([3, 4], fn(1, 2, 3, 4));
+ assertEquals([3, 4, 5], fn(1, 2, 3, 4, 5));
+ assertThrows("var x = ...y => y;", SyntaxError);
+ assertEquals([], ((...args) => args)());
+ assertEquals([1,2,3], ((...args) => args)(1,2,3));
+})();*/
diff --git a/deps/v8/test/mjsunit/harmony/super.js b/deps/v8/test/mjsunit/harmony/super.js
index 6dcc393cce..988cef22e2 100644
--- a/deps/v8/test/mjsunit/harmony/super.js
+++ b/deps/v8/test/mjsunit/harmony/super.js
@@ -1,36 +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-classes
+// Flags: --harmony-classes --allow-natives-syntax
(function TestSuperNamedLoads() {
function Base() { }
+ function fBase() { }
+ Base.prototype = {
+ f() {
+ return "Base " + this.toString();
+ },
+ x: 15,
+ toString() {
+ return "this is Base";
+ }
+ };
+
function Derived() {
this.derivedDataProperty = "xxx";
}
- Derived.prototype = Object.create(Base.prototype);
-
- function fBase() { return "Base " + this.toString(); }
-
- Base.prototype.f = fBase.toMethod(Base.prototype);
-
- function fDerived() {
- assertEquals("Base this is Derived", super.f());
- var a = super.x;
- assertEquals(15, a);
- assertEquals(15, super.x);
- assertEquals(27, this.x);
-
- return "Derived"
- }
-
- Base.prototype.x = 15;
- Base.prototype.toString = function() { return "this is Base"; };
- Derived.prototype.toString = function() { return "this is Derived"; };
- Derived.prototype.x = 27;
- Derived.prototype.f = fDerived.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ toString() { return "this is Derived"; },
+ x: 27,
+ f() {
+ assertEquals("Base this is Derived", super.f());
+ var a = super.x;
+ assertEquals(15, a);
+ assertEquals(15, super.x);
+ assertEquals(27, this.x);
+ return "Derived";
+ }
+ };
assertEquals("Base this is Base", new Base().f());
assertEquals("Derived", new Derived().f());
@@ -38,34 +40,39 @@
(function TestSuperKeyedLoads() {
+ 'use strict';
+
var x = 'x';
var derivedDataProperty = 'derivedDataProperty';
var f = 'f';
- function Base() { }
- function Derived() {
- this[derivedDataProperty] = 'xxx';
- }
- Derived.prototype = Object.create(Base.prototype);
-
- function fBase() { return "Base " + this.toString(); }
-
- Base.prototype[f] = fBase.toMethod(Base.prototype);
-
- function fDerived() {
- assertEquals("Base this is Derived", super[f]());
- var a = super[x];
- assertEquals(15, a);
- assertEquals(15, super[x]);
- assertEquals(27, this[x]);
- return "Derived"
+ class Base {
+ f() {
+ return "Base " + this.toString();
+ }
+ toString() {
+ return "this is Base";
+ }
}
Base.prototype[x] = 15;
- Base.prototype.toString = function() { return "this is Base"; };
- Derived.prototype.toString = function() { return "this is Derived"; };
- Derived.prototype[x] = 27;
- Derived.prototype[f] = fDerived.toMethod(Derived.prototype);
+
+ function Derived() {
+ this[derivedDataProperty] = "xxx";
+ }
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ toString() { return "this is Derived"; },
+ x: 27,
+ f() {
+ assertEquals("Base this is Derived", super[f]());
+ var a = super[x];
+ assertEquals(15, a);
+ assertEquals(15, super[x]);
+ assertEquals(27, this[x]);
+ return "Derived";
+ }
+ };
assertEquals("Base this is Base", new Base().f());
assertEquals("Derived", new Derived().f());
@@ -76,31 +83,29 @@
var x = 1;
var derivedDataProperty = 2;
var f = 3;
- function Base() { }
- function Derived() {
- this[derivedDataProperty] = 'xxx';
- }
- Derived.prototype = Object.create(Base.prototype);
+ function Base() { }
function fBase() { return "Base " + this.toString(); }
-
- Base.prototype[f] = fBase.toMethod(Base.prototype);
-
- function fDerived() {
- assertEquals("Base this is Derived", super[f]());
- var a = super[x];
- assertEquals(15, a);
- assertEquals(15, super[x]);
- assertEquals(27, this[x]);
-
- return "Derived"
- }
-
+ Base.prototype[f] = %ToMethod(fBase, Base.prototype);
Base.prototype[x] = 15;
Base.prototype.toString = function() { return "this is Base"; };
- Derived.prototype.toString = function() { return "this is Derived"; };
- Derived.prototype[x] = 27;
- Derived.prototype[f] = fDerived.toMethod(Derived.prototype);
+
+ function Derived() {
+ this[derivedDataProperty] = "xxx";
+ }
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ toString() { return "this is Derived"; },
+ 1: 27,
+ 3() {
+ assertEquals("Base this is Derived", super[f]());
+ var a = super[x];
+ assertEquals(15, a);
+ assertEquals(15, super[x]);
+ assertEquals(27, this[x]);
+ return "Derived";
+ }
+ };
assertEquals("Base this is Base", new Base()[f]());
assertEquals("Derived", new Derived()[f]());
@@ -108,11 +113,17 @@
(function TestSuperKeywordNonMethod() {
- function f() {
- super.unknown();
+ 'use strict';
+
+ class C {
+ f() {
+ super.unknown();
+ }
}
- assertThrows(f, ReferenceError);
+ assertThrows(function() {
+ new C().f();
+ }, TypeError);
}());
@@ -133,15 +144,16 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 'derived'
+ _x: 'derived',
+ testGetter() {
+ return super.x;
+ },
+ testGetterStrict() {
+ 'use strict';
+ return super.x;
+ }
};
- Derived.prototype.testGetter = function() {
- return super.x;
- }.toMethod(Derived.prototype);
- Derived.prototype.testGetterStrict = function() {
- 'use strict';
- return super.x;
- }.toMethod(Derived.prototype);
+
derived = new Derived();
assertEquals('derived', derived.testGetter());
derived = new Derived();
@@ -167,44 +179,45 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 'derived'
+ _x: 'derived',
+ testGetter() {
+ return super[x];
+ },
+ testGetterStrict() {
+ 'use strict';
+ return super[x];
+ },
+ testGetterWithToString() {
+ var toStringCalled;
+ var o = { toString: function() {
+ toStringCalled++;
+ return 'x';
+ } };
+
+ toStringCalled = 0;
+ assertEquals('derived', super[o]);
+ assertEquals(1, toStringCalled);
+
+ var eToThrow = new Error();
+ var oThrowsInToString = { toString: function() {
+ throw eToThrow;
+ } };
+
+ var ex = null;
+ try {
+ super[oThrowsInToString];
+ } catch(e) { ex = e }
+ assertEquals(eToThrow, ex);
+
+ var oReturnsNumericString = { toString: function() {
+ return "1";
+ } };
+
+ assertEquals(undefined, super[oReturnsNumericString]);
+ assertEquals(undefined, super[1]);
+ }
};
- Derived.prototype.testGetter = function() {
- return super[x];
- }.toMethod(Derived.prototype);
- Derived.prototype.testGetterStrict = function() {
- 'use strict';
- return super[x];
- }.toMethod(Derived.prototype);
- Derived.prototype.testGetterWithToString = function() {
- var toStringCalled;
- var o = { toString: function() {
- toStringCalled++;
- return 'x';
- } };
-
- toStringCalled = 0;
- assertEquals('derived', super[o]);
- assertEquals(1, toStringCalled);
-
- var eToThrow = new Error();
- var oThrowsInToString = { toString: function() {
- throw eToThrow;
- } };
-
- var ex = null;
- try {
- super[oThrowsInToString];
- } catch(e) { ex = e }
- assertEquals(eToThrow, ex);
-
- var oReturnsNumericString = { toString: function() {
- return "1";
- } };
-
- assertEquals(undefined, super[oReturnsNumericString]);
- assertEquals(undefined, super[1]);
- }.toMethod(Derived.prototype);
+
derived = new Derived();
assertEquals('derived', derived.testGetter());
derived = new Derived();
@@ -233,45 +246,51 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 'derived'
+ _x: 'derived',
+ testGetter() {
+ return super[x];
+ },
+ testGetterStrict() {
+ 'use strict';
+ return super[x];
+ },
+ testGetterWithToString() {
+ var toStringCalled;
+ var o = {
+ toString: function() {
+ toStringCalled++;
+ return '42';
+ }
+ };
+
+ toStringCalled = 0;
+ assertEquals('derived', super[o]);
+ assertEquals(1, toStringCalled);
+
+ var eToThrow = new Error();
+ var oThrowsInToString = {
+ toString: function() {
+ throw eToThrow;
+ }
+ };
+
+ var ex = null;
+ try {
+ super[oThrowsInToString];
+ } catch(e) { ex = e }
+ assertEquals(eToThrow, ex);
+
+ var oReturnsNumericString = {
+ toString: function() {
+ return "42";
+ }
+ };
+
+ assertEquals('derived', super[oReturnsNumericString]);
+ assertEquals('derived', super[42]);
+ }
};
- Derived.prototype.testGetter = function() {
- return super[x];
- }.toMethod(Derived.prototype);
- Derived.prototype.testGetterStrict = function() {
- 'use strict';
- return super[x];
- }.toMethod(Derived.prototype);
-
- Derived.prototype.testGetterWithToString = function() {
- var toStringCalled;
- var o = { toString: function() {
- toStringCalled++;
- return '42';
- } };
-
- toStringCalled = 0;
- assertEquals('derived', super[o]);
- assertEquals(1, toStringCalled);
-
- var eToThrow = new Error();
- var oThrowsInToString = { toString: function() {
- throw eToThrow;
- } };
-
- var ex = null;
- try {
- super[oThrowsInToString];
- } catch(e) { ex = e }
- assertEquals(eToThrow, ex);
-
- var oReturnsNumericString = { toString: function() {
- return "42";
- } };
-
- assertEquals('derived', super[oReturnsNumericString]);
- assertEquals('derived', super[42]);
- }.toMethod(Derived.prototype);
+
derived = new Derived();
assertEquals('derived', derived.testGetter());
derived = new Derived();
@@ -299,22 +318,24 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 'derived'
+ _x: 'derived',
+ testSetter() {
+ assertEquals('foobar', super.x = 'foobar');
+ assertEquals('foobarabc', super.x += 'abc');
+ },
+ testSetterStrict() {
+ 'use strict';
+ assertEquals('foobar', super.x = 'foobar');
+ assertEquals('foobarabc', super.x += 'abc');
+ }
};
- Derived.prototype.testSetter = function() {
- assertEquals('foobar', super.x = 'foobar');
- assertEquals('foobarabc', super.x += 'abc');
- }.toMethod(Derived.prototype);
+
var d = new Derived();
d.testSetter();
assertEquals('base', Base.prototype._x);
assertEquals('foobarabc', d._x);
d._x = '';
- Derived.prototype.testSetterStrict = function() {
- 'use strict';
- assertEquals('foobar', super.x = 'foobar');
- assertEquals('foobarabc', super.x += 'abc');
- }.toMethod(Derived.prototype);
+
d.testSetterStrict();
assertEquals('base', Base.prototype._x);
assertEquals('foobarabc', d._x);
@@ -339,51 +360,56 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 'derived'
+ _x: 'derived',
+ testSetter() {
+ assertEquals('foobar', super[x] = 'foobar');
+ assertEquals('foobarabc', super[x] += 'abc');
+ },
+ testSetterStrict() {
+ 'use strict';
+ assertEquals('foobar', super[x] = 'foobar');
+ assertEquals('foobarabc', super[x] += 'abc');
+ },
+ testSetterWithToString() {
+ var toStringCalled;
+ var o = {
+ toString: function() {
+ toStringCalled++;
+ return x;
+ }
+ };
+
+ toStringCalled = 0;
+ super[o] = 'set';
+ assertEquals(1, toStringCalled);
+ assertEquals('set', this._x);
+
+ var eToThrow = new Error();
+ var oThrowsInToString = {
+ toString: function() {
+ throw eToThrow;
+ }
+ };
+
+ var ex = null;
+ try {
+ super[oThrowsInToString] = 'xyz';
+ } catch(e) { ex = e }
+ assertEquals(eToThrow, ex);
+ assertEquals('set', this._x);
+ }
};
- Derived.prototype.testSetter = function() {
- assertEquals('foobar', super[x] = 'foobar');
- assertEquals('foobarabc', super[x] += 'abc');
- }.toMethod(Derived.prototype);
+
var d = new Derived();
d.testSetter();
assertEquals('base', Base.prototype._x);
assertEquals('foobarabc', d._x);
d._x = '';
- Derived.prototype.testSetterStrict = function() {
- 'use strict';
- assertEquals('foobar', super[x] = 'foobar');
- assertEquals('foobarabc', super[x] += 'abc');
- }.toMethod(Derived.prototype);
+
d.testSetterStrict();
assertEquals('base', Base.prototype._x);
assertEquals('foobarabc', d._x);
-
- Derived.prototype.testSetterWithToString = function() {
- var toStringCalled;
- var o = { toString: function() {
- toStringCalled++;
- return x;
- } };
-
- toStringCalled = 0;
- super[o] = 'set';
- assertEquals(1, toStringCalled);
- assertEquals('set', this._x);
-
- var eToThrow = new Error();
- var oThrowsInToString = { toString: function() {
- throw eToThrow;
- } };
-
- var ex = null;
- try {
- super[oThrowsInToString] = 'xyz';
- } catch(e) { ex = e }
- assertEquals(eToThrow, ex);
- assertEquals('set', this._x);
- }.toMethod(Derived.prototype);
d = new Derived();
d.testSetterWithToString();
}());
@@ -408,61 +434,67 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 'derived'
+ _x: 'derived',
+ testSetter() {
+ assertEquals('foobar', super[x] = 'foobar');
+ assertEquals('foobarabc', super[x] += 'abc');
+ },
+ testSetterStrict() {
+ 'use strict';
+ assertEquals('foobar', super[x] = 'foobar');
+ assertEquals('foobarabc', super[x] += 'abc');
+ },
+ testSetterWithToString() {
+ var toStringCalled;
+ var o = {
+ toString: function() {
+ toStringCalled++;
+ return 'x';
+ }
+ };
+
+ toStringCalled = 0;
+ super[o] = 'set';
+ assertEquals(1, toStringCalled);
+ assertEquals('set', this._x);
+
+ var eToThrow = new Error();
+ var oThrowsInToString = {
+ toString: function() {
+ throw eToThrow;
+ }
+ };
+
+ var ex = null;
+ try {
+ super[oThrowsInToString] = 'xyz';
+ } catch(e) { ex = e }
+ assertEquals(eToThrow, ex);
+ assertEquals('set', this._x);
+
+ var oReturnsNumericString = {
+ toString: function() {
+ return "1";
+ }
+ };
+
+ assertEquals('abc', super[oReturnsNumericString] = 'abc');
+
+ assertEquals('set', this._x);
+
+ assertEquals(10, super[1] = 10);
+ }
};
- Derived.prototype.testSetter = function() {
- assertEquals('foobar', super[x] = 'foobar');
- assertEquals('foobarabc', super[x] += 'abc');
- }.toMethod(Derived.prototype);
+
var d = new Derived();
d.testSetter();
assertEquals('base', Base.prototype._x);
assertEquals('foobarabc', d._x);
d._x = '';
- Derived.prototype.testSetterStrict = function() {
- 'use strict';
- assertEquals('foobar', super[x] = 'foobar');
- assertEquals('foobarabc', super[x] += 'abc');
- }.toMethod(Derived.prototype);
d.testSetterStrict();
assertEquals('base', Base.prototype._x);
assertEquals('foobarabc', d._x);
-
- Derived.prototype.testSetterWithToString = function() {
- var toStringCalled;
- var o = { toString: function() {
- toStringCalled++;
- return 'x';
- } };
-
- toStringCalled = 0;
- super[o] = 'set';
- assertEquals(1, toStringCalled);
- assertEquals('set', this._x);
-
- var eToThrow = new Error();
- var oThrowsInToString = { toString: function() {
- throw eToThrow;
- } };
-
- var ex = null;
- try {
- super[oThrowsInToString] = 'xyz';
- } catch(e) { ex = e }
- assertEquals(eToThrow, ex);
- assertEquals('set', this._x);
-
- var oReturnsNumericString = { toString: function() {
- return "1";
- } };
-
- assertEquals('abc', super[oReturnsNumericString] = 'abc');
-
- assertEquals('set', this._x);
-
- assertEquals(10, super[1] = 10);
- }.toMethod(Derived.prototype);
d = new Derived();
d.testSetterWithToString();
}());
@@ -479,15 +511,14 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
+ testSetter() {
+ assertEquals('x from Base', super.x);
+ super.x = 'data property';
+ assertEquals('x from Base', super.x);
+ assertEquals('data property', this.x);
+ }
};
- Derived.prototype.testSetter = function() {
- assertEquals('x from Base', super.x);
- super.x = 'data property';
- assertEquals('x from Base', super.x);
- assertEquals('data property', this.x);
- }.toMethod(Derived.prototype);
-
new Derived().testSetter();
}());
@@ -504,15 +535,14 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
+ testSetter() {
+ assertEquals('x from Base', super[x]);
+ super[x] = 'data property';
+ assertEquals('x from Base', super[x]);
+ assertEquals('data property', this[x]);
+ }
};
- Derived.prototype.testSetter = function() {
- assertEquals('x from Base', super[x]);
- super[x] = 'data property';
- assertEquals('x from Base', super[x]);
- assertEquals('data property', this[x]);
- }.toMethod(Derived.prototype);
-
new Derived().testSetter();
}());
@@ -529,15 +559,14 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
+ testSetter() {
+ assertEquals('x from Base', super[x]);
+ super[x] = 'data property';
+ assertEquals('x from Base', super[x]);
+ assertEquals('data property', this[x]);
+ }
};
- Derived.prototype.testSetter = function() {
- assertEquals('x from Base', super[x]);
- super[x] = 'data property';
- assertEquals('x from Base', super[x]);
- assertEquals('data property', this[x]);
- }.toMethod(Derived.prototype);
-
new Derived().testSetter();
}());
@@ -562,73 +591,74 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- };
- Derived.prototype.testSetter = function() {
- setCalled = 0;
- getCalled = 0;
- assertEquals('object', typeof this);
- assertTrue(this instanceof Number)
- assertEquals(42, this.valueOf());
- assertEquals(1, super.x);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- assertEquals(5, super.x = 5);
- assertEquals(1, getCalled);
- assertEquals(1, setCalled);
-
- assertEquals(6, super.x += 5);
- assertEquals(2, getCalled);
- assertEquals(2, setCalled);
-
- super.newProperty = 15;
- assertEquals(15, this.newProperty);
- assertEquals(undefined, super.newProperty);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.testSetterStrict = function() {
- 'use strict';
- getCalled = 0;
- setCalled = 0;
- assertTrue(42 === this);
-
- assertEquals(1, super.x);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- assertEquals(5, super.x = 5);
- assertEquals(1, getCalled);
- assertEquals(1, setCalled);
-
- assertEquals(6, super.x += 5);
- assertEquals(2, getCalled);
- assertEquals(2, setCalled);
-
- var ex;
- try {
+ testSetter() {
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals('object', typeof this);
+ assertInstanceof(this, Number)
+ assertEquals(42, this.valueOf());
+ assertEquals(1, super.x);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ assertEquals(5, super.x = 5);
+ assertEquals(1, getCalled);
+ assertEquals(1, setCalled);
+
+ assertEquals(6, super.x += 5);
+ assertEquals(2, getCalled);
+ assertEquals(2, setCalled);
+
super.newProperty = 15;
- } catch (e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- }.toMethod(Derived.prototype);
+ assertEquals(15, this.newProperty);
+ assertEquals(undefined, super.newProperty);
+ },
+ testSetterStrict() {
+ 'use strict';
+ getCalled = 0;
+ setCalled = 0;
+ assertTrue(42 === this);
+
+ assertEquals(1, super.x);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ assertEquals(5, super.x = 5);
+ assertEquals(1, getCalled);
+ assertEquals(1, setCalled);
+
+ assertEquals(6, super.x += 5);
+ assertEquals(2, getCalled);
+ assertEquals(2, setCalled);
+
+ var ex;
+ try {
+ super.newProperty = 15;
+ } catch (e) { ex = e; }
+ assertInstanceof(ex, TypeError);
+ }
+ }
Derived.prototype.testSetter.call(42);
Derived.prototype.testSetterStrict.call(42);
function DerivedFromString() {}
- DerivedFromString.prototype = Object.create(String.prototype);
-
- function f() {
- 'use strict';
- assertTrue(42 === this);
- assertEquals(String.prototype.toString, super.toString);
- var ex;
- try {
- super.toString();
- } catch(e) { ex = e; }
-
- assertTrue(ex instanceof TypeError);
- }
- f.toMethod(DerivedFromString.prototype).call(42);
+ DerivedFromString.prototype = {
+ __proto__: String.prototype,
+ f() {
+ 'use strict';
+ assertTrue(42 === this);
+ assertEquals(String.prototype.toString, super.toString);
+ var ex;
+ try {
+ super.toString();
+ } catch(e) { ex = e; }
+
+ assertInstanceof(ex, TypeError);
+ }
+ };
+
+ DerivedFromString.prototype.f.call(42);
}());
@@ -655,73 +685,73 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- };
- Derived.prototype.testSetter = function() {
- setCalled = 0;
- getCalled = 0;
- assertEquals('object', typeof this);
- assertTrue(this instanceof Number)
- assertEquals(42, this.valueOf());
- assertEquals(1, super[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- assertEquals(5, super[x] = 5);
- assertEquals(1, getCalled);
- assertEquals(1, setCalled);
-
- assertEquals(6, super[x] += 5);
- assertEquals(2, getCalled);
- assertEquals(2, setCalled);
-
- super[newProperty] = 15;
- assertEquals(15, this[newProperty]);
- assertEquals(undefined, super[newProperty]);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.testSetterStrict = function() {
- 'use strict';
- getCalled = 0;
- setCalled = 0;
- assertTrue(42 === this);
-
- assertEquals(1, super[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- assertEquals(5, super[x] = 5);
- assertEquals(1, getCalled);
- assertEquals(1, setCalled);
-
- assertEquals(6, super[x] += 5);
- assertEquals(2, getCalled);
- assertEquals(2, setCalled);
-
- var ex;
- try {
+ testSetter() {
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals('object', typeof this);
+ assertInstanceof(this, Number)
+ assertEquals(42, this.valueOf());
+ assertEquals(1, super[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ assertEquals(5, super[x] = 5);
+ assertEquals(1, getCalled);
+ assertEquals(1, setCalled);
+
+ assertEquals(6, super[x] += 5);
+ assertEquals(2, getCalled);
+ assertEquals(2, setCalled);
+
super[newProperty] = 15;
- } catch (e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- }.toMethod(Derived.prototype);
+ assertEquals(15, this[newProperty]);
+ assertEquals(undefined, super[newProperty]);
+ },
+ testSetterStrict() {
+ 'use strict';
+ getCalled = 0;
+ setCalled = 0;
+ assertTrue(42 === this);
+
+ assertEquals(1, super[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ assertEquals(5, super[x] = 5);
+ assertEquals(1, getCalled);
+ assertEquals(1, setCalled);
+
+ assertEquals(6, super[x] += 5);
+ assertEquals(2, getCalled);
+ assertEquals(2, setCalled);
+
+ var ex;
+ try {
+ super[newProperty] = 15;
+ } catch (e) { ex = e; }
+ assertInstanceof(ex,TypeError);
+ }
+ };
Derived.prototype.testSetter.call(42);
Derived.prototype.testSetterStrict.call(42);
function DerivedFromString() {}
- DerivedFromString.prototype = Object.create(String.prototype);
-
- function f() {
- 'use strict';
- assertTrue(42 === this);
- assertEquals(String.prototype.toString, super[toString]);
- var ex;
- try {
- super[toString]();
- } catch(e) { ex = e; }
-
- assertTrue(ex instanceof TypeError);
- }
- f.toMethod(DerivedFromString.prototype).call(42);
+ DerivedFromString.prototype = {
+ __proto__: String.prototype,
+ f() {
+ 'use strict';
+ assertTrue(42 === this);
+ assertEquals(String.prototype.toString, super[toString]);
+ var ex;
+ try {
+ super[toString]();
+ } catch(e) { ex = e; }
+
+ assertInstanceof(ex, TypeError);
+ }
+ };
+ DerivedFromString.prototype.f.call(42);
}());
@@ -750,54 +780,53 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- };
- Derived.prototype.testSetter = function() {
- setCalled = 0;
- getCalled = 0;
- assertEquals('object', typeof this);
- assertTrue(this instanceof Number)
- assertEquals(42, this.valueOf());
- assertEquals(1, super[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- assertEquals(5, super[x] = 5);
- assertEquals(1, getCalled);
- assertEquals(1, setCalled);
-
- assertEquals(6, super[x] += 5);
- assertEquals(2, getCalled);
- assertEquals(2, setCalled);
-
- super[newProperty] = 15;
- assertEquals(15, this[newProperty]);
- assertEquals(undefined, super[newProperty]);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.testSetterStrict = function() {
- 'use strict';
- getCalled = 0;
- setCalled = 0;
- assertTrue(42 === this);
-
- assertEquals(1, super[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- assertEquals(5, super[x] = 5);
- assertEquals(1, getCalled);
- assertEquals(1, setCalled);
-
- assertEquals(6, super[x] += 5);
- assertEquals(2, getCalled);
- assertEquals(2, setCalled);
-
- var ex;
- try {
+ testSetter() {
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals('object', typeof this);
+ assertInstanceof(this, Number)
+ assertEquals(42, this.valueOf());
+ assertEquals(1, super[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ assertEquals(5, super[x] = 5);
+ assertEquals(1, getCalled);
+ assertEquals(1, setCalled);
+
+ assertEquals(6, super[x] += 5);
+ assertEquals(2, getCalled);
+ assertEquals(2, setCalled);
+
super[newProperty] = 15;
- } catch (e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- }.toMethod(Derived.prototype);
+ assertEquals(15, this[newProperty]);
+ assertEquals(undefined, super[newProperty]);
+ },
+ testSetterStrict() {
+ 'use strict';
+ getCalled = 0;
+ setCalled = 0;
+ assertTrue(42 === this);
+
+ assertEquals(1, super[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ assertEquals(5, super[x] = 5);
+ assertEquals(1, getCalled);
+ assertEquals(1, setCalled);
+
+ assertEquals(6, super[x] += 5);
+ assertEquals(2, getCalled);
+ assertEquals(2, setCalled);
+
+ var ex;
+ try {
+ super[newProperty] = 15;
+ } catch (e) { ex = e; }
+ assertInstanceof(ex, TypeError);
+ }
+ };
Derived.prototype.testSetter.call(42);
Derived.prototype.testSetterStrict.call(42);
@@ -807,28 +836,28 @@
(function TestKeyedNumericSetterOnExotics() {
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__: Base.prototype };
-
- Derived.prototype.callSetterOnArray = function() {
- super[42] = 1;
- }.toMethod(Derived.prototype);
-
- Derived.prototype.callStrictSetterOnString = function() {
- 'use strict';
- assertEquals('string', typeof this);
- assertTrue('abcdef' === this);
- var ex = null;
- try {
- super[5] = 'q';
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
-
- ex = null;
- try {
- super[1024] = 'q';
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ callSetterOnArray() {
+ super[42] = 1;
+ },
+ callStrictSetterOnString() {
+ 'use strict';
+ assertEquals('string', typeof this);
+ assertTrue('abcdef' === this);
+ var ex = null;
+ try {
+ super[5] = 'q';
+ } catch(e) { ex = e; }
+ assertInstanceof(ex, TypeError);
+
+ ex = null;
+ try {
+ super[1024] = 'q';
+ } catch(e) { ex = e; }
+ assertInstanceof(ex, TypeError);
+ }
+ };
var x = [];
assertEquals(0, x.length);
@@ -844,23 +873,25 @@
(function TestSetterUndefinedProperties() {
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__ : Base.prototype };
- Derived.prototype.mSloppy = function () {
- assertEquals(undefined, super.x);
- assertEquals(undefined, this.x);
- super.x = 10;
- assertEquals(10, this.x);
- assertEquals(undefined, super.x);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function () {
- 'use strict';
- assertEquals(undefined, super.x);
- assertEquals(undefined, this.x);
- super.x = 10;
- assertEquals(10, this.x);
- assertEquals(undefined, super.x);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mSloppy() {
+ assertEquals(undefined, super.x);
+ assertEquals(undefined, this.x);
+ super.x = 10;
+ assertEquals(10, this.x);
+ assertEquals(undefined, super.x);
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(undefined, super.x);
+ assertEquals(undefined, this.x);
+ super.x = 10;
+ assertEquals(10, this.x);
+ assertEquals(undefined, super.x);
+ }
+ };
+
var d = new Derived();
d.mSloppy();
assertEquals(10, d.x);
@@ -874,23 +905,24 @@
var x = 'x';
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__ : Base.prototype };
- Derived.prototype.mSloppy = function () {
- assertEquals(undefined, super[x]);
- assertEquals(undefined, this[x]);
- super[x] = 10;
- assertEquals(10, this[x]);
- assertEquals(undefined, super[x]);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function () {
- 'use strict';
- assertEquals(undefined, super[x]);
- assertEquals(undefined, this[x]);
- super[x] = 10;
- assertEquals(10, this[x]);
- assertEquals(undefined, super[x]);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mSloppy() {
+ assertEquals(undefined, super[x]);
+ assertEquals(undefined, this[x]);
+ super[x] = 10;
+ assertEquals(10, this[x]);
+ assertEquals(undefined, super[x]);
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(undefined, super[x]);
+ assertEquals(undefined, this[x]);
+ super[x] = 10;
+ assertEquals(10, this[x]);
+ assertEquals(undefined, super[x]);
+ }
+ };
var d = new Derived();
d.mSloppy();
assertEquals(10, d.x);
@@ -904,23 +936,24 @@
var x = 42;
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__ : Base.prototype };
- Derived.prototype.mSloppy = function () {
- assertEquals(undefined, super[x]);
- assertEquals(undefined, this[x]);
- super[x] = 10;
- assertEquals(10, this[x]);
- assertEquals(undefined, super[x]);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function () {
- 'use strict';
- assertEquals(undefined, super[x]);
- assertEquals(undefined, this[x]);
- super[x] = 10;
- assertEquals(10, this[x]);
- assertEquals(undefined, super[x]);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mSloppy() {
+ assertEquals(undefined, super[x]);
+ assertEquals(undefined, this[x]);
+ super[x] = 10;
+ assertEquals(10, this[x]);
+ assertEquals(undefined, super[x]);
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(undefined, super[x]);
+ assertEquals(undefined, this[x]);
+ super[x] = 10;
+ assertEquals(10, this[x]);
+ assertEquals(undefined, super[x]);
+ }
+ };
var d = new Derived();
d.mSloppy();
assertEquals(10, d[x]);
@@ -930,53 +963,180 @@
}());
-(function TestSetterCreatingOwnProperties() {
+(function TestSetterCreatingOwnPropertiesReconfigurable() {
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__ : Base.prototype };
- var setterCalled;
-
- Derived.prototype.mSloppy = function() {
- assertEquals(42, this.ownReadOnly);
- super.ownReadOnly = 55;
- assertEquals(42, this.ownReadOnly);
-
- assertEquals(15, this.ownReadonlyAccessor);
- super.ownReadonlyAccessor = 55;
- assertEquals(15, this.ownReadonlyAccessor);
-
- setterCalled = 0;
- super.ownSetter = 42;
- assertEquals(1, setterCalled);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function() {
- 'use strict';
- assertEquals(42, this.ownReadOnly);
- var ex;
- try {
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mSloppy() {
+ assertEquals(42, this.ownReadOnly);
+ super.ownReadOnly = 55;
+ assertEquals(55, this.ownReadOnly);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly');
+ assertEquals(55, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty('ownReadOnly'));
+
+ assertEquals(15, this.ownReadonlyAccessor);
+ super.ownReadonlyAccessor = 25;
+ assertEquals(25, this.ownReadonlyAccessor);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownReadonlyAccessor');
+ assertEquals(25, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor'));
+
+ super.ownSetter = 35;
+ assertEquals(35, this.ownSetter);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownSetter');
+ assertEquals(35, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty('ownSetter'));
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(42, this.ownReadOnly);
super.ownReadOnly = 55;
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(42, this.ownReadOnly);
-
- assertEquals(15, this.ownReadonlyAccessor);
- ex = null;
- try {
- super.ownReadonlyAccessor = 55;
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(15, this.ownReadonlyAccessor);
-
- setterCalled = 0;
- super.ownSetter = 42;
- assertEquals(1, setterCalled);
- }.toMethod(Derived.prototype);
+ assertEquals(55, this.ownReadOnly);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly');
+ assertEquals(55, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty('ownReadOnly'));
+
+ assertEquals(15, this.ownReadonlyAccessor);
+ super.ownReadonlyAccessor = 25;
+ assertEquals(25, this.ownReadonlyAccessor);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownReadonlyAccessor');
+ assertEquals(25, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor'));
+
+ super.ownSetter = 35;
+ assertEquals(35, this.ownSetter);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownSetter');
+ assertEquals(35, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty('ownSetter'));
+ },
+ };
+
+ var d = new Derived();
+ Object.defineProperty(d, 'ownReadOnly', {
+ value: 42,
+ writable: false,
+ configurable: true
+ });
+ Object.defineProperty(d, 'ownSetter', {
+ set: function() { assertUnreachable(); },
+ configurable: true
+ });
+ Object.defineProperty(d, 'ownReadonlyAccessor', {
+ get: function() { return 15; },
+ configurable: true
+ });
+
+ d.mSloppy();
+
+ var d = new Derived();
+ Object.defineProperty(d, 'ownReadOnly', {
+ value: 42,
+ writable: false,
+ configurable: true
+ });
+ Object.defineProperty(d, 'ownSetter', {
+ set: function() { assertUnreachable(); },
+ configurable: true
+ });
+ Object.defineProperty(d, 'ownReadonlyAccessor', {
+ get: function() { return 15; },
+ configurable: true
+ });
+ d.mStrict();
+}());
+
+
+(function TestSetterCreatingOwnPropertiesNonConfigurable() {
+ function Base() {}
+ function Derived() {}
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mSloppy() {
+ assertEquals(42, this.ownReadOnly);
+ super.ownReadOnly = 55;
+ assertEquals(42, this.ownReadOnly);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly');
+ assertEquals(42, descr.value);
+ assertFalse(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty('ownReadOnly'));
+
+ assertEquals(15, this.ownReadonlyAccessor);
+ super.ownReadonlyAccessor = 25;
+ assertEquals(15, this.ownReadonlyAccessor);
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownReadonlyAccessor');
+ assertFalse(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor'));
+
+ super.ownSetter = 35;
+ var descr = Object.getOwnPropertyDescriptor(this, 'ownSetter');
+ assertFalse(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(Base.prototype.hasOwnProperty('ownSetter'));
+ },
+ mStrict() {
+ 'use strict';
+ var ex;
+ assertEquals(42, this.ownReadOnly);
+ try {
+ super.ownReadOnly = 55;
+ } catch (e) {
+ ex = e;
+ }
+ assertInstanceof(ex, TypeError);
+ assertEquals(
+ "Cannot assign to read only property 'ownReadOnly' of #<Base>",
+ ex.message);
+ assertEquals(42, this.ownReadOnly);
+
+ ex = null;
+ assertEquals(15, this.ownReadonlyAccessor);
+ try {
+ super.ownReadonlyAccessor = 25;
+ } catch (e) {
+ ex = e;
+ }
+ assertInstanceof(ex, TypeError);
+ assertEquals('Cannot redefine property: ownReadonlyAccessor', ex.message);
+ assertEquals(15, this.ownReadonlyAccessor);
+
+ ex = null;
+ try {
+ super.ownSetter = 35;
+ } catch (e) {
+ ex = e;
+ }
+ assertInstanceof(ex, TypeError);
+ assertEquals('Cannot redefine property: ownSetter', ex.message);
+ }
+ };
var d = new Derived();
Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false });
Object.defineProperty(d, 'ownSetter',
- { set : function() { setterCalled++; } });
+ { set : function() { assertUnreachable(); } });
Object.defineProperty(d, 'ownReadonlyAccessor',
{ get : function() { return 15; }});
d.mSloppy();
@@ -1006,156 +1166,233 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
+ testIter() {
+ setCalled = 0;
+ getCalled = 0;
+ for (super.x in [1,2,3]) {}
+ assertEquals(0, getCalled);
+ assertEquals(3, setCalled);
+ assertEquals(["0", "1", "2"], this.x_);
+ },
+ testIterKeyed() {
+ setCalled = 0;
+ getCalled = 0;
+ for (super[x] in [1,2,3]) {}
+ assertEquals(0, getCalled);
+ assertEquals(3, setCalled);
+ assertEquals(["0","1","2"], this.x_);
+
+ this.x_ = [];
+ setCalled = 0;
+ getCalled = 0;
+ var toStringCalled = 0;
+ var o = {toString: function () { toStringCalled++; return x }};
+ for (super[o] in [1,2,3]) {}
+ assertEquals(0, getCalled);
+ assertEquals(3, setCalled);
+ assertEquals(3, toStringCalled);
+ assertEquals(["0","1","2"], this.x_);
+ }
};
- Derived.prototype.testIter = function() {
- setCalled = 0;
- getCalled = 0;
- for (super.x in [1,2,3]) {}
- assertEquals(0, getCalled);
- assertEquals(3, setCalled);
- assertEquals(["0","1","2"], this.x_);
- }.toMethod(Derived.prototype);
-
new Derived().testIter();
var x = 'x';
- Derived.prototype.testIterKeyed = function() {
- setCalled = 0;
- getCalled = 0;
- for (super[x] in [1,2,3]) {}
- assertEquals(0, getCalled);
- assertEquals(3, setCalled);
- assertEquals(["0","1","2"], this.x_);
-
- this.x_ = [];
- setCalled = 0;
- getCalled = 0;
- var toStringCalled = 0;
- var o = {toString: function () { toStringCalled++; return x }};
- for (super[o] in [1,2,3]) {}
- assertEquals(0, getCalled);
- assertEquals(3, setCalled);
- assertEquals(3, toStringCalled);
- assertEquals(["0","1","2"], this.x_);
- }.toMethod(Derived.prototype);
new Derived().testIterKeyed();
}());
-(function TestKeyedSetterCreatingOwnProperties() {
- var ownReadOnly = 'ownReadOnly';
- var ownReadonlyAccessor = 'ownReadonlyAccessor';
- var ownSetter = 'ownSetter';
+function TestKeyedSetterCreatingOwnPropertiesReconfigurable(ownReadOnly,
+ ownReadonlyAccessor, ownSetter) {
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__ : Base.prototype };
- var setterCalled;
-
- Derived.prototype.mSloppy = function() {
- assertEquals(42, this[ownReadOnly]);
- super[ownReadOnly] = 55;
- assertEquals(42, this[ownReadOnly]);
-
- assertEquals(15, this[ownReadonlyAccessor]);
- super[ownReadonlyAccessor] = 55;
- assertEquals(15, this[ownReadonlyAccessor]);
-
- setterCalled = 0;
- super[ownSetter] = 42;
- assertEquals(1, setterCalled);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function() {
- 'use strict';
- assertEquals(42, this[ownReadOnly]);
- var ex;
- try {
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mSloppy() {
+ assertEquals(42, this[ownReadOnly]);
super[ownReadOnly] = 55;
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(42, this[ownReadOnly]);
-
- assertEquals(15, this[ownReadonlyAccessor]);
- ex = null;
- try {
- super[ownReadonlyAccessor] = 55;
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(15, this[ownReadonlyAccessor]);
-
- setterCalled = 0;
- super[ownSetter] = 42;
- assertEquals(1, setterCalled);
- }.toMethod(Derived.prototype);
+ assertEquals(55, this[ownReadOnly]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly);
+ assertEquals(55, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty(ownReadOnly));
+
+ assertEquals(15, this[ownReadonlyAccessor]);
+ super[ownReadonlyAccessor] = 25;
+ assertEquals(25, this[ownReadonlyAccessor]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownReadonlyAccessor);
+ assertEquals(25, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor));
+
+ super[ownSetter] = 35;
+ assertEquals(35, this[ownSetter]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownSetter);
+ assertEquals(35, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty(ownSetter));
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(42, this[ownReadOnly]);
+ super[ownReadOnly] = 55;
+ assertEquals(55, this[ownReadOnly]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly);
+ assertEquals(55, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty(ownReadOnly));
+
+ assertEquals(15, this[ownReadonlyAccessor]);
+ super[ownReadonlyAccessor] = 25;
+ assertEquals(25, this[ownReadonlyAccessor]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownReadonlyAccessor);
+ assertEquals(25, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor));
+
+ super[ownSetter] = 35;
+ assertEquals(35, this[ownSetter]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownSetter);
+ assertEquals(35, descr.value);
+ assertTrue(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertTrue(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty(ownSetter));
+ },
+ };
var d = new Derived();
- Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false });
- Object.defineProperty(d, 'ownSetter',
- { set : function() { setterCalled++; } });
- Object.defineProperty(d, 'ownReadonlyAccessor',
- { get : function() { return 15; }});
+ Object.defineProperty(d, ownReadOnly, {
+ value: 42,
+ writable: false,
+ configurable: true
+ });
+ Object.defineProperty(d, ownSetter, {
+ set: function() { assertUnreachable(); },
+ configurable: true
+ });
+ Object.defineProperty(d, ownReadonlyAccessor, {
+ get: function() { return 15; },
+ configurable: true
+ });
+
d.mSloppy();
+
+ var d = new Derived();
+ Object.defineProperty(d, ownReadOnly, {
+ value: 42,
+ writable: false,
+ configurable: true
+ });
+ Object.defineProperty(d, ownSetter, {
+ set: function() { assertUnreachable(); },
+ configurable: true
+ });
+ Object.defineProperty(d, ownReadonlyAccessor, {
+ get: function() { return 15; },
+ configurable: true
+ });
d.mStrict();
-}());
+}
+TestKeyedSetterCreatingOwnPropertiesReconfigurable('ownReadOnly',
+ 'ownReadonlyAccessor',
+ 'ownSetter');
+TestKeyedSetterCreatingOwnPropertiesReconfigurable(42, 43, 44);
-(function TestKeyedNumericSetterCreatingOwnProperties() {
- var ownReadOnly = 42;
- var ownReadonlyAccessor = 43;
- var ownSetter = 44;
+function TestKeyedSetterCreatingOwnPropertiesNonConfigurable(
+ ownReadOnly, ownReadonlyAccessor, ownSetter) {
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__ : Base.prototype };
- var setterCalled;
-
- Derived.prototype.mSloppy = function() {
- assertEquals(42, this[ownReadOnly]);
- super[ownReadOnly] = 55;
- assertEquals(42, this[ownReadOnly]);
-
- assertEquals(15, this[ownReadonlyAccessor]);
- super[ownReadonlyAccessor] = 55;
- assertEquals(15, this[ownReadonlyAccessor]);
-
- setterCalled = 0;
- super[ownSetter] = 42;
- assertEquals(1, setterCalled);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function() {
- 'use strict';
- assertEquals(42, this[ownReadOnly]);
- var ex;
- try {
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mSloppy() {
+ assertEquals(42, this[ownReadOnly]);
super[ownReadOnly] = 55;
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(42, this[ownReadOnly]);
-
- assertEquals(15, this[ownReadonlyAccessor]);
- ex = null;
- try {
- super[ownReadonlyAccessor] = 55;
- } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(15, this[ownReadonlyAccessor]);
-
- setterCalled = 0;
- super[ownSetter] = 42;
- assertEquals(1, setterCalled);
- }.toMethod(Derived.prototype);
+ assertEquals(42, this[ownReadOnly]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly);
+ assertEquals(42, descr.value);
+ assertFalse(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(descr.writable);
+ assertFalse(Base.prototype.hasOwnProperty(ownReadOnly));
+
+ assertEquals(15, this[ownReadonlyAccessor]);
+ super[ownReadonlyAccessor] = 25;
+ assertEquals(15, this[ownReadonlyAccessor]);
+ var descr = Object.getOwnPropertyDescriptor(this, ownReadonlyAccessor);
+ assertFalse(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor));
+
+ super[ownSetter] = 35;
+ var descr = Object.getOwnPropertyDescriptor(this, ownSetter);
+ assertFalse(descr.configurable);
+ assertFalse(descr.enumerable);
+ assertFalse(Base.prototype.hasOwnProperty(ownSetter));
+ },
+ mStrict() {
+ 'use strict';
+ var ex;
+ assertEquals(42, this[ownReadOnly]);
+ try {
+ super[ownReadOnly] = 55;
+ } catch (e) {
+ ex = e;
+ }
+ assertInstanceof(ex, TypeError);
+ assertEquals(
+ "Cannot assign to read only property '" + ownReadOnly +
+ "' of #<Base>",
+ ex.message);
+ assertEquals(42, this[ownReadOnly]);
+
+ ex = null;
+ assertEquals(15, this[ownReadonlyAccessor]);
+ try {
+ super[ownReadonlyAccessor] = 25;
+ } catch (e) {
+ ex = e;
+ }
+ assertInstanceof(ex, TypeError);
+ assertEquals('Cannot redefine property: ' + ownReadonlyAccessor,
+ ex.message);
+ assertEquals(15, this[ownReadonlyAccessor]);
+
+ ex = null;
+ try {
+ super[ownSetter] = 35;
+ } catch (e) {
+ ex = e;
+ }
+ assertInstanceof(ex, TypeError);
+ assertEquals('Cannot redefine property: ' + ownSetter, ex.message);
+ }
+ };
var d = new Derived();
Object.defineProperty(d, ownReadOnly, { value : 42, writable : false });
Object.defineProperty(d, ownSetter,
- { set : function() { setterCalled++; } });
+ { set : function() { assertUnreachable(); } });
Object.defineProperty(d, ownReadonlyAccessor,
{ get : function() { return 15; }});
d.mSloppy();
d.mStrict();
-}());
+}
+TestKeyedSetterCreatingOwnPropertiesNonConfigurable('ownReadOnly',
+ 'ownReadonlyAccessor', 'ownSetter');
+TestKeyedSetterCreatingOwnPropertiesNonConfigurable(42, 43, 44);
(function TestSetterNoProtoWalk() {
@@ -1164,62 +1401,58 @@
var getCalled;
var setCalled;
Derived.prototype = {
- __proto__ : Base.prototype,
+ __proto__: Base.prototype,
get x() { getCalled++; return 42; },
- set x(v) { setCalled++; }
+ set x(v) { setCalled++; },
+ mSloppy() {
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals(42, this.x);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ this.x = 43;
+ assertEquals(0, getCalled);
+ assertEquals(1, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ super.x = 15;
+ assertEquals(0, setCalled);
+ assertEquals(0, getCalled);
+
+ assertEquals(15, this.x);
+ assertEquals(0, getCalled);
+ assertEquals(0, setCalled);
+ },
+ mStrict() {
+ 'use strict';
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals(42, this.x);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ this.x = 43;
+ assertEquals(0, getCalled);
+ assertEquals(1, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ super.x = 15;
+ assertEquals(0, setCalled);
+ assertEquals(0, getCalled);
+
+ assertEquals(15, this.x);
+ assertEquals(0, getCalled);
+ assertEquals(0, setCalled);
+ }
};
- Derived.prototype.mSloppy = function() {
- setCalled = 0;
- getCalled = 0;
- assertEquals(42, this.x);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- this.x = 43;
- assertEquals(0, getCalled);
- assertEquals(1, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- super.x = 15;
- assertEquals(0, setCalled);
- assertEquals(0, getCalled);
-
- assertEquals(15, this.x);
- assertEquals(0, getCalled);
- assertEquals(0, setCalled);
-
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function() {
- 'use strict';
- setCalled = 0;
- getCalled = 0;
- assertEquals(42, this.x);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- this.x = 43;
- assertEquals(0, getCalled);
- assertEquals(1, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- super.x = 15;
- assertEquals(0, setCalled);
- assertEquals(0, getCalled);
-
- assertEquals(15, this.x);
- assertEquals(0, getCalled);
- assertEquals(0, setCalled);
-
- }.toMethod(Derived.prototype);
-
new Derived().mSloppy();
new Derived().mStrict();
}());
@@ -1232,62 +1465,58 @@
var getCalled;
var setCalled;
Derived.prototype = {
- __proto__ : Base.prototype,
+ __proto__: Base.prototype,
get x() { getCalled++; return 42; },
- set x(v) { setCalled++; }
+ set x(v) { setCalled++; },
+ mSloppy() {
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals(42, this[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ this[x] = 43;
+ assertEquals(0, getCalled);
+ assertEquals(1, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ super[x] = 15;
+ assertEquals(0, setCalled);
+ assertEquals(0, getCalled);
+
+ assertEquals(15, this[x]);
+ assertEquals(0, getCalled);
+ assertEquals(0, setCalled);
+ },
+ mStrict() {
+ 'use strict';
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals(42, this[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ this[x] = 43;
+ assertEquals(0, getCalled);
+ assertEquals(1, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ super[x] = 15;
+ assertEquals(0, setCalled);
+ assertEquals(0, getCalled);
+
+ assertEquals(15, this[x]);
+ assertEquals(0, getCalled);
+ assertEquals(0, setCalled);
+ }
};
- Derived.prototype.mSloppy = function() {
- setCalled = 0;
- getCalled = 0;
- assertEquals(42, this[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- this[x] = 43;
- assertEquals(0, getCalled);
- assertEquals(1, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- super[x] = 15;
- assertEquals(0, setCalled);
- assertEquals(0, getCalled);
-
- assertEquals(15, this[x]);
- assertEquals(0, getCalled);
- assertEquals(0, setCalled);
-
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function() {
- 'use strict';
- setCalled = 0;
- getCalled = 0;
- assertEquals(42, this[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- this[x] = 43;
- assertEquals(0, getCalled);
- assertEquals(1, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- super[x] = 15;
- assertEquals(0, setCalled);
- assertEquals(0, getCalled);
-
- assertEquals(15, this[x]);
- assertEquals(0, getCalled);
- assertEquals(0, setCalled);
-
- }.toMethod(Derived.prototype);
-
new Derived().mSloppy();
new Derived().mStrict();
}());
@@ -1300,7 +1529,54 @@
var getCalled;
var setCalled;
Derived.prototype = {
- __proto__ : Base.prototype,
+ __proto__: Base.prototype,
+ mSloppy() {
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals(42, this[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ this[x] = 43;
+ assertEquals(0, getCalled);
+ assertEquals(1, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ super[x] = 15;
+ assertEquals(0, setCalled);
+ assertEquals(0, getCalled);
+
+ assertEquals(15, this[x]);
+ assertEquals(0, getCalled);
+ assertEquals(0, setCalled);
+ },
+ mStrict() {
+ 'use strict';
+ setCalled = 0;
+ getCalled = 0;
+ assertEquals(42, this[x]);
+ assertEquals(1, getCalled);
+ assertEquals(0, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ this[x] = 43;
+ assertEquals(0, getCalled);
+ assertEquals(1, setCalled);
+
+ getCalled = 0;
+ setCalled = 0;
+ super[x] = 15;
+ assertEquals(0, setCalled);
+ assertEquals(0, getCalled);
+
+ assertEquals(15, this[x]);
+ assertEquals(0, getCalled);
+ assertEquals(0, setCalled);
+ }
};
Object.defineProperty(Derived.prototype, x, {
@@ -1308,57 +1584,6 @@
set: function(v) { setCalled++; }
});
- Derived.prototype.mSloppy = function() {
- setCalled = 0;
- getCalled = 0;
- assertEquals(42, this[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- this[x] = 43;
- assertEquals(0, getCalled);
- assertEquals(1, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- super[x] = 15;
- assertEquals(0, setCalled);
- assertEquals(0, getCalled);
-
- assertEquals(15, this[x]);
- assertEquals(0, getCalled);
- assertEquals(0, setCalled);
-
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mStrict = function() {
- 'use strict';
- setCalled = 0;
- getCalled = 0;
- assertEquals(42, this[x]);
- assertEquals(1, getCalled);
- assertEquals(0, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- this[x] = 43;
- assertEquals(0, getCalled);
- assertEquals(1, setCalled);
-
- getCalled = 0;
- setCalled = 0;
- super[x] = 15;
- assertEquals(0, setCalled);
- assertEquals(0, getCalled);
-
- assertEquals(15, this[x]);
- assertEquals(0, getCalled);
- assertEquals(0, setCalled);
-
- }.toMethod(Derived.prototype);
-
new Derived().mSloppy();
new Derived().mStrict();
}());
@@ -1367,35 +1592,36 @@
(function TestSetterDoesNotReconfigure() {
function Base() {}
function Derived() {}
-
- Derived.prototype.mStrict = function (){
- 'use strict';
- super.nonEnumConfig = 5;
- var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumConfig');
- assertEquals(5, d1.value);
- assertTrue(d1.configurable);
- assertFalse(d1.enumerable);
-
- super.nonEnumNonConfig = 5;
- var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumNonConfig');
- assertEquals(5, d1.value);
- assertFalse(d1.configurable);
- assertFalse(d1.enumerable);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mSloppy = function (){
- super.nonEnumConfig = 42;
- var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumConfig');
- assertEquals(42, d1.value);
- assertTrue(d1.configurable);
- assertFalse(d1.enumerable);
-
- super.nonEnumNonConfig = 42;
- var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumNonConfig');
- assertEquals(42, d1.value);
- assertFalse(d1.configurable);
- assertFalse(d1.enumerable);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Derived.prototype,
+ mStrict(){
+ 'use strict';
+ super.nonEnumConfig = 5;
+ var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumConfig');
+ assertEquals(5, d1.value);
+ assertTrue(d1.configurable);
+ assertFalse(d1.enumerable);
+
+ super.nonEnumNonConfig = 5;
+ var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumNonConfig');
+ assertEquals(5, d1.value);
+ assertFalse(d1.configurable);
+ assertFalse(d1.enumerable);
+ },
+ mSloppy(){
+ super.nonEnumConfig = 42;
+ var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumConfig');
+ assertEquals(42, d1.value);
+ assertTrue(d1.configurable);
+ assertFalse(d1.enumerable);
+
+ super.nonEnumNonConfig = 42;
+ var d1 = Object.getOwnPropertyDescriptor(this, 'nonEnumNonConfig');
+ assertEquals(42, d1.value);
+ assertFalse(d1.configurable);
+ assertFalse(d1.enumerable);
+ }
+ };
var d = new Derived();
Object.defineProperty(d, 'nonEnumConfig',
@@ -1413,36 +1639,36 @@
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__: Base.prototype };
-
- Derived.prototype.mStrict = function (){
- 'use strict';
- super[nonEnumConfig] = 5;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
- assertEquals(5, d1.value);
- assertTrue(d1.configurable);
- assertFalse(d1.enumerable);
-
- super[nonEnumNonConfig] = 5;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
- assertEquals(5, d1.value);
- assertFalse(d1.configurable);
- assertFalse(d1.enumerable);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mSloppy = function (){
- super[nonEnumConfig] = 42;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
- assertEquals(42, d1.value);
- assertTrue(d1.configurable);
- assertFalse(d1.enumerable);
-
- super[nonEnumNonConfig] = 42;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
- assertEquals(42, d1.value);
- assertFalse(d1.configurable);
- assertFalse(d1.enumerable);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mStrict(){
+ 'use strict';
+ super[nonEnumConfig] = 5;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
+ assertEquals(5, d1.value);
+ assertTrue(d1.configurable);
+ assertFalse(d1.enumerable);
+
+ super[nonEnumNonConfig] = 5;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
+ assertEquals(5, d1.value);
+ assertFalse(d1.configurable);
+ assertFalse(d1.enumerable);
+ },
+ mSloppy(){
+ super[nonEnumConfig] = 42;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
+ assertEquals(42, d1.value);
+ assertTrue(d1.configurable);
+ assertFalse(d1.enumerable);
+
+ super[nonEnumNonConfig] = 42;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
+ assertEquals(42, d1.value);
+ assertFalse(d1.configurable);
+ assertFalse(d1.enumerable);
+ }
+ };
var d = new Derived();
Object.defineProperty(d, nonEnumConfig,
@@ -1460,36 +1686,36 @@
function Base() {}
function Derived() {}
- Derived.prototype = { __proto__: Base.prototype };
-
- Derived.prototype.mStrict = function (){
- 'use strict';
- super[nonEnumConfig] = 5;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
- assertEquals(5, d1.value);
- assertTrue(d1.configurable);
- assertFalse(d1.enumerable);
-
- super[nonEnumNonConfig] = 5;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
- assertEquals(5, d1.value);
- assertFalse(d1.configurable);
- assertFalse(d1.enumerable);
- }.toMethod(Derived.prototype);
-
- Derived.prototype.mSloppy = function (){
- super[nonEnumConfig] = 42;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
- assertEquals(42, d1.value);
- assertTrue(d1.configurable);
- assertFalse(d1.enumerable);
-
- super[nonEnumNonConfig] = 42;
- var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
- assertEquals(42, d1.value);
- assertFalse(d1.configurable);
- assertFalse(d1.enumerable);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ mStrict(){
+ 'use strict';
+ super[nonEnumConfig] = 5;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
+ assertEquals(5, d1.value);
+ assertTrue(d1.configurable);
+ assertFalse(d1.enumerable);
+
+ super[nonEnumNonConfig] = 5;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
+ assertEquals(5, d1.value);
+ assertFalse(d1.configurable);
+ assertFalse(d1.enumerable);
+ },
+ mSloppy(){
+ super[nonEnumConfig] = 42;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumConfig);
+ assertEquals(42, d1.value);
+ assertTrue(d1.configurable);
+ assertFalse(d1.enumerable);
+
+ super[nonEnumNonConfig] = 42;
+ var d1 = Object.getOwnPropertyDescriptor(this, nonEnumNonConfig);
+ assertEquals(42, d1.value);
+ assertFalse(d1.configurable);
+ assertFalse(d1.enumerable);
+ }
+ };
var d = new Derived();
Object.defineProperty(d, nonEnumConfig,
@@ -1519,32 +1745,31 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 2
+ _x: 2,
+ testCounts() {
+ assertEquals(2, this._x);
+ assertEquals(2, super.x);
+ super.x++;
+ assertEquals(3, super.x);
+ ++super.x;
+ assertEquals(4, super.x);
+ assertEquals(4, super.x++);
+ assertEquals(5, super.x);
+ assertEquals(6, ++super.x);
+ assertEquals(6, super.x);
+ assertEquals(6, this._x);
+
+ super.x--;
+ assertEquals(5, super.x);
+ --super.x;
+ assertEquals(4, super.x);
+ assertEquals(4, super.x--);
+ assertEquals(3, super.x);
+ assertEquals(2, --super.x);
+ assertEquals(2, super.x);
+ assertEquals(2, this._x);
+ }
};
-
- Derived.prototype.testCounts = function() {
- assertEquals(2, this._x);
- assertEquals(2, super.x);
- super.x++;
- assertEquals(3, super.x);
- ++super.x;
- assertEquals(4, super.x);
- assertEquals(4, super.x++);
- assertEquals(5, super.x);
- assertEquals(6, ++super.x);
- assertEquals(6, super.x);
- assertEquals(6, this._x);
-
- super.x--;
- assertEquals(5, super.x);
- --super.x;
- assertEquals(4, super.x);
- assertEquals(4, super.x--);
- assertEquals(3, super.x);
- assertEquals(2, --super.x);
- assertEquals(2, super.x);
- assertEquals(2, this._x);
- }.toMethod(Derived.prototype);
new Derived().testCounts();
}());
@@ -1568,32 +1793,31 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 2
+ _x: 2,
+ testCounts() {
+ assertEquals(2, this._x);
+ assertEquals(2, super[x]);
+ super[x]++;
+ assertEquals(3, super[x]);
+ ++super[x];
+ assertEquals(4, super[x]);
+ assertEquals(4, super[x]++);
+ assertEquals(5, super[x]);
+ assertEquals(6, ++super[x]);
+ assertEquals(6, super[x]);
+ assertEquals(6, this._x);
+
+ super[x]--;
+ assertEquals(5, super[x]);
+ --super[x];
+ assertEquals(4, super[x]);
+ assertEquals(4, super[x]--);
+ assertEquals(3, super[x]);
+ assertEquals(2, --super[x]);
+ assertEquals(2, super[x]);
+ assertEquals(2, this._x);
+ }
};
-
- Derived.prototype.testCounts = function() {
- assertEquals(2, this._x);
- assertEquals(2, super[x]);
- super[x]++;
- assertEquals(3, super[x]);
- ++super[x];
- assertEquals(4, super[x]);
- assertEquals(4, super[x]++);
- assertEquals(5, super[x]);
- assertEquals(6, ++super[x]);
- assertEquals(6, super[x]);
- assertEquals(6, this._x);
-
- super[x]--;
- assertEquals(5, super[x]);
- --super[x];
- assertEquals(4, super[x]);
- assertEquals(4, super[x]--);
- assertEquals(3, super[x]);
- assertEquals(2, --super[x]);
- assertEquals(2, super[x]);
- assertEquals(2, this._x);
- }.toMethod(Derived.prototype);
new Derived().testCounts();
}());
@@ -1616,32 +1840,31 @@
Derived.prototype = {
__proto__: Base.prototype,
constructor: Derived,
- _x: 2
+ _x: 2,
+ testCounts() {
+ assertEquals(2, this._x);
+ assertEquals(2, super[x]);
+ super[x]++;
+ assertEquals(3, super[x]);
+ ++super[x];
+ assertEquals(4, super[x]);
+ assertEquals(4, super[x]++);
+ assertEquals(5, super[x]);
+ assertEquals(6, ++super[x]);
+ assertEquals(6, super[x]);
+ assertEquals(6, this._x);
+
+ super[x]--;
+ assertEquals(5, super[x]);
+ --super[x];
+ assertEquals(4, super[x]);
+ assertEquals(4, super[x]--);
+ assertEquals(3, super[x]);
+ assertEquals(2, --super[x]);
+ assertEquals(2, super[x]);
+ assertEquals(2, this._x);
+ }
};
-
- Derived.prototype.testCounts = function() {
- assertEquals(2, this._x);
- assertEquals(2, super[x]);
- super[x]++;
- assertEquals(3, super[x]);
- ++super[x];
- assertEquals(4, super[x]);
- assertEquals(4, super[x]++);
- assertEquals(5, super[x]);
- assertEquals(6, ++super[x]);
- assertEquals(6, super[x]);
- assertEquals(6, this._x);
-
- super[x]--;
- assertEquals(5, super[x]);
- --super[x];
- assertEquals(4, super[x]);
- assertEquals(4, super[x]--);
- assertEquals(3, super[x]);
- assertEquals(2, --super[x]);
- assertEquals(2, super[x]);
- assertEquals(2, this._x);
- }.toMethod(Derived.prototype);
new Derived().testCounts();
}());
@@ -1650,26 +1873,27 @@
function Base() {}
Object.defineProperty(Base.prototype, 'x', { value : 27, writable: false });
function Derived() {}
-
- Derived.prototype = { __proto__: Base.prototype, constructor: Derived };
-
- Derived.prototype.mSloppy = function() {
- assertEquals(27, super.x);
- assertEquals(27, this.x);
- super.x = 10;
- assertEquals(27, super.x);
- assertEquals(27, this.x);
- }.toMethod(Derived.prototype);
- Derived.prototype.mStrict = function() {
- 'use strict';
- assertEquals(27, super.x);
- assertEquals(27, this.x);
- var ex = null;
- try { super.x = 10; } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(27, super.x);
- assertEquals(27, this.x);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ constructor: Derived,
+ mSloppy() {
+ assertEquals(27, super.x);
+ assertEquals(27, this.x);
+ super.x = 10;
+ assertEquals(27, super.x);
+ assertEquals(27, this.x);
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(27, super.x);
+ assertEquals(27, this.x);
+ var ex = null;
+ try { super.x = 10; } catch(e) { ex = e; }
+ assertInstanceof(ex, TypeError);
+ assertEquals(27, super.x);
+ assertEquals(27, this.x);
+ }
+ };
new Derived().mSloppy();
new Derived().mStrict();
}());
@@ -1681,25 +1905,27 @@
Object.defineProperty(Base.prototype, x, { value : 27, writable: false });
function Derived() {}
- Derived.prototype = { __proto__: Base.prototype, constructor: Derived };
-
- Derived.prototype.mSloppy = function() {
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- super[x] = 10;
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- }.toMethod(Derived.prototype);
- Derived.prototype.mStrict = function() {
- 'use strict';
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- var ex = null;
- try { super[x] = 10; } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ constructor: Derived,
+ mSloppy() {
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ super[x] = 10;
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ var ex = null;
+ try { super[x] = 10; } catch(e) { ex = e; }
+ assertInstanceof(ex, TypeError);
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ }
+ };
new Derived().mSloppy();
new Derived().mStrict();
}());
@@ -1711,55 +1937,51 @@
Object.defineProperty(Base.prototype, x, { value : 27, writable: false });
function Derived() {}
- Derived.prototype = { __proto__: Base.prototype, constructor: Derived };
-
- Derived.prototype.mSloppy = function() {
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- super[x] = 10;
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- }.toMethod(Derived.prototype);
- Derived.prototype.mStrict = function() {
- 'use strict';
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- var ex = null;
- try { super[x] = 10; } catch(e) { ex = e; }
- assertTrue(ex instanceof TypeError);
- assertEquals(27, super[x]);
- assertEquals(27, this[x]);
- }.toMethod(Derived.prototype);
+ Derived.prototype = {
+ __proto__: Base.prototype,
+ constructor: Derived,
+ mSloppy() {
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ super[x] = 10;
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ },
+ mStrict() {
+ 'use strict';
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ var ex = null;
+ try { super[x] = 10; } catch(e) { ex = e; }
+ assertInstanceof(ex, TypeError);
+ assertEquals(27, super[x]);
+ assertEquals(27, this[x]);
+ }
+ };
new Derived().mSloppy();
new Derived().mStrict();
}());
-function Subclass(base, constructor) {
- var homeObject = {
- __proto__: base.prototype,
- constructor: constructor
- };
- constructor.__proto__ = base;
- constructor.prototype = homeObject;
- // not doing toMethod: home object is not required for
- // super constructor calls.
- return constructor;
-}
-
(function TestSuperCall() {
+ 'use strict';
+
var baseCalled = 0;
var derivedCalled = 0;
var derivedDerivedCalled = 0;
- function Base() {
- baseCalled++;
+ class Base {
+ constructor() {
+ baseCalled++;
+ }
}
- var Derived = Subclass(Base, function () {
- super();
- derivedCalled++;
- });
+ class Derived extends Base {
+ constructor() {
+ super();
+ derivedCalled++;
+ }
+ }
assertEquals(Base, Base.prototype.constructor);
assertEquals(Base.prototype, Derived.prototype.__proto__);
@@ -1770,10 +1992,12 @@ function Subclass(base, constructor) {
assertEquals(1, baseCalled);
assertEquals(1, derivedCalled);
- var DerivedDerived = Subclass(Derived, function () {
- super();
- derivedDerivedCalled++;
- });
+ class DerivedDerived extends Derived {
+ constructor() {
+ super();
+ derivedDerivedCalled++;
+ }
+ }
baseCalled = 0;
derivedCalled = 0;
@@ -1783,32 +2007,33 @@ function Subclass(base, constructor) {
assertEquals(1, derivedCalled);
assertEquals(1, derivedDerivedCalled);
- function Base2(v) {
- this.fromBase = v;
+ class Base2 {
+ constructor(v) {
+ this.fromBase = v;
+ }
+ }
+ class Derived2 extends Base2 {
+ constructor(v1, v2) {
+ super(v1);
+ this.fromDerived = v2;
+ }
}
- var Derived2 = Subclass(Base2, function (v1, v2) {
- super(v1);
- this.fromDerived = v2;
- });
var d = new Derived2("base", "derived");
assertEquals("base", d.fromBase);
assertEquals("derived", d.fromDerived);
- function ImplicitSubclassOfFunction() {
- super();
- this.x = 123;
- }
-
- var o = new ImplicitSubclassOfFunction();
- assertEquals(123, o.x);
-
var calls = 0;
- function G() {
- calls++;
+ class G {
+ constructor() {
+ calls++;
+ }
}
- function F() {
- super();
+
+ class F extends Object {
+ constructor() {
+ super();
+ }
}
F.__proto__ = G;
new F();
@@ -1819,103 +2044,23 @@ function Subclass(base, constructor) {
}());
-(function TestNewSuper() {
- var baseCalled = 0;
- var derivedCalled = 0;
-
- function Base() {
- baseCalled++;
- this.x = 15;
- }
-
-
- var Derived = Subclass(Base, function() {
- baseCalled = 0;
- var b = new super();
- assertEquals(1, baseCalled)
- assertEquals(Base.prototype, b.__proto__);
- assertEquals(15, b.x);
- assertEquals(undefined, this.x);
- derivedCalled++;
- });
+(function TestExtendsObject() {
+ 'use strict';
+ class F extends Object { }
+ var f = new F(42);
- derivedCalled = 0;
- new Derived();
- assertEquals(1, derivedCalled);
+ // TODO(dslomov,arv): Fix this. BUG=v8:3886.
+ assertInstanceof(f, Number);
}());
-
(function TestSuperCallErrorCases() {
- function T() {
- super();
+ 'use strict';
+ class T extends Object {
+ constructor() {
+ super();
+ }
}
+
T.__proto__ = null;
- // Spec says ReferenceError here, but for other IsCallable failures
- // we throw TypeError.
- // Filed https://bugs.ecmascript.org/show_bug.cgi?id=3282
assertThrows(function() { new T(); }, TypeError);
-
- function T1() {
- var b = new super();
- }
- T1.__proto = null;
- assertThrows(function() { new T1(); }, TypeError);
-}());
-
-
-(function TestSuperCallSyntacticRestriction() {
- assertThrows(function() {
- function C() {
- var y;
- super();
- }
- new C();
- }, TypeError);
- assertThrows(function() {
- function C() {
- super(this.x);
- }
- new C();
- }, TypeError);
- assertThrows(function() {
- function C() {
- super(this);
- }
- new C();
- }, TypeError);
- assertThrows(function() {
- function C() {
- super(1, 2, Object.getPrototypeOf(this));
- }
- new C();
- }, TypeError);
- assertThrows(function() {
- function C() {
- { super(1, 2); }
- }; new C();
- }, TypeError);
- assertThrows(function() {
- function C() {
- if (1) super();
- }; new C();
- }, TypeError);
-
- function C1() {
- 'use strict';
- super();
- };
- new C1();
-
- function C2() {
- ; 'use strict';;;;;
- super();
- };
- new C2();
-
- function C3() {
- ; 'use strict';;;;;
- // This is a comment.
- super();
- }
- new C3();
}());
diff --git a/deps/v8/test/mjsunit/harmony/templates.js b/deps/v8/test/mjsunit/harmony/templates.js
index c339bb8cc7..a884f58fb6 100644
--- a/deps/v8/test/mjsunit/harmony/templates.js
+++ b/deps/v8/test/mjsunit/harmony/templates.js
@@ -505,3 +505,16 @@ var obj = {
assertEquals("\u00008", `\08`);
assertEquals("\u00009", `\09`);
})();
+
+
+(function testLegacyOctalEscapesInExpressions() {
+ // Allowed in sloppy expression
+ assertEquals("\x07", `${"\07"}`);
+
+ // Disallowed in template tail
+ assertThrows("`${\"\\07\"}\\07`", SyntaxError);
+
+ // Disallowed in strict expression
+ assertThrows("`${(function() { \"use strict\"; return \"\\07\"; })()}`",
+ SyntaxError);
+})();
diff --git a/deps/v8/test/mjsunit/harmony/toMethod.js b/deps/v8/test/mjsunit/harmony/toMethod.js
index ad51b2ff38..81db5830c2 100644
--- a/deps/v8/test/mjsunit/harmony/toMethod.js
+++ b/deps/v8/test/mjsunit/harmony/toMethod.js
@@ -14,7 +14,7 @@
function ClassD() { }
assertEquals(1, f(1));
- var g = f.toMethod(ClassD.prototype);
+ var g = %ToMethod(f, ClassD.prototype);
assertEquals(1, g(1));
assertEquals(undefined, f[%HomeObjectSymbol()]);
assertEquals(ClassD.prototype, g[%HomeObjectSymbol()]);
@@ -33,22 +33,13 @@
var q = f(0);
assertEquals(2, q(1));
assertEquals(3, q(1));
- var g = q.toMethod(Derived.prototype);
+ var g = %ToMethod(q, Derived.prototype);
assertFalse(g === q);
assertEquals(4, g(1));
assertEquals(5, q(1));
}());
-(function TestErrorCases() {
- var sFun = Function.prototype.toMethod;
- assertThrows(function() { sFun.call({}); }, TypeError);
- assertThrows(function() { sFun.call({}, {}); }, TypeError);
- function f(){};
- assertThrows(function() { f.toMethod(1); }, TypeError);
-}());
-
-
(function TestPrototypeChain() {
var o = {};
var o1 = {};
@@ -56,11 +47,11 @@
function g() { }
- var fMeth = f.toMethod(o);
+ var fMeth = %ToMethod(f, o);
assertEquals(o, fMeth[%HomeObjectSymbol()]);
g.__proto__ = fMeth;
assertEquals(undefined, g[%HomeObjectSymbol()]);
- var gMeth = g.toMethod(o1);
+ var gMeth = %ToMethod(g, o1);
assertEquals(fMeth, gMeth.__proto__);
assertEquals(o, fMeth[%HomeObjectSymbol()]);
assertEquals(o1, gMeth[%HomeObjectSymbol()]);
@@ -82,7 +73,7 @@
}
var fBound = f.bind(o, 1, 2, 3);
- var fMeth = fBound.toMethod(p);
+ var fMeth = %ToMethod(fBound, p);
assertEquals(10, fMeth(4));
assertEquals(10, fMeth.call(p, 4));
var fBound1 = fBound.bind(o, 4);
@@ -100,7 +91,7 @@
assertEquals(15, f(o));
%OptimizeFunctionOnNextCall(f);
assertEquals(15, f(o));
- var g = f.toMethod({});
+ var g = %ToMethod(f, {});
var o1 = {y : 1024, x : "abc"};
assertEquals("abc", f(o1));
assertEquals("abc", g(o1));
@@ -110,6 +101,6 @@
function f() {}
Object.preventExtensions(f);
assertFalse(Object.isExtensible(f));
- var m = f.toMethod({});
+ var m = %ToMethod(f, {});
assertTrue(Object.isExtensible(m));
}());
diff --git a/deps/v8/test/mjsunit/harmony/unicode-escapes-in-regexps.js b/deps/v8/test/mjsunit/harmony/unicode-escapes-in-regexps.js
new file mode 100644
index 0000000000..67493351a4
--- /dev/null
+++ b/deps/v8/test/mjsunit/harmony/unicode-escapes-in-regexps.js
@@ -0,0 +1,212 @@
+// 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.
+
+// ES6 extends the \uxxxx escape and also allows \u{xxxxx}.
+
+// Flags: --harmony-unicode-regexps --harmony-regexps
+
+function testRegexpHelper(r) {
+ assertTrue(r.test("foo"));
+ assertTrue(r.test("boo"));
+ assertFalse(r.test("moo"));
+}
+
+
+(function TestUnicodeEscapes() {
+ testRegexpHelper(/(\u0066|\u0062)oo/);
+ testRegexpHelper(/(\u0066|\u0062)oo/u);
+ testRegexpHelper(/(\u{0066}|\u{0062})oo/u);
+ testRegexpHelper(/(\u{66}|\u{000062})oo/u);
+
+ // Note that we need \\ inside a string, otherwise it's interpreted as a
+ // unicode escape inside a string.
+ testRegexpHelper(new RegExp("(\\u0066|\\u0062)oo"));
+ testRegexpHelper(new RegExp("(\\u0066|\\u0062)oo", "u"));
+ testRegexpHelper(new RegExp("(\\u{0066}|\\u{0062})oo", "u"));
+ testRegexpHelper(new RegExp("(\\u{66}|\\u{000062})oo", "u"));
+
+ // Though, unicode escapes via strings should work too.
+ testRegexpHelper(new RegExp("(\u0066|\u0062)oo"));
+ testRegexpHelper(new RegExp("(\u0066|\u0062)oo", "u"));
+ testRegexpHelper(new RegExp("(\u{0066}|\u{0062})oo", "u"));
+ testRegexpHelper(new RegExp("(\u{66}|\u{000062})oo", "u"));
+})();
+
+
+(function TestUnicodeEscapesInCharacterClasses() {
+ testRegexpHelper(/[\u0062-\u0066]oo/);
+ testRegexpHelper(/[\u0062-\u0066]oo/u);
+ testRegexpHelper(/[\u{0062}-\u{0066}]oo/u);
+ testRegexpHelper(/[\u{62}-\u{00000066}]oo/u);
+
+ // Note that we need \\ inside a string, otherwise it's interpreted as a
+ // unicode escape inside a string.
+ testRegexpHelper(new RegExp("[\\u0062-\\u0066]oo"));
+ testRegexpHelper(new RegExp("[\\u0062-\\u0066]oo", "u"));
+ testRegexpHelper(new RegExp("[\\u{0062}-\\u{0066}]oo", "u"));
+ testRegexpHelper(new RegExp("[\\u{62}-\\u{00000066}]oo", "u"));
+
+ // Though, unicode escapes via strings should work too.
+ testRegexpHelper(new RegExp("[\u0062-\u0066]oo"));
+ testRegexpHelper(new RegExp("[\u0062-\u0066]oo", "u"));
+ testRegexpHelper(new RegExp("[\u{0062}-\u{0066}]oo", "u"));
+ testRegexpHelper(new RegExp("[\u{62}-\u{00000066}]oo", "u"));
+})();
+
+
+(function TestBraceEscapesWithoutUnicodeFlag() {
+ // \u followed by illegal escape will be parsed as u. {x} will be the
+ // character count.
+ function helper1(r) {
+ assertFalse(r.test("fbar"));
+ assertFalse(r.test("fubar"));
+ assertTrue(r.test("fuubar"));
+ assertFalse(r.test("fuuubar"));
+ }
+ helper1(/f\u{2}bar/);
+ helper1(new RegExp("f\\u{2}bar"));
+
+ function helper2(r) {
+ assertFalse(r.test("fbar"));
+ assertTrue(r.test("fubar"));
+ assertTrue(r.test("fuubar"));
+ assertFalse(r.test("fuuubar"));
+ }
+
+ helper2(/f\u{1,2}bar/);
+ helper2(new RegExp("f\\u{1,2}bar"));
+
+ function helper3(r) {
+ assertTrue(r.test("u"));
+ assertTrue(r.test("{"));
+ assertTrue(r.test("2"));
+ assertTrue(r.test("}"));
+ assertFalse(r.test("q"));
+ assertFalse(r.test("("));
+ assertFalse(r.test(")"));
+ }
+ helper3(/[\u{2}]/);
+ helper3(new RegExp("[\\u{2}]"));
+})();
+
+
+(function TestInvalidEscapes() {
+ // Without the u flag, invalid unicode escapes and other invalid escapes are
+ // treated as identity escapes.
+ function helper1(r) {
+ assertTrue(r.test("firstuxz89second"));
+ }
+ helper1(/first\u\x\z\8\9second/);
+ helper1(new RegExp("first\\u\\x\\z\\8\\9second"));
+
+ function helper2(r) {
+ assertTrue(r.test("u"));
+ assertTrue(r.test("x"));
+ assertTrue(r.test("z"));
+ assertTrue(r.test("8"));
+ assertTrue(r.test("9"));
+ assertFalse(r.test("q"));
+ assertFalse(r.test("7"));
+ }
+ helper2(/[\u\x\z\8\9]/);
+ helper2(new RegExp("[\\u\\x\\z\\8\\9]"));
+
+ // However, with the u flag, these are treated as invalid escapes.
+ assertThrows("/\\u/u", SyntaxError);
+ assertThrows("/\\u12/u", SyntaxError);
+ assertThrows("/\\ufoo/u", SyntaxError);
+ assertThrows("/\\x/u", SyntaxError);
+ assertThrows("/\\xfoo/u", SyntaxError);
+ assertThrows("/\\z/u", SyntaxError);
+ assertThrows("/\\8/u", SyntaxError);
+ assertThrows("/\\9/u", SyntaxError);
+
+ assertThrows("new RegExp('\\\\u', 'u')", SyntaxError);
+ assertThrows("new RegExp('\\\\u12', 'u')", SyntaxError);
+ assertThrows("new RegExp('\\\\ufoo', 'u')", SyntaxError);
+ assertThrows("new RegExp('\\\\x', 'u')", SyntaxError);
+ assertThrows("new RegExp('\\\\xfoo', 'u')", SyntaxError);
+ assertThrows("new RegExp('\\\\z', 'u')", SyntaxError);
+ assertThrows("new RegExp('\\\\8', 'u')", SyntaxError);
+ assertThrows("new RegExp('\\\\9', 'u')", SyntaxError);
+})();
+
+
+(function TestTooBigHexEscape() {
+ // The hex number inside \u{} has a maximum value.
+ /\u{10ffff}/u
+ new RegExp("\\u{10ffff}", "u")
+ assertThrows("/\\u{110000}/u", SyntaxError);
+ assertThrows("new RegExp('\\\\u{110000}', 'u')", SyntaxError);
+
+ // Without the u flag, they're of course fine ({x} is the count).
+ /\u{110000}/
+ new RegExp("\\u{110000}")
+})();
+
+
+(function TestSyntaxEscapes() {
+ // Syntax escapes work the same with or without the u flag.
+ function helper(r) {
+ assertTrue(r.test("foo[bar"));
+ assertFalse(r.test("foo]bar"));
+ }
+ helper(/foo\[bar/);
+ helper(new RegExp("foo\\[bar"));
+ helper(/foo\[bar/u);
+ helper(new RegExp("foo\\[bar", "u"));
+})();
+
+
+(function TestUnicodeSurrogates() {
+ // U+10E6D corresponds to the surrogate pair [U+D803, U+DE6D].
+ function helper(r) {
+ assertTrue(r.test("foo\u{10e6d}bar"));
+ }
+ helper(/foo\ud803\ude6dbar/u);
+ helper(new RegExp("foo\\ud803\\ude6dbar", "u"));
+})();
+
+
+(function AllFlags() {
+ // Test that we can pass all possible regexp flags and they work properly.
+ function helper1(r) {
+ assertTrue(r.global);
+ assertTrue(r.ignoreCase);
+ assertTrue(r.multiline);
+ assertTrue(r.sticky);
+ assertTrue(r.unicode);
+ }
+
+ helper1(/foo/gimyu);
+ helper1(new RegExp("foo", "gimyu"));
+
+ function helper2(r) {
+ assertFalse(r.global);
+ assertFalse(r.ignoreCase);
+ assertFalse(r.multiline);
+ assertFalse(r.sticky);
+ assertFalse(r.unicode);
+ }
+
+ helper2(/foo/);
+ helper2(new RegExp("foo"));
+})();
+
+
+(function DuplicatedFlags() {
+ // Test that duplicating the u flag is not allowed.
+ assertThrows("/foo/ugu");
+ assertThrows("new RegExp('foo', 'ugu')");
+})();
+
+
+(function ToString() {
+ // Test that the u flag is included in the string representation of regexps.
+ function helper(r) {
+ assertEquals(r.toString(), "/foo/u");
+ }
+ helper(/foo/u);
+ helper(new RegExp("foo", "u"));
+})();
diff --git a/deps/v8/test/mjsunit/mirror-object.js b/deps/v8/test/mjsunit/mirror-object.js
index 91d0f82fe4..834d7a580a 100644
--- a/deps/v8/test/mjsunit/mirror-object.js
+++ b/deps/v8/test/mjsunit/mirror-object.js
@@ -209,14 +209,14 @@ mirror = debug.MakeMirror(o);
// a has getter but no setter.
assertTrue(mirror.property('a').hasGetter());
assertFalse(mirror.property('a').hasSetter());
-assertEquals(debug.PropertyType.Callbacks, mirror.property('a').propertyType());
+assertEquals(debug.PropertyType.AccessorConstant, mirror.property('a').propertyType());
assertEquals('function', mirror.property('a').getter().type());
assertEquals('undefined', mirror.property('a').setter().type());
assertEquals('function (){return \'a\';}', mirror.property('a').getter().source());
// b has setter but no getter.
assertFalse(mirror.property('b').hasGetter());
assertTrue(mirror.property('b').hasSetter());
-assertEquals(debug.PropertyType.Callbacks, mirror.property('b').propertyType());
+assertEquals(debug.PropertyType.AccessorConstant, mirror.property('b').propertyType());
assertEquals('undefined', mirror.property('b').getter().type());
assertEquals('function', mirror.property('b').setter().type());
assertEquals('function (){}', mirror.property('b').setter().source());
@@ -224,7 +224,7 @@ assertFalse(mirror.property('b').isException());
// c has both getter and setter. The getter throws an exception.
assertTrue(mirror.property('c').hasGetter());
assertTrue(mirror.property('c').hasSetter());
-assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType());
+assertEquals(debug.PropertyType.AccessorConstant, mirror.property('c').propertyType());
assertEquals('function', mirror.property('c').getter().type());
assertEquals('function', mirror.property('c').setter().type());
assertEquals('function (){throw \'c\';}', mirror.property('c').getter().source());
diff --git a/deps/v8/test/mjsunit/mirror-regexp.js b/deps/v8/test/mjsunit/mirror-regexp.js
index d6a9d71024..6c251d4ff6 100644
--- a/deps/v8/test/mjsunit/mirror-regexp.js
+++ b/deps/v8/test/mjsunit/mirror-regexp.js
@@ -25,7 +25,7 @@
// (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-debug-as debug
+// Flags: --expose-debug-as debug --harmony-unicode-regexps
// Test the mirror object for regular expression values
var all_attributes = debug.PropertyAttribute.ReadOnly |
@@ -36,6 +36,7 @@ var expected_attributes = {
'global': all_attributes,
'ignoreCase': all_attributes,
'multiline': all_attributes,
+ 'unicode' : all_attributes,
'lastIndex': debug.PropertyAttribute.DontEnum | debug.PropertyAttribute.DontDelete
};
@@ -108,3 +109,4 @@ testRegExpMirror(/x/);
testRegExpMirror(/[abc]/);
testRegExpMirror(/[\r\n]/g);
testRegExpMirror(/a*b/gmi);
+testRegExpMirror(/(\u{0066}|\u{0062})oo/u);
diff --git a/deps/v8/test/mjsunit/mjsunit.js b/deps/v8/test/mjsunit/mjsunit.js
index b360425c61..f50319d6aa 100644
--- a/deps/v8/test/mjsunit/mjsunit.js
+++ b/deps/v8/test/mjsunit/mjsunit.js
@@ -202,8 +202,8 @@ var assertUnoptimized;
if (a === 0) return (1 / a) === (1 / b);
return true;
}
- if (typeof a != typeof b) return false;
- if (typeof a == "number") return isNaN(a) && isNaN(b);
+ if (typeof a !== typeof b) return false;
+ if (typeof a === "number") return isNaN(a) && isNaN(b);
if (typeof a !== "object" && typeof a !== "function") return false;
// Neither a nor b is primitive.
var objectClass = classOf(a);
@@ -216,7 +216,7 @@ var assertUnoptimized;
if (objectClass === "Function") return false;
if (objectClass === "Array") {
var elementCount = 0;
- if (a.length != b.length) {
+ if (a.length !== b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
@@ -224,8 +224,8 @@ var assertUnoptimized;
}
return true;
}
- if (objectClass == "String" || objectClass == "Number" ||
- objectClass == "Boolean" || objectClass == "Date") {
+ if (objectClass === "String" || objectClass === "Number" ||
+ objectClass === "Boolean" || objectClass === "Date") {
if (a.valueOf() !== b.valueOf()) return false;
}
return deepObjectEquals(a, b);
@@ -235,7 +235,7 @@ var assertUnoptimized;
// TODO(mstarzinger): We should think about using Harmony's egal operator
// or the function equivalent Object.is() here.
if (found === expected) {
- if (expected !== 0 || (1 / expected) == (1 / found)) return;
+ if (expected !== 0 || (1 / expected) === (1 / found)) return;
} else if ((expected !== expected) && (found !== found)) {
return;
}
@@ -262,7 +262,7 @@ var assertUnoptimized;
start = name_opt + " - ";
}
assertEquals(expected.length, found.length, start + "array length");
- if (expected.length == found.length) {
+ if (expected.length === found.length) {
for (var i = 0; i < expected.length; ++i) {
assertEquals(expected[i], found[i],
start + "array element at index " + i);
@@ -282,7 +282,7 @@ var assertUnoptimized;
assertToStringEquals = function assertToStringEquals(expected, found,
name_opt) {
- if (expected != String(found)) {
+ if (expected !== String(found)) {
fail(expected, found, name_opt);
}
};
@@ -315,14 +315,14 @@ var assertUnoptimized;
assertThrows = function assertThrows(code, type_opt, cause_opt) {
var threwException = true;
try {
- if (typeof code == 'function') {
+ if (typeof code === 'function') {
code();
} else {
eval(code);
}
threwException = false;
} catch (e) {
- if (typeof type_opt == 'function') {
+ if (typeof type_opt === 'function') {
assertInstanceof(e, type_opt);
}
if (arguments.length >= 3) {
@@ -339,7 +339,7 @@ var assertUnoptimized;
if (!(obj instanceof type)) {
var actualTypeName = null;
var actualConstructor = Object.getPrototypeOf(obj).constructor;
- if (typeof actualConstructor == "function") {
+ if (typeof actualConstructor === "function") {
actualTypeName = actualConstructor.name || String(actualConstructor);
}
fail("Object <" + PrettyPrint(obj) + "> is not an instance of <" +
@@ -351,7 +351,7 @@ var assertUnoptimized;
assertDoesNotThrow = function assertDoesNotThrow(code, name_opt) {
try {
- if (typeof code == 'function') {
+ if (typeof code === 'function') {
code();
} else {
eval(code);
@@ -386,12 +386,12 @@ var assertUnoptimized;
assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
- assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt);
+ assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt);
}
assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
- assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt);
+ assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt);
}
})();
diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status
index 26ec10ba66..dc96a1de35 100644
--- a/deps/v8/test/mjsunit/mjsunit.status
+++ b/deps/v8/test/mjsunit/mjsunit.status
@@ -67,8 +67,10 @@
'array-feedback': [PASS, NO_VARIANTS],
'compare-known-objects-slow': [PASS, NO_VARIANTS],
'elements-kind': [PASS, NO_VARIANTS],
+ 'opt-elements-kind': [PASS, NO_VARIANTS],
# Some tests are just too slow to run for now.
+ 'big-object-literal': [PASS, NO_VARIANTS],
'bit-not': [PASS, NO_VARIANTS],
'json2': [PASS, NO_VARIANTS],
'packed-elements': [PASS, NO_VARIANTS],
@@ -76,52 +78,42 @@
'whitespaces': [PASS, NO_VARIANTS],
'compiler/osr-assert': [PASS, NO_VARIANTS],
'regress/regress-2185-2': [PASS, NO_VARIANTS],
+ 'regress/regress-2612': [PASS, NO_VARIANTS],
+
+ # Modules are busted
+ 'harmony/module-linking': [SKIP],
+ 'harmony/module-recompile': [SKIP],
+ 'harmony/module-resolution': [SKIP],
+ 'harmony/regress/regress-343928': [SKIP],
# Issue 3660: Replacing activated TurboFan frames by unoptimized code does
# not work, but we expect it to not crash.
'debug-step-turbofan': [PASS, FAIL],
- # Support for %GetFrameDetails is missing and requires checkpoints.
- 'debug-evaluate-bool-constructor': [PASS, NO_VARIANTS],
+ # TODO(jarin/mstarzinger): Investigate debugger issues with TurboFan.
'debug-evaluate-const': [PASS, NO_VARIANTS],
- 'debug-evaluate-locals-optimized-double': [PASS, NO_VARIANTS],
- 'debug-evaluate-locals-optimized': [PASS, NO_VARIANTS],
'debug-evaluate-locals': [PASS, NO_VARIANTS],
- 'debug-evaluate-with-context': [PASS, NO_VARIANTS],
+ 'debug-liveedit-check-stack': [PASS, NO_VARIANTS], # only in no-snap mode.
'debug-liveedit-double-call': [PASS, NO_VARIANTS],
- 'debug-liveedit-restart-frame': [PASS, NO_VARIANTS],
- 'debug-return-value': [PASS, NO_VARIANTS],
- 'debug-set-variable-value': [PASS, NO_VARIANTS],
'debug-step-stub-callfunction': [PASS, NO_VARIANTS],
+ 'debug-set-variable-value': [PASS, NO_VARIANTS],
'debug-stepin-accessor': [PASS, NO_VARIANTS],
'debug-stepin-builtin': [PASS, NO_VARIANTS],
'debug-stepin-constructor': [PASS, NO_VARIANTS],
'debug-stepin-function-call': [PASS, NO_VARIANTS],
'debug-stepnext-do-while': [PASS, NO_VARIANTS],
- 'debug-stepout-recursive-function': [PASS, NO_VARIANTS],
'debug-stepout-scope-part1': [PASS, NO_VARIANTS],
'debug-stepout-scope-part2': [PASS, NO_VARIANTS],
'debug-stepout-scope-part3': [PASS, NO_VARIANTS],
- 'debug-stepout-scope-part7': [PASS, NO_VARIANTS],
- 'debug-stepout-to-builtin': [PASS, NO_VARIANTS],
- 'es6/debug-promises/throw-in-constructor': [PASS, NO_VARIANTS],
- 'es6/debug-promises/reject-in-constructor': [PASS, NO_VARIANTS],
- 'es6/debug-promises/throw-with-undefined-reject': [PASS, NO_VARIANTS],
- 'es6/debug-promises/throw-with-throw-in-reject': [PASS, NO_VARIANTS],
- 'es6/debug-promises/reject-with-throw-in-reject': [PASS, NO_VARIANTS],
- 'es6/debug-promises/throw-uncaught-all': [PASS, NO_VARIANTS],
- 'es6/debug-promises/throw-uncaught-uncaught': [PASS, NO_VARIANTS],
- 'es6/debug-promises/reject-uncaught-late': [PASS, NO_VARIANTS],
- 'es6/debug-promises/throw-caught-by-default-reject-handler': [PASS, NO_VARIANTS],
- 'es6/generators-debug-scopes': [PASS, NO_VARIANTS],
- 'harmony/debug-blockscopes': [PASS, NO_VARIANTS],
- 'regress/regress-1081309': [PASS, NO_VARIANTS],
- 'regress/regress-269': [PASS, NO_VARIANTS],
- 'regress/regress-crbug-259300': [PASS, NO_VARIANTS],
- 'regress/regress-frame-details-null-receiver': [PASS, NO_VARIANTS],
+ 'es6/debug-stepin-microtasks': [PASS, NO_VARIANTS],
+ 'es6/debug-stepnext-for': [PASS, NO_VARIANTS],
+ 'harmony/debug-evaluate-blockscopes': [PASS, NO_VARIANTS],
- # TODO(arv): TurboFan does not yet add [[HomeObject]] as needed.
- 'harmony/object-literals-super': [PASS, NO_VARIANTS],
+ # TODO(jarin): Some tests don't like --turbo-deoptimzation very much.
+ 'asm/embenchen/lua_binarytrees': [SKIP],
+ 'es6/symbols': [PASS, NO_VARIANTS],
+ 'regress/regress-354433': [PASS, NO_VARIANTS], # only on ARM simulator.
+ 'regress/regress-crbug-259300': [PASS, NO_VARIANTS],
##############################################################################
# Too slow in debug mode with --stress-opt mode.
@@ -257,6 +249,12 @@
}], # 'gc_stress == True'
##############################################################################
+['byteorder == big', {
+ # Emscripten requires little-endian, skip all tests on big endian platforms.
+ 'asm/embenchen/*': [SKIP],
+}], # 'byteorder == big'
+
+##############################################################################
['arch == arm64 or arch == android_arm64', {
# arm64 TF timeout.
@@ -445,9 +443,6 @@
['arch == mips', {
# Flaky with TF.
'mirror-script': [PASS, NO_VARIANTS],
-
- # Emscripten requires little-endian, skip all tests on MIPS EB.
- 'asm/embenchen/*': [SKIP],
}], # 'arch == mips'
##############################################################################
@@ -574,6 +569,12 @@
}], # 'arch == nacl_ia32 or arch == nacl_x64'
##############################################################################
+['arch == x87', {
+ # Currently Turbofan is not supported by x87.
+ 'compiler/opt-next-call-turbo': [SKIP],
+}], # 'arch == x87'
+
+##############################################################################
['deopt_fuzzer == True', {
# Skip tests that are not suitable for deoptimization fuzzing.
diff --git a/deps/v8/test/mjsunit/object-literal-multiple-fields.js b/deps/v8/test/mjsunit/object-literal-multiple-fields.js
new file mode 100644
index 0000000000..f36d14d074
--- /dev/null
+++ b/deps/v8/test/mjsunit/object-literal-multiple-fields.js
@@ -0,0 +1,96 @@
+// 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 TestConstants() {
+ var o = {
+ p: 1,
+ p: 2,
+ };
+ assertEquals(2, o.p);
+})();
+
+
+(function TestMaterialized() {
+ var o = {
+ p: [1],
+ p: [2],
+ };
+ assertEquals(2, o.p[0]);
+})();
+
+
+(function TestMaterialize2() {
+ var o = {
+ p: function() {},
+ p: 2,
+ };
+ assertEquals(2, o.p);
+})();
+
+
+
+(function TestComputed() {
+ var o = {
+ p: (function() { return 1; })(),
+ p: (function() { return 2; })(),
+ };
+ assertEquals(2, o.p);
+})();
+
+
+(function TestComputed2() {
+ var o = {
+ p: (function() { return 1; })(),
+ p: 2,
+ };
+ assertEquals(2, o.p);
+})();
+
+
+
+(function TestGetter() {
+ var o = {
+ get p() { return 1; },
+ get p() { return 2; },
+ };
+ assertEquals(2, o.p);
+})();
+
+
+(function TestGetterSetter() {
+ var o = {
+ get p() { return 1; },
+ set p(_) {},
+ };
+ assertEquals(1, o.p);
+
+ o = {
+ set p(_) {},
+ get p() { return 2; },
+ };
+ assertEquals(2, o.p);
+})();
+
+
+(function TestCombined() {
+ var o = {
+ get p() { return 1; },
+ p: 2,
+ };
+ assertEquals(2, o.p);
+
+ o = {
+ get p() { return 1; },
+ p: 2,
+ get p() { return 3; },
+ };
+ assertEquals(3, o.p);
+
+ o = {
+ get p() { return 1; },
+ p: 2,
+ set p(_) {},
+ };
+ assertEquals(undefined, o.p);
+})();
diff --git a/deps/v8/test/mjsunit/object-literal-multiple-proto-fields.js b/deps/v8/test/mjsunit/object-literal-multiple-proto-fields.js
new file mode 100644
index 0000000000..1ab608bde2
--- /dev/null
+++ b/deps/v8/test/mjsunit/object-literal-multiple-proto-fields.js
@@ -0,0 +1,21 @@
+// 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 p1 = {};
+var p2 = {};
+var p3 = {};
+var x = 0;
+var y = 1;
+var z = 2;
+var o = 3;
+assertThrows(
+ 'o = {' +
+ ' __proto__: (x++, p1),' +
+ ' __proto__: (y++, p2),' +
+ ' __proto__: (z++, p3)' +
+ '};', SyntaxError);
+assertEquals(0, x);
+assertEquals(1, y);
+assertEquals(2, z);
+assertEquals(3, o);
diff --git a/deps/v8/test/mjsunit/osr-elements-kind.js b/deps/v8/test/mjsunit/osr-elements-kind.js
index 518b984743..389b6dac6f 100644
--- a/deps/v8/test/mjsunit/osr-elements-kind.js
+++ b/deps/v8/test/mjsunit/osr-elements-kind.js
@@ -88,11 +88,10 @@ function assertKind(expected, obj, name_opt) {
assertEquals(expected, getKind(obj), name_opt);
}
-// long-running loop forces OSR.
%NeverOptimizeFunction(construct_smis);
%NeverOptimizeFunction(construct_doubles);
%NeverOptimizeFunction(convert_mixed);
-for (var i = 0; i < 1000000; i++) { }
+for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); }
// This code exists to eliminate the learning influence of AllocationSites
// on the following tests.
diff --git a/deps/v8/test/mjsunit/property-name-eval-arguments.js b/deps/v8/test/mjsunit/property-name-eval-arguments.js
new file mode 100644
index 0000000000..ebb07485c3
--- /dev/null
+++ b/deps/v8/test/mjsunit/property-name-eval-arguments.js
@@ -0,0 +1,59 @@
+// 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 e = 1, a = 2;
+ var o = {
+ get eval() {
+ return e;
+ },
+ set eval(v) {
+ e = v;
+ },
+ get arguments() {
+ return a;
+ },
+ set arguments(v) {
+ a = v;
+ },
+ };
+
+ assertEquals(1, o.eval);
+ o.eval = 3;
+ assertEquals(3, e);
+
+ assertEquals(2, o.arguments);
+ o.arguments = 4;
+ assertEquals(4, a);
+})();
+
+
+(function TestStrictMode() {
+ 'use strict';
+
+ var e = 1, a = 2;
+ var o = {
+ get eval() {
+ return e;
+ },
+ set eval(v) {
+ e = v;
+ },
+ get arguments() {
+ return a;
+ },
+ set arguments(v) {
+ a = v;
+ },
+ };
+
+ assertEquals(1, o.eval);
+ o.eval = 3;
+ assertEquals(3, e);
+
+ assertEquals(2, o.arguments);
+ o.arguments = 4;
+ assertEquals(4, a);
+})();
diff --git a/deps/v8/test/mjsunit/regress-sync-optimized-lists.js b/deps/v8/test/mjsunit/regress-sync-optimized-lists.js
index f07c12b2cb..2ce60aa836 100644
--- a/deps/v8/test/mjsunit/regress-sync-optimized-lists.js
+++ b/deps/v8/test/mjsunit/regress-sync-optimized-lists.js
@@ -13,9 +13,7 @@ function get_closure() {
return function add_field(obj, osr) {
obj.c = 3;
var x = 0;
- if (osr) {
- %OptimizeFunctionOnNextCall(add_field, "osr");
- }
+ if (osr) %OptimizeOsr();
for (var i = 0; i < 10; i++) {
x = i + 1;
}
diff --git a/deps/v8/test/mjsunit/regress/binop-in-effect-context-deopt.js b/deps/v8/test/mjsunit/regress/binop-in-effect-context-deopt.js
index fb7280a0d1..8d60e9015e 100644
--- a/deps/v8/test/mjsunit/regress/binop-in-effect-context-deopt.js
+++ b/deps/v8/test/mjsunit/regress/binop-in-effect-context-deopt.js
@@ -31,7 +31,7 @@
function f(a, deopt, osr) {
var result = (a + 10, "result");
var dummy = deopt + 0;
- if (osr) while (%GetOptimizationStatus(f) == 2) {}
+ for (var i = 0; osr && i < 2; i++) %OptimizeOsr();
return result;
}
diff --git a/deps/v8/test/mjsunit/regress/call-function-in-effect-context-deopt.js b/deps/v8/test/mjsunit/regress/call-function-in-effect-context-deopt.js
index 9a36c141b7..704af744d2 100644
--- a/deps/v8/test/mjsunit/regress/call-function-in-effect-context-deopt.js
+++ b/deps/v8/test/mjsunit/regress/call-function-in-effect-context-deopt.js
@@ -31,7 +31,7 @@ function f(deopt, osr) {
var result = "result";
%_CallFunction(0, 0, function() {});
var dummy = deopt + 0;
- if (osr) while (%GetOptimizationStatus(f) == 2) {}
+ for (var i = 0; osr && i < 2; i++) %OptimizeOsr();
return result;
}
diff --git a/deps/v8/test/mjsunit/regress/regress-1118.js b/deps/v8/test/mjsunit/regress/regress-1118.js
index 4fd23456be..05b192d6f3 100644
--- a/deps/v8/test/mjsunit/regress/regress-1118.js
+++ b/deps/v8/test/mjsunit/regress/regress-1118.js
@@ -41,24 +41,10 @@ var o = new A();
// inlined.
function g() { try { return o.f(); } finally { }}
-// Optimization status (see runtime.cc):
-// 1 - yes, 2 - no, 3 - always, 4 - never.
-
// This function should be optimized via OSR.
function h() {
- var optstatus = %GetOptimizationStatus(h);
- if (optstatus == 4) {
- // Optimizations are globally disabled; just run once.
- g();
- } else {
- // Run for a bit as long as h is unoptimized.
- if (%GetOptimizationStatus(h) != 4) {
- while (%GetOptimizationCount(h) == 0) {
- for (var j = 0; j < 100; j++) g();
- }
- }
- g();
- }
+ for (var i = 0; i < 10; i++) %OptimizeOsr();
+ g();
}
h();
diff --git a/deps/v8/test/mjsunit/regress/regress-2618.js b/deps/v8/test/mjsunit/regress/regress-2618.js
index 363557bff8..b3cfffd92c 100644
--- a/deps/v8/test/mjsunit/regress/regress-2618.js
+++ b/deps/v8/test/mjsunit/regress/regress-2618.js
@@ -30,9 +30,7 @@
function f() {
do {
do {
- for (var i = 0; i < 10000000; i++) {
- // This should run long enough to trigger OSR.
- }
+ for (var i = 0; i < 10; i++) %OptimizeOsr();
} while (false);
} while (false);
}
@@ -57,7 +55,7 @@ function g() {
do {
do {
do {
- for (var i = 0; i < 10000000; i++) { }
+ for (var i = 0; i < 10; i++) %OptimizeOsr();
} while (false);
} while (false);
} while (false);
diff --git a/deps/v8/test/mjsunit/regress/regress-2825.js b/deps/v8/test/mjsunit/regress/regress-2825.js
new file mode 100644
index 0000000000..34348c911b
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-2825.js
@@ -0,0 +1,40 @@
+// 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: --expose-debug-as debug
+
+// Do not edit this file with an editor that replaces \r with \r\n.
+// Variable definitions for i0 through i3 are each terminated with \r.
+function f() {
+ var i0 = 0; var i1 = 1; var i2 = 2; var i3 = 3;
+ var j0 = 0;
+ var j1 = 1;
+ var j2 = 2;
+ var j3 = 3;
+}
+
+Debug = debug.Debug;
+var exception = null;
+var break_point_hit = false;
+
+function listener(event, exec_state, event_data, data) {
+ if (event != Debug.DebugEvent.Break) return;
+ try {
+ break_point_hit = true;
+ assertEquals(" var i2 = 2;", exec_state.frame(0).sourceLineText());
+ } catch (e) {
+ print(e + e.stack);
+ exception = e;
+ }
+}
+
+Debug.setListener(listener);
+
+Debug.setBreakPoint(f, 3, 0);
+
+f();
+
+Debug.setListener(null);
+assertTrue(break_point_hit);
+assertNull(exception);
diff --git a/deps/v8/test/mjsunit/regress/regress-3032.js b/deps/v8/test/mjsunit/regress/regress-3032.js
index ae54543758..9b18e146ce 100644
--- a/deps/v8/test/mjsunit/regress/regress-3032.js
+++ b/deps/v8/test/mjsunit/regress/regress-3032.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-for (var i = 0; i < 1000000; i++) { }
+// Flags: --allow-natives-syntax
+
+for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); }
var xl = 4096;
var z = i % xl;
diff --git a/deps/v8/test/mjsunit/regress/regress-3501.js b/deps/v8/test/mjsunit/regress/regress-3501.js
new file mode 100644
index 0000000000..4b449e458f
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-3501.js
@@ -0,0 +1,11 @@
+// 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-arrow-functions
+
+// See: http://code.google.com/p/v8/issues/detail?id=3501
+
+"use strict";
+let lift = f => (x, k) => k (f (x));
+lift(isNaN);
diff --git a/deps/v8/test/mjsunit/regress/regress-379770.js b/deps/v8/test/mjsunit/regress/regress-379770.js
index a6653c2591..ab1b339f7d 100644
--- a/deps/v8/test/mjsunit/regress/regress-379770.js
+++ b/deps/v8/test/mjsunit/regress/regress-379770.js
@@ -6,9 +6,7 @@
function foo(obj) {
var counter = 1;
- for (var i = 0; i < obj.length; i++) {
- %OptimizeFunctionOnNextCall(foo, "osr");
- }
+ for (var i = 0; i < obj.length; i++) %OptimizeOsr();
counter += obj;
return counter;
}
diff --git a/deps/v8/test/mjsunit/regress/regress-3859.js b/deps/v8/test/mjsunit/regress/regress-3859.js
new file mode 100644
index 0000000000..3248ef14ac
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-3859.js
@@ -0,0 +1,6 @@
+// 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.
+
+assertEquals(1, new Set([NaN, NaN, NaN]).size);
+assertEquals(42, new Map([[NaN, 42]]).get(NaN));
diff --git a/deps/v8/test/mjsunit/regress/regress-3865.js b/deps/v8/test/mjsunit/regress/regress-3865.js
new file mode 100644
index 0000000000..0d1d02f00d
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-3865.js
@@ -0,0 +1,14 @@
+// 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: --allow-natives-syntax
+
+function bar() {
+ var radix = 10;
+ return 21 / radix | 0;
+}
+assertEquals(2, bar());
+assertEquals(2, bar());
+%OptimizeFunctionOnNextCall(bar);
+assertEquals(2, bar());
diff --git a/deps/v8/test/mjsunit/regress/regress-3884.js b/deps/v8/test/mjsunit/regress/regress-3884.js
new file mode 100644
index 0000000000..ecd000f6c7
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-3884.js
@@ -0,0 +1,27 @@
+// 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: --allow-natives-syntax --expose-gc
+
+function f(x) {
+ // TurboFan will hoist the CompareIC for x === 'some_string' and spill it.
+ if (x === 'some_other_string_1' || x === 'some_string') {
+ gc();
+ }
+ if (x === 'some_other_string_2' || x === 'some_string') {
+ gc();
+ }
+ // TurboFan will hoist the CompareIC for x === 1.4 and spill it.
+ if (x === 1.7 || x === 1.4) {
+ gc();
+ }
+ if (x === 1.9 || x === 1.4) {
+ gc();
+ }
+}
+
+%OptimizeFunctionOnNextCall(f);
+
+f('some_other_string_1');
+f(1.7);
diff --git a/deps/v8/test/mjsunit/regress/regress-437713.js b/deps/v8/test/mjsunit/regress/regress-437713.js
new file mode 100644
index 0000000000..704dd3ed8a
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-437713.js
@@ -0,0 +1,26 @@
+// 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: --allow-natives-syntax --enable-slow-asserts
+
+var o1 = {
+ a00:0, a01:0, a02:0, a03:0, a04:0, a05:0, a06:0, a07:0, a08:0, a09:0, a0a:0, a0b:0, a0c:0, a0d:0, a0e:0, a0f:0,
+ a10:0, a11:0, a12:0, a13:0, a14:0, a15:0, a16:0, a17:0, a18:0, a19:0, a1a:0, a1b:0, a1c:0, a1d:0, a1e:0, a1f:0,
+
+ dbl: 0.1,
+
+ some_double: 2.13,
+};
+
+var o2 = {
+ a00:0, a01:0, a02:0, a03:0, a04:0, a05:0, a06:0, a07:0, a08:0, a09:0, a0a:0, a0b:0, a0c:0, a0d:0, a0e:0, a0f:0,
+ a10:0, a11:0, a12:0, a13:0, a14:0, a15:0, a16:0, a17:0, a18:0, a19:0, a1a:0, a1b:0, a1c:0, a1d:0, a1e:0, a1f:0,
+
+ dbl: 0.1,
+
+ boom: [],
+};
+
+o2.boom.push(42);
+assertEquals(42, o2.boom[0]);
diff --git a/deps/v8/test/mjsunit/regress/regress-444805.js b/deps/v8/test/mjsunit/regress/regress-444805.js
new file mode 100644
index 0000000000..5a533acd5e
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-444805.js
@@ -0,0 +1,8 @@
+// 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.
+
+try {
+ load("test/mjsunit/regress/regress-444805.js-script");
+} catch (e) {
+}
diff --git a/deps/v8/test/mjsunit/regress/regress-444805.js-script b/deps/v8/test/mjsunit/regress/regress-444805.js-script
new file mode 100644
index 0000000000..17b233b561
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-444805.js-script
@@ -0,0 +1,11 @@
+// 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.
+
+Error.prepareStackTrace = function(dummyObject, v8StackTrace)
+{
+ throw new Error('boom');
+};
+
+
+throw new Error('just error');
diff --git a/deps/v8/test/mjsunit/regress/regress-446389.js b/deps/v8/test/mjsunit/regress/regress-446389.js
new file mode 100644
index 0000000000..d6006387e4
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-446389.js
@@ -0,0 +1,12 @@
+// 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 runNearStackLimit(f) { function t() { try { t(); } catch(e) { f(); } }; try { t(); } catch(e) {} }
+%OptimizeFunctionOnNextCall(__f_3);
+function __f_3() {
+ var __v_5 = a[0];
+}
+runNearStackLimit(function() { __f_3(); });
diff --git a/deps/v8/test/mjsunit/regress/regress-447526.js b/deps/v8/test/mjsunit/regress/regress-447526.js
new file mode 100644
index 0000000000..9f9396f2ee
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-447526.js
@@ -0,0 +1,25 @@
+// 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 bar() {
+ throw "done";
+}
+
+function foo() {
+ var i;
+ while (i) {
+ while (i) {
+}
+ i++;
+ }
+ while (true) {
+ bar();
+ }
+}
+
+
+%OptimizeFunctionOnNextCall(foo);
+assertThrows(foo);
diff --git a/deps/v8/test/mjsunit/regress/regress-447561.js b/deps/v8/test/mjsunit/regress/regress-447561.js
new file mode 100644
index 0000000000..0d7a321de0
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-447561.js
@@ -0,0 +1,10 @@
+// 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.
+
+__proto__ = /foo/gi;
+assertEquals("foo", source);
+assertTrue(global);
+assertTrue(ignoreCase);
+assertFalse(multiline);
+assertEquals(0, lastIndex);
diff --git a/deps/v8/test/mjsunit/regress/regress-448711.js b/deps/v8/test/mjsunit/regress/regress-448711.js
new file mode 100644
index 0000000000..b7628ab2eb
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-448711.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: --allow-natives-syntax
+
+function f() {
+ this.a = { text: "Hello!" };
+}
+var v4 = new f();
+var v7 = new f();
+v7.b = {};
+Object.defineProperty(v4, '2', {});
+var v6 = new f();
+v6.a = {};
diff --git a/deps/v8/test/mjsunit/regress/regress-449070.js b/deps/v8/test/mjsunit/regress/regress-449070.js
new file mode 100644
index 0000000000..7a0f0a838c
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-449070.js
@@ -0,0 +1,10 @@
+// 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: --allow-natives-syntax
+
+try {
+ %NormalizeElements(this);
+} catch(e) {
+}
diff --git a/deps/v8/test/mjsunit/regress/regress-449291.js b/deps/v8/test/mjsunit/regress/regress-449291.js
new file mode 100644
index 0000000000..fb56027b67
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-449291.js
@@ -0,0 +1,19 @@
+// 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: --allow-natives-syntax
+
+a = {y:1.5};
+a.y = 1093445778;
+b = a.y;
+c = {y:{}};
+
+function f() {
+ return {y: b};
+}
+
+f();
+f();
+%OptimizeFunctionOnNextCall(f);
+assertEquals(f().y, 1093445778);
diff --git a/deps/v8/test/mjsunit/regress/regress-450895.js b/deps/v8/test/mjsunit/regress/regress-450895.js
new file mode 100644
index 0000000000..48aa00d956
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-450895.js
@@ -0,0 +1,9 @@
+// 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: --allow-natives-syntax
+
+var v = new Array();
+Object.freeze(v);
+v = v.concat(0.5);
diff --git a/deps/v8/test/mjsunit/regress/regress-451322.js b/deps/v8/test/mjsunit/regress/regress-451322.js
new file mode 100644
index 0000000000..b7794f52f0
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-451322.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.
+
+// Flags: --allow-natives-syntax
+
+var foo = 0;
+
+function bar() {
+ var baz = 0 - {};
+ if (foo > 24) return baz * 0;
+}
+
+bar();
+bar();
+%OptimizeFunctionOnNextCall(bar);
+bar();
diff --git a/deps/v8/test/mjsunit/regress/regress-451958.js b/deps/v8/test/mjsunit/regress/regress-451958.js
new file mode 100644
index 0000000000..33695f2b3e
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-451958.js
@@ -0,0 +1,31 @@
+// 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: --allow-natives-syntax
+
+function k() { throw "e"; }
+var a = true;
+var a = false;
+function foo(a) {
+ var i, j;
+ if (a) {
+ for (i = 0; i < 1; j++) ;
+ for (i = 0; i < 1; k()) ;
+ for (i = 0; i < 1; i++) ;
+ }
+}
+%OptimizeFunctionOnNextCall(foo);
+foo();
+
+function bar() {
+var __v_45;
+ for (__v_45 = 0; __v_45 < 64; __v_63++) {
+ }
+ for (__v_45 = 0; __v_45 < 128; __v_36++) {
+ }
+ for (__v_45 = 128; __v_45 < 256; __v_45++) {
+ }
+}
+%OptimizeFunctionOnNextCall(bar);
+assertThrows(bar);
diff --git a/deps/v8/test/mjsunit/regress/regress-453481.js b/deps/v8/test/mjsunit/regress/regress-453481.js
new file mode 100644
index 0000000000..2bc9e46433
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-453481.js
@@ -0,0 +1,127 @@
+// 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: --always-opt
+
+var __v_0 = "";
+var __v_1 = {};
+var __v_2 = {};
+var __v_3 = {};
+var __v_4 = {};
+var __v_5 = {};
+var __v_6 = {};
+var __v_7 = {};
+var __v_8 = {};
+var __v_10 = {};
+var __v_13 = {};
+var __v_15 = {};
+var __v_16 = /abc/;
+var __v_17 = {};
+var __v_18 = function() {};
+var __v_19 = this;
+var __v_20 = {};
+var __v_21 = this;
+
+function __f_5(s) {
+ return __f_11(__f_3(__f_7(s), s.length * 8));
+}
+function __f_3(x, len) {
+ var __v_3 = 1732584193;
+ var __v_6 = -271733879;
+ var __v_5 = -1732584194;
+ var __v_7 = 271733892;
+
+ for (var i = 0; i < 1; i++) {
+ var __v_11 = __v_3;
+ var __v_14 = __v_6;
+ var __v_13 = __v_5;
+ var __v_15 = __v_7;
+
+ __v_3 = __f_10(__v_3, __v_6, __v_5, __v_7, x[__v_8+ 0], 6 , -198630844);
+ __v_7 = __f_10(__v_7, __v_3, __v_6, __v_5, x[__v_8+ 7], 10, 1126891415);
+ __v_5 = __f_10(__v_5, __v_7, __v_3, __v_6, x[__v_8+14], 15, -1416354905);
+ __v_6 = __f_10(__v_6, __v_5, __v_7, __v_3, x[__v_8+ 5], 21, -57434055);
+ __v_3 = __f_10(__v_3, __v_6, __v_5, __v_7, x[__v_8+12], 6 , 1700485571);
+ __v_7 = __f_10(__v_7, __v_3, __v_6, __v_5, x[__v_8+ 3], 10, -1894986606);
+ __v_5 = __f_10(__v_5, __v_7, __v_3, __v_6, x[__v_8+10], 15, -1051523);
+ __v_6 = __f_10(__v_6, __v_5, __v_7, __v_3, x[__v_8+ 1], 21, -2054922799);
+ __v_3 = __f_10(__v_3, __v_6, __v_5, __v_7, x[__v_8+ 8], 6 , 1873313359);
+ __v_7 = __f_10(__v_7, __v_3, __v_6, __v_5, x[__v_8+15], 10, -30611744);
+ __v_5 = __f_10(__v_5, __v_7, __v_3, __v_6, x[__v_8+ 22], 14, -1560198371);
+ __v_3 = __f_10(__v_3, __v_6, __v_5, __v_7, x[__v_8+ 4], 6 , -145523070);
+ __v_7 = __f_10(__v_7, __v_3, __v_6, __v_5, x[__v_8+11], 10, -1120210379);
+ __v_5 = __f_10(__v_5, __v_7, __v_3, __v_6, x[__v_8+ 2], 15, 718787259);
+ __v_6 = __f_10(__v_13, __v_5, __v_7, __v_3, x[__v_8+ 9], 21, -343485551);
+ __v_3 = __f_6(__v_3, __v_11);
+ __v_6 = __f_6(__v_6, __v_14);
+ __v_5 = __f_6(__v_5, __v_13);
+ __v_7 = __f_6(__v_7, __v_15);
+
+ }
+
+ return Array(__v_3, __v_13, __v_4, __v_19);
+}
+function __f_4(q, __v_3, __v_6, x, s, t) {
+ return __f_6(__f_12(__f_6(__f_6(__v_3, q), __f_6(x, t)), s),__v_6);
+}
+function __f_13(__v_3, __v_6, __v_5, __v_7, x, s, t) {
+ return __f_4((__v_6 & __v_5) | ((~__v_6) & __v_7), __v_3, __v_6, x, s, t);
+}
+function __f_8(__v_3, __v_6, __v_5, __v_7, x, s, t) {
+ return __f_4((__v_6 & __v_7) | (__v_5 & (~__v_7)), __v_3, __v_6, x, s, t);
+}
+function __f_9(__v_3, __v_6, __v_5, __v_7, x, s, t) {
+ return __f_4(__v_6 ^ __v_5 ^ __v_7, __v_3, __v_6, x, s, t);
+}
+function __f_10(__v_3, __v_6, __v_5, __v_7, x, s, t) {
+ return __f_4(__v_5 ^ (__v_6 | (~__v_7)), __v_3, __v_6, x, s, t);
+}
+function __f_6(x, y) {
+ var __v_12 = (x & 0xFFFF) + (y & 0xFFFF);
+ var __v_18 = (x >> 16) + (y >> 16) + (__v_12 >> 16);
+ return (__v_18 << 16) | (__v_12 & 0xFFFF);
+}
+function __f_12(num, cnt) {
+ return (num << cnt) | (num >>> (32 - cnt));
+}
+function __f_7(__v_16) {
+ var __v_4 = Array();
+ var __v_9 = (1 << 8) - 1;
+ for(var __v_8 = 0; __v_8 < __v_16.length * 8; __v_8 += 8)
+ __v_4[__v_8>>5] |= (__v_16.charCodeAt(__v_8 / 8) & __v_9) << (__v_8%32);
+ return __v_4;
+}
+
+function __f_11(binarray) { return __v_16; }
+
+try {
+__v_10 = "Rebellious subjects, enemies to peace,\n\
+Profaners of this neighbour-stained steel,--\n\
+Will they not hear? What, ho! you men, you beasts,\n\
+That quench the fire of your pernicious rage\n\
+With purple fountains issuing from your veins,\n\
+On pain of torture, from those bloody hands\n\
+Throw your mistemper'__v_7 weapons to the ground,\n\
+And hear the sentence of your moved prince.\n\
+Three civil brawls, bred of an airy word,\n\
+By thee, old Capulet, and Montague,\n\
+Have thrice disturb'__v_7 the quiet of our streets,\n\
+And made Verona's ancient citizens\n\
+Cast by their grave beseeming ornaments,\n\
+To wield old partisans, in hands as old,\n\
+Canker'__v_7 with peace, to part your canker'__v_7 hate:\n\
+If ever you disturb our streets again,\n\
+Your lives shall pay the forfeit of the peace.\n\
+For this time, all the rest depart away:\n\
+You Capulet; shall go along with me:\n\
+And, Montague, come you this afternoon,\n\
+To know our further pleasure in this case,\n\
+To old Free-town, our common judgment-place.\n\
+Once more, on pain of death, all men depart.\n"
+ function assertEquals(a, b) { }
+for (var __v_8 = 0; __v_8 < 11; ++__v_8) {
+ assertEquals(__f_5(__v_10), "1b8719c72d5d8bfd06e096ef6c6288c5");
+}
+
+} catch(e) { print("Caught: " + e); }
diff --git a/deps/v8/test/mjsunit/regress/regress-454725.js b/deps/v8/test/mjsunit/regress/regress-454725.js
new file mode 100644
index 0000000000..a2469d11a0
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-454725.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.
+//
+// Flags: --expose-gc
+
+var __v_9 = {};
+var depth = 15;
+var current = 0;
+
+function __f_15(__v_3) {
+ if ((__v_3 % 50) != 0) {
+ return __v_3;
+ } else {
+ return __v_9 + 0.5;
+ }
+}
+function __f_13(a) {
+ a[100000 - 2] = 1;
+ for (var __v_3= 0; __v_3 < 70000; ++__v_3 ) {
+ a[__v_3] = __f_15(__v_3);
+ }
+}
+function __f_2(size) {
+
+}
+var tmp;
+function __f_18(allocator) {
+ current++;
+ if (current == depth) return;
+ var __v_7 = new allocator(100000);
+ __f_13(__v_7);
+ var __v_4 = 6;
+ for (var __v_3= 0; __v_3 < 70000; __v_3 += 501 ) {
+ tmp += __v_3;
+ }
+ __f_18(Array);
+ current--;
+}
+
+gc();
+__f_18(__f_2);
diff --git a/deps/v8/test/mjsunit/regress/regress-634.js b/deps/v8/test/mjsunit/regress/regress-455212.js
index b68e843740..f2fd033c3d 100644
--- a/deps/v8/test/mjsunit/regress/regress-634.js
+++ b/deps/v8/test/mjsunit/regress/regress-455212.js
@@ -1,4 +1,4 @@
-// Copyright 2010 the V8 project authors. All rights reserved.
+// Copyright 2008 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:
@@ -25,8 +25,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-for (var i = 0; i < 1000000; i++) {
- a = new Array(0);
- assertEquals(0, a.length);
- assertEquals(0, a.length);
-}
+// Typeof expression must resolve to 'undefined' when it used on a
+// non-existing property. It is *not* allowed to throw a
+// ReferenceError.
+
+// eval("\u0060\u005c") is an unterminated template string (\u0060)
+assertThrows("\u0060\u005c", SyntaxError);
diff --git a/deps/v8/test/mjsunit/regress/regress-457935.js b/deps/v8/test/mjsunit/regress/regress-457935.js
new file mode 100644
index 0000000000..d34db05de4
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-457935.js
@@ -0,0 +1,26 @@
+// 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: --allow-natives-syntax
+
+function dummy(x) { };
+
+function g() {
+ return g.arguments;
+}
+
+function f(limit) {
+ var i = 0;
+ var o = {};
+ for (; i < limit; i++) {
+ o.y = +o.y;
+ g();
+ }
+}
+
+f(1);
+f(1);
+%OptimizeFunctionOnNextCall(f);
+dummy(f(1));
+dummy(f(2));
diff --git a/deps/v8/test/mjsunit/regress/regress-458876.js b/deps/v8/test/mjsunit/regress/regress-458876.js
new file mode 100644
index 0000000000..7df0615d64
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-458876.js
@@ -0,0 +1,16 @@
+// 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 module() {
+ "use asm";
+ function foo() {
+ do ; while (foo ? 0 : 1) ;
+ return -1 > 0 ? -1 : 0;
+ }
+ return foo;
+}
+
+var foo = module();
+assertEquals(0, foo());
+assertEquals(0, foo());
diff --git a/deps/v8/test/mjsunit/regress/regress-458987.js b/deps/v8/test/mjsunit/regress/regress-458987.js
new file mode 100644
index 0000000000..f7a7edcef4
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-458987.js
@@ -0,0 +1,16 @@
+// 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 () {
+ "use asm";
+
+ function g() {}
+
+ runNearStackLimit(g);
+})();
+
+function runNearStackLimit(f) {
+ function g() { try { g(); } catch(e) { f(); } };
+ g();
+}
diff --git a/deps/v8/test/mjsunit/regress/regress-459955.js b/deps/v8/test/mjsunit/regress/regress-459955.js
new file mode 100644
index 0000000000..24eff6d40c
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-459955.js
@@ -0,0 +1,10 @@
+// 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 f(x) {
+ var v;
+ if (x) v = 0;
+ return v <= 1;
+}
+assertFalse(f(false));
diff --git a/deps/v8/test/mjsunit/regress/regress-arg-materialize-store.js b/deps/v8/test/mjsunit/regress/regress-arg-materialize-store.js
new file mode 100644
index 0000000000..2a30dc87a3
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-arg-materialize-store.js
@@ -0,0 +1,22 @@
+// 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: --allow-natives-syntax
+
+function f() {
+ return f.arguments;
+}
+
+function g(deopt) {
+ var o = { x : 2 };
+ f();
+ o.x = 1;
+ deopt + 0;
+ return o.x;
+}
+
+g(0);
+g(0);
+%OptimizeFunctionOnNextCall(g);
+assertEquals(1, g({}));
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-150545.js b/deps/v8/test/mjsunit/regress/regress-crbug-150545.js
index 8238d2fa0d..cfee0618ec 100644
--- a/deps/v8/test/mjsunit/regress/regress-crbug-150545.js
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-150545.js
@@ -45,10 +45,7 @@
function outer() {
inner(1,2,3);
- // Trigger OSR, if optimization is not disabled.
- if (%GetOptimizationStatus(outer) != 4) {
- while (%GetOptimizationCount(outer) == 0) {}
- }
+ for (var i = 0; i < 3; i++) %OptimizeOsr();
}
outer();
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-387599.js b/deps/v8/test/mjsunit/regress/regress-crbug-387599.js
index 98750aa918..753dcfa3a6 100644
--- a/deps/v8/test/mjsunit/regress/regress-crbug-387599.js
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-387599.js
@@ -8,9 +8,7 @@ Debug = debug.Debug;
Debug.setListener(function() {});
function f() {
- for (var i = 0; i < 100; i++) {
- %OptimizeFunctionOnNextCall(f, "osr");
- }
+ for (var i = 0; i < 100; i++) %OptimizeOsr();
}
Debug.setBreakPoint(f, 0, 0);
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-448730.js b/deps/v8/test/mjsunit/regress/regress-crbug-448730.js
new file mode 100644
index 0000000000..31d276aa83
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-448730.js
@@ -0,0 +1,14 @@
+// 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: --allow-natives-syntax --harmony-proxies
+
+function bar() {}
+bar({ a: Proxy.create({}) });
+function foo(x) { x.a.b == ""; }
+var x = {a: {b: "" }};
+foo(x);
+foo(x);
+%OptimizeFunctionOnNextCall(foo);
+foo(x);
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-450642.js b/deps/v8/test/mjsunit/regress/regress-crbug-450642.js
new file mode 100644
index 0000000000..7f821e0ffc
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-450642.js
@@ -0,0 +1,5 @@
+// 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.
+
+assertThrows(function() { with (undefined) {} }, TypeError);
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-450960.js b/deps/v8/test/mjsunit/regress/regress-crbug-450960.js
new file mode 100644
index 0000000000..f745522dbe
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-450960.js
@@ -0,0 +1,20 @@
+// 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: --stack-size=70
+
+"a".replace(/a/g, "");
+
+function test() {
+ try {
+ test();
+ } catch(e) {
+ "b".replace(/(b)/g, new []);
+ }
+}
+
+try {
+ test();
+} catch (e) {
+}
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-451013.js b/deps/v8/test/mjsunit/regress/regress-crbug-451013.js
new file mode 100644
index 0000000000..d843d3334b
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-451013.js
@@ -0,0 +1,11 @@
+// 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.
+
+assertThrows(function testDeepArrayLiteral() {
+ testDeepArrayLiteral([], [], [[]]);
+}, RangeError);
+
+assertThrows(function testDeepObjectLiteral() {
+ testDeepObjectLiteral({}, {}, {x:[[]]});
+}, RangeError);
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-451016.js b/deps/v8/test/mjsunit/regress/regress-crbug-451016.js
new file mode 100644
index 0000000000..93152c3665
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-451016.js
@@ -0,0 +1,10 @@
+// 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: --turbo-filter=STRICT_EQUALS
+
+var value = NaN;
+for (i = 0; i < 256; i++) {
+ value === "A" || value === "B";
+}
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-451770.js b/deps/v8/test/mjsunit/regress/regress-crbug-451770.js
new file mode 100644
index 0000000000..942814a316
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-451770.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: --harmony-computed-property-names --harmony-classes --harmony-sloppy
+
+assertThrows(function f() {
+ var t = { toString: function() { throw new Error(); } };
+ var o = { [t]: 23 };
+}, Error);
+
+assertThrows(function f() {
+ var t = { toString: function() { throw new Error(); } };
+ class C { [t]() { return 23; } };
+}, Error);
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-454091.js b/deps/v8/test/mjsunit/regress/regress-crbug-454091.js
new file mode 100644
index 0000000000..2705e96bfd
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-454091.js
@@ -0,0 +1,9 @@
+// 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.
+
+this.__proto__ = Array.prototype;
+Object.freeze(this);
+this.length = 1;
+assertThrows('this.__proto__ = {}');
+assertEquals(Array.prototype, this.__proto__);
diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-455644.js b/deps/v8/test/mjsunit/regress/regress-crbug-455644.js
new file mode 100644
index 0000000000..4993d857a8
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-crbug-455644.js
@@ -0,0 +1,12 @@
+// 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 f() {
+ do { return 23; } while(false);
+ with (0) {
+ try {
+ return 42;
+ } finally {}
+ }
+})();
diff --git a/deps/v8/test/mjsunit/regress/regress-deoptimize-constant-keyed-load.js b/deps/v8/test/mjsunit/regress/regress-deoptimize-constant-keyed-load.js
new file mode 100644
index 0000000000..ed63133c0f
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-deoptimize-constant-keyed-load.js
@@ -0,0 +1,22 @@
+// 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: --allow-natives-syntax
+
+var o = { };
+o.__defineGetter__("progressChanged", function() { %DeoptimizeFunction(f); return 10; })
+
+function g(a, b, c) {
+ return a + b + c;
+}
+
+function f() {
+ var t="progressChanged";
+ return g(1, o[t], 100);
+}
+
+f();
+f();
+%OptimizeFunctionOnNextCall(f);
+assertEquals(111, f());
diff --git a/deps/v8/test/mjsunit/regress/regress-merge-descriptors.js b/deps/v8/test/mjsunit/regress/regress-merge-descriptors.js
index a84a6254a0..98e2f26674 100644
--- a/deps/v8/test/mjsunit/regress/regress-merge-descriptors.js
+++ b/deps/v8/test/mjsunit/regress/regress-merge-descriptors.js
@@ -77,7 +77,7 @@ var SuperCar = ((function (Super) {
}
});
- // Convert self.copy from CONSTANT to FIELD.
+ // Convert self.copy from DATA_CONSTANT to DATA.
self.copy = function () { };
return self;
diff --git a/deps/v8/test/mjsunit/regress/regress-undefined-nan.js b/deps/v8/test/mjsunit/regress/regress-undefined-nan.js
new file mode 100644
index 0000000000..93106c5eb1
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-undefined-nan.js
@@ -0,0 +1,35 @@
+// 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: --allow-natives-syntax
+
+function loader(dst, src, i) {
+ dst[i] = src[i];
+}
+
+var ab = new ArrayBuffer(8);
+var i_view = new Int32Array(ab);
+i_view[0] = 0xFFF7FFFF;
+i_view[1] = 0xFFF7FFFF;
+var f_view = new Float64Array(ab);
+
+var fixed_double_elements = new Float64Array(1);
+
+function opt_store() { fixed_double_elements[0] = f_view[0]; }
+
+opt_store();
+opt_store();
+%OptimizeFunctionOnNextCall(opt_store);
+opt_store();
+
+var i32 = new Int32Array(fixed_double_elements.buffer);
+assertEquals(i_view[0], i32[0]);
+assertEquals(i_view[1], i32[1]);
+
+var doubles = [0.5];
+loader(doubles, fixed_double_elements, 0);
+loader(doubles, fixed_double_elements, 0);
+%OptimizeFunctionOnNextCall(loader);
+loader(doubles, fixed_double_elements, 0);
+assertTrue(doubles[0] !== undefined);
diff --git a/deps/v8/test/mjsunit/regress/regress-undefined-nan2.js b/deps/v8/test/mjsunit/regress/regress-undefined-nan2.js
new file mode 100644
index 0000000000..9b0a05f8fd
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-undefined-nan2.js
@@ -0,0 +1,12 @@
+// 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 foo(a, i) {
+ var o = [0.5,,1];
+ a[i] = o[i];
+}
+var a1 = [0.1,0.1];
+foo(a1, 0);
+foo(a1, 1);
+assertEquals(undefined, a1[1]);
diff --git a/deps/v8/test/mjsunit/regress/regress-undefined-nan3.js b/deps/v8/test/mjsunit/regress/regress-undefined-nan3.js
new file mode 100644
index 0000000000..636b38a110
--- /dev/null
+++ b/deps/v8/test/mjsunit/regress/regress-undefined-nan3.js
@@ -0,0 +1,32 @@
+// 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: --allow-natives-syntax
+
+var ab = new ArrayBuffer(8);
+var i_view = new Int32Array(ab);
+i_view[0] = 0xFFF7FFFF;
+i_view[1] = 0xFFF7FFFF;
+var f_view = new Float64Array(ab);
+
+var fixed_double_elements = new Float64Array(1);
+fixed_double_elements[0] = f_view[0];
+
+function A(src) { this.x = src[0]; }
+
+new A(fixed_double_elements);
+new A(fixed_double_elements);
+
+%OptimizeFunctionOnNextCall(A);
+
+var obj = new A(fixed_double_elements);
+
+function move_x(dst, obj) { dst[0] = obj.x; }
+
+var doubles = [0.5];
+move_x(doubles, obj);
+move_x(doubles, obj);
+%OptimizeFunctionOnNextCall(move_x);
+move_x(doubles, obj);
+assertTrue(doubles[0] !== undefined);
diff --git a/deps/v8/test/mjsunit/regress/string-set-char-deopt.js b/deps/v8/test/mjsunit/regress/string-set-char-deopt.js
index c8e8538e16..03100a3505 100644
--- a/deps/v8/test/mjsunit/regress/string-set-char-deopt.js
+++ b/deps/v8/test/mjsunit/regress/string-set-char-deopt.js
@@ -36,7 +36,7 @@
var world = " world";
%_OneByteSeqStringSetChar(0, (deopt(), 0x48), string);
- if (osr) while (%GetOptimizationStatus(f) == 2) {}
+ for (var i = 0; osr && i < 2; i++) %OptimizeOsr();
return string + world;
}
diff --git a/deps/v8/test/mjsunit/strict-mode.js b/deps/v8/test/mjsunit/strict-mode.js
index 62d003f9fa..d0839ba0fb 100644
--- a/deps/v8/test/mjsunit/strict-mode.js
+++ b/deps/v8/test/mjsunit/strict-mode.js
@@ -169,18 +169,6 @@ assertThrows('\
"use strict";\
}', SyntaxError);
-// Duplicate data properties.
-CheckStrictMode("var x = { dupe : 1, nondupe: 3, dupe : 2 };", SyntaxError);
-CheckStrictMode("var x = { '1234' : 1, '2345' : 2, '1234' : 3 };", SyntaxError);
-CheckStrictMode("var x = { '1234' : 1, '2345' : 2, 1234 : 3 };", SyntaxError);
-CheckStrictMode("var x = { 3.14 : 1, 2.71 : 2, 3.14 : 3 };", SyntaxError);
-CheckStrictMode("var x = { 3.14 : 1, '3.14' : 2 };", SyntaxError);
-CheckStrictMode("var x = { \
- 123: 1, \
- 123.00000000000000000000000000000000000000000000000000000000000000000001: 2 \
-}", SyntaxError);
-
-// Non-conflicting data properties.
(function StrictModeNonDuplicate() {
"use strict";
var x = { 123 : 1, "0123" : 2 };
@@ -191,37 +179,50 @@ CheckStrictMode("var x = { \
};
})();
-// Two getters (non-strict)
-assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError);
-assertThrows("var x = { get foo(){}, get 'foo'(){}};", SyntaxError);
-assertThrows("var x = { get 12(){}, get '12'(){}};", SyntaxError);
-
-// Two setters (non-strict)
-assertThrows("var x = { set foo(v) { }, set foo(v) { } };", SyntaxError);
-assertThrows("var x = { set foo(v) { }, set 'foo'(v) { } };", SyntaxError);
-assertThrows("var x = { set 13(v) { }, set '13'(v) { } };", SyntaxError);
-
-// Setter and data (non-strict)
-assertThrows("var x = { foo: 'data', set foo(v) { } };", SyntaxError);
-assertThrows("var x = { set foo(v) { }, foo: 'data' };", SyntaxError);
-assertThrows("var x = { foo: 'data', set 'foo'(v) { } };", SyntaxError);
-assertThrows("var x = { set foo(v) { }, 'foo': 'data' };", SyntaxError);
-assertThrows("var x = { 'foo': 'data', set foo(v) { } };", SyntaxError);
-assertThrows("var x = { set 'foo'(v) { }, foo: 'data' };", SyntaxError);
-assertThrows("var x = { 'foo': 'data', set 'foo'(v) { } };", SyntaxError);
-assertThrows("var x = { set 'foo'(v) { }, 'foo': 'data' };", SyntaxError);
-assertThrows("var x = { 12: 1, set '12'(v){}};", SyntaxError);
-assertThrows("var x = { 12: 1, set 12(v){}};", SyntaxError);
-assertThrows("var x = { '12': 1, set '12'(v){}};", SyntaxError);
-assertThrows("var x = { '12': 1, set 12(v){}};", SyntaxError);
-
-// Getter and data (non-strict)
-assertThrows("var x = { foo: 'data', get foo() { } };", SyntaxError);
-assertThrows("var x = { get foo() { }, foo: 'data' };", SyntaxError);
-assertThrows("var x = { 'foo': 'data', get foo() { } };", SyntaxError);
-assertThrows("var x = { get 'foo'() { }, 'foo': 'data' };", SyntaxError);
-assertThrows("var x = { '12': 1, get '12'(){}};", SyntaxError);
-assertThrows("var x = { '12': 1, get 12(){}};", SyntaxError);
+// Duplicate data properties are allowed in ES6
+(function StrictModeDuplicateES6() {
+ 'use strict';
+ var x = {
+ 123: 1,
+ 123.00000000000000000000000000000000000000000000000000000000000000000001: 2
+ };
+ var x = { dupe : 1, nondupe: 3, dupe : 2 };
+ var x = { '1234' : 1, '2345' : 2, '1234' : 3 };
+ var x = { '1234' : 1, '2345' : 2, 1234 : 3 };
+ var x = { 3.14 : 1, 2.71 : 2, 3.14 : 3 };
+ var x = { 3.14 : 1, '3.14' : 2 };
+
+ var x = { get foo() { }, get foo() { } };
+ var x = { get foo(){}, get 'foo'(){}};
+ var x = { get 12(){}, get '12'(){}};
+
+ // Two setters
+ var x = { set foo(v) { }, set foo(v) { } };
+ var x = { set foo(v) { }, set 'foo'(v) { } };
+ var x = { set 13(v) { }, set '13'(v) { } };
+
+ // Setter and data
+ var x = { foo: 'data', set foo(v) { } };
+ var x = { set foo(v) { }, foo: 'data' };
+ var x = { foo: 'data', set 'foo'(v) { } };
+ var x = { set foo(v) { }, 'foo': 'data' };
+ var x = { 'foo': 'data', set foo(v) { } };
+ var x = { set 'foo'(v) { }, foo: 'data' };
+ var x = { 'foo': 'data', set 'foo'(v) { } };
+ var x = { set 'foo'(v) { }, 'foo': 'data' };
+ var x = { 12: 1, set '12'(v){}};
+ var x = { 12: 1, set 12(v){}};
+ var x = { '12': 1, set '12'(v){}};
+ var x = { '12': 1, set 12(v){}};
+
+ // Getter and data
+ var x = { foo: 'data', get foo() { } };
+ var x = { get foo() { }, foo: 'data' };
+ var x = { 'foo': 'data', get foo() { } };
+ var x = { get 'foo'() { }, 'foo': 'data' };
+ var x = { '12': 1, get '12'(){}};
+ var x = { '12': 1, get 12(){}};
+})();
// Assignment to eval or arguments
CheckStrictMode("function strict() { eval = undefined; }", SyntaxError);
@@ -291,7 +292,7 @@ CheckStrictMode("const x = 0;", SyntaxError);
CheckStrictMode("for (const x = 0; false;) {}", SyntaxError);
CheckStrictMode("function strict() { const x = 0; }", SyntaxError);
-// Strict mode only allows functions in SourceElements
+// Strict mode only allows functions in StatementList
CheckStrictMode("if (true) { function invalid() {} }", SyntaxError);
CheckStrictMode("for (;false;) { function invalid() {} }", SyntaxError);
CheckStrictMode("{ function invalid() {} }", SyntaxError);
diff --git a/deps/v8/test/mjsunit/strong/classes.js b/deps/v8/test/mjsunit/strong/classes.js
new file mode 100644
index 0000000000..3c7caf5f84
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/classes.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.
+
+// Flags: --strong-mode
+
+'use strong';
+
+class C {}
+
+(function ImmutableClassBindings() {
+ class D {}
+ assertThrows(function(){ eval("C = 0") }, TypeError);
+ assertThrows(function(){ eval("D = 0") }, TypeError);
+ assertEquals('function', typeof C);
+ assertEquals('function', typeof D);
+})();
diff --git a/deps/v8/test/mjsunit/strong/delete.js b/deps/v8/test/mjsunit/strong/delete.js
new file mode 100644
index 0000000000..349af0bf39
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/delete.js
@@ -0,0 +1,11 @@
+// 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: --strong-mode
+
+(function NoDelete() {
+ const o = {a: 0};
+ assertThrows("'use strong'; delete o.a", SyntaxError);
+ assertThrows("'use strong'; delete o", SyntaxError);
+})();
diff --git a/deps/v8/test/mjsunit/strong/empty-statement.js b/deps/v8/test/mjsunit/strong/empty-statement.js
new file mode 100644
index 0000000000..65edf74733
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/empty-statement.js
@@ -0,0 +1,18 @@
+// 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: --strong-mode
+
+(function NoEmptySubStatement() {
+ assertThrows("'use strong'; if (1);", SyntaxError);
+ assertThrows("'use strong'; if (1) {} else;", SyntaxError);
+ assertThrows("'use strong'; while (1);", SyntaxError);
+ assertThrows("'use strong'; do; while (1);", SyntaxError);
+ assertThrows("'use strong'; for (;;);", SyntaxError);
+ assertThrows("'use strong'; for (x in []);", SyntaxError);
+ assertThrows("'use strong'; for (x of []);", SyntaxError);
+ assertThrows("'use strong'; for (let x;;);", SyntaxError);
+ assertThrows("'use strong'; for (let x in []);", SyntaxError);
+ assertThrows("'use strong'; for (let x of []);", SyntaxError);
+})();
diff --git a/deps/v8/test/mjsunit/strong/equality.js b/deps/v8/test/mjsunit/strong/equality.js
new file mode 100644
index 0000000000..5e2464c372
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/equality.js
@@ -0,0 +1,10 @@
+// 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: --strong-mode
+
+(function NoSloppyEquality() {
+ assertThrows("'use strong'; 0 == 0", SyntaxError);
+ assertThrows("'use strong'; 0 != 0", SyntaxError);
+})();
diff --git a/deps/v8/test/mjsunit/strong/for-in.js b/deps/v8/test/mjsunit/strong/for-in.js
new file mode 100644
index 0000000000..8fa9010202
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/for-in.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.
+
+// Flags: --strong-mode
+
+(function NoForInStatement() {
+ assertThrows("'use strong'; for (x in []) {}", SyntaxError);
+ assertThrows("'use strong'; for (let x in []) {}", SyntaxError);
+ assertThrows("'use strong'; for (const x in []) {}", SyntaxError);
+})();
+
+(function ForOfStatement() {
+ assertTrue(eval("'use strong'; for (x of []) {} true"));
+ assertTrue(eval("'use strong'; for (let x of []) {} true"));
+ assertTrue(eval("'use strong'; for (const x of []) {} true"));
+})();
diff --git a/deps/v8/test/mjsunit/strong/functions.js b/deps/v8/test/mjsunit/strong/functions.js
new file mode 100644
index 0000000000..4869ac6dfa
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/functions.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.
+
+// Flags: --strong-mode
+
+'use strong';
+
+(function NoArguments() {
+ assertThrows("'use strong'; arguments", SyntaxError);
+ assertThrows("'use strong'; function f() { arguments }", SyntaxError);
+ assertThrows("'use strong'; let f = function() { arguments }", SyntaxError);
+ assertThrows("'use strong'; let f = () => arguments", SyntaxError);
+ // The following are strict mode errors already.
+ assertThrows("'use strong'; let arguments", SyntaxError);
+ assertThrows("'use strong'; function f(arguments) {}", SyntaxError);
+ assertThrows("'use strong'; let f = (arguments) => {}", SyntaxError);
+})();
+
+function g() {}
+
+(function LexicalFunctionBindings(global) {
+ assertEquals('function', typeof g);
+ assertEquals(undefined, global.g);
+})(this);
+
+(function ImmutableFunctionBindings() {
+ function f() {}
+ assertThrows(function(){ eval("g = 0") }, TypeError);
+ assertThrows(function(){ eval("f = 0") }, TypeError);
+ assertEquals('function', typeof g);
+ assertEquals('function', typeof f);
+})();
diff --git a/deps/v8/test/mjsunit/strong/mutually-recursive-funcs.js b/deps/v8/test/mjsunit/strong/mutually-recursive-funcs.js
new file mode 100644
index 0000000000..726eed839c
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/mutually-recursive-funcs.js
@@ -0,0 +1,25 @@
+// 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: --strong-mode
+
+"use strong";
+
+function foo(param, fooCount, barCount) {
+ if (param === 0)
+ return {'foo': fooCount, 'bar': barCount};
+ return bar(param - 1, fooCount + 1, barCount);
+}
+
+function bar(param, fooCount, barCount) {
+ if (param === 0)
+ return {'foo': fooCount, 'bar': barCount};
+ return foo(param - 1, fooCount, barCount + 1);
+}
+
+(function TestMutuallyRecursiveFunctions() {
+ let obj = foo(10, 0, 0);
+ assertEquals(obj.foo, 5);
+ assertEquals(obj.bar, 5);
+})();
diff --git a/deps/v8/test/mjsunit/strong/use-strong.js b/deps/v8/test/mjsunit/strong/use-strong.js
new file mode 100644
index 0000000000..bbda2662c2
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/use-strong.js
@@ -0,0 +1,27 @@
+// 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: --strong-mode
+
+(function UseStrongScoping() {
+ assertThrows("'use strong'; 0 == 0", SyntaxError);
+ assertThrows("'use strong'; try {} catch(e) { { 0 == 0 } }", SyntaxError);
+ assertThrows("function f() { 'use strong'; 0 == 0 }", SyntaxError);
+ assertThrows("'use strong'; function f() { 0 == 0 }", SyntaxError);
+ assertThrows("'use strong'; function f() { function g() { 0 == 0 } }", SyntaxError);
+ assertThrows("'use strong'; eval('function f() { 0 == 0 }')", SyntaxError);
+ assertTrue(eval("function f() { 'use strong' } 0 == 0"));
+ assertTrue(eval("eval('\\\'use strong\\\''); 0 == 0"));
+})();
+
+(function UseStrongMixed() {
+ assertThrows("'use strict'; 'use strong'; 0 == 0", SyntaxError);
+ assertThrows("'use strong'; 'use strict'; 0 == 0", SyntaxError);
+ assertThrows("'use strong'; 'use strong'; 0 == 0", SyntaxError);
+ assertThrows("'use strict'; function f() { 'use strong'; 0 == 0 }", SyntaxError);
+ assertThrows("'use strong'; function f() { 'use strict'; 0 == 0 }", SyntaxError);
+ assertTrue(eval("'use strict'; function f() { 'use strong' } 0 == 0"));
+ assertTrue(eval("var x; function f() { 'use strong' } delete x"));
+ assertThrows("'use strict'; var x; function f() { 'use strong' } delete x", SyntaxError);
+})();
diff --git a/deps/v8/test/mjsunit/strong/var-let-const.js b/deps/v8/test/mjsunit/strong/var-let-const.js
new file mode 100644
index 0000000000..5545ccfa58
--- /dev/null
+++ b/deps/v8/test/mjsunit/strong/var-let-const.js
@@ -0,0 +1,22 @@
+// 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: --strong-mode
+
+(function NoVar() {
+ assertThrows("'use strong'; var x = 0;", SyntaxError);
+ assertThrows("'use strong'; for(var i = 0; i < 10; ++i) { };", SyntaxError);
+})();
+
+
+(function LetIsOkay() {
+ assertTrue(eval("'use strong'; let x = 0; x === 0;"));
+ assertTrue(eval("'use strong'; for(let i = 0; i < 10; ++i) { } 0 === 0;"));
+})();
+
+
+(function ConstIsOkay() {
+ assertTrue(eval("'use strong'; const x = 0; x === 0;"));
+ assertTrue(eval("'use strong'; for(const i = 0; false;) { } 0 === 0;"));
+})();
diff --git a/deps/v8/test/mjsunit/testcfg.py b/deps/v8/test/mjsunit/testcfg.py
index c960ce6b30..8389696f49 100644
--- a/deps/v8/test/mjsunit/testcfg.py
+++ b/deps/v8/test/mjsunit/testcfg.py
@@ -34,6 +34,7 @@ from testrunner.objects import testcase
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
+MODULE_PATTERN = re.compile(r"^// MODULE$", flags=re.MULTILINE)
class MjsunitTestSuite(testsuite.TestSuite):
@@ -77,7 +78,12 @@ class MjsunitTestSuite(testsuite.TestSuite):
if SELF_SCRIPT_PATTERN.search(source):
env = ["-e", "TEST_FILE_NAME=\"%s\"" % testfilename.replace("\\", "\\\\")]
files = env + files
- files.append(os.path.join(self.root, "mjsunit.js"))
+
+ if not context.no_harness:
+ files.append(os.path.join(self.root, "mjsunit.js"))
+
+ if MODULE_PATTERN.search(source):
+ files.append("--module")
files.append(testfilename)
flags += files
diff --git a/deps/v8/test/mjsunit/tools/tickprocessor-test.default b/deps/v8/test/mjsunit/tools/tickprocessor-test.default
index c2fe441e19..943ec33553 100644
--- a/deps/v8/test/mjsunit/tools/tickprocessor-test.default
+++ b/deps/v8/test/mjsunit/tools/tickprocessor-test.default
@@ -7,7 +7,6 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[JavaScript]:
ticks total nonlib name
- 1 7.7% 11.1% LazyCompile: exp native math.js:41
[C++]:
ticks total nonlib name
@@ -18,7 +17,7 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Summary]:
ticks total nonlib name
- 1 7.7% 11.1% JavaScript
+ 0 0.0% 0.0% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
@@ -45,6 +44,10 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
+ 2 15.4% UNKNOWN
+ 1 50.0% LazyCompile: exp native math.js:41
+ 1 100.0% Script: exp.js
+
1 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
@@ -57,6 +60,3 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
1 100.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
- 1 7.7% LazyCompile: exp native math.js:41
- 1 100.0% Script: exp.js
-
diff --git a/deps/v8/test/mjsunit/tools/tickprocessor-test.ignore-unknown b/deps/v8/test/mjsunit/tools/tickprocessor-test.ignore-unknown
index 263cec551e..1dbf71baa9 100644
--- a/deps/v8/test/mjsunit/tools/tickprocessor-test.ignore-unknown
+++ b/deps/v8/test/mjsunit/tools/tickprocessor-test.ignore-unknown
@@ -7,7 +7,6 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[JavaScript]:
ticks total nonlib name
- 1 9.1% 14.3% LazyCompile: exp native math.js:41
[C++]:
ticks total nonlib name
@@ -18,7 +17,7 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Summary]:
ticks total nonlib name
- 1 9.1% 14.3% JavaScript
+ 0 0.0% 0.0% JavaScript
5 45.5% 71.4% C++
0 0.0% 0.0% GC
4 36.4% Shared libraries
@@ -44,6 +43,10 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
+ 2 18.2% UNKNOWN
+ 1 50.0% LazyCompile: exp native math.js:41
+ 1 100.0% Script: exp.js
+
1 9.1% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
@@ -56,6 +59,3 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
1 100.0% LazyCompile: exp native math.js:41
1 100.0% Script: exp.js
- 1 9.1% LazyCompile: exp native math.js:41
- 1 100.0% Script: exp.js
-
diff --git a/deps/v8/test/mjsunit/tools/tickprocessor-test.separate-ic b/deps/v8/test/mjsunit/tools/tickprocessor-test.separate-ic
index aee1d1f792..52821e7b63 100644
--- a/deps/v8/test/mjsunit/tools/tickprocessor-test.separate-ic
+++ b/deps/v8/test/mjsunit/tools/tickprocessor-test.separate-ic
@@ -9,7 +9,6 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
ticks total nonlib name
1 7.7% 11.1% LoadIC: j
1 7.7% 11.1% LoadIC: i
- 1 7.7% 11.1% LazyCompile: exp native math.js:41
[C++]:
ticks total nonlib name
@@ -20,7 +19,7 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Summary]:
ticks total nonlib name
- 3 23.1% 33.3% JavaScript
+ 2 15.4% 22.2% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
@@ -47,6 +46,10 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
2 100.0% LazyCompile: exp native math.js:41
2 100.0% Script: exp.js
+ 2 15.4% UNKNOWN
+ 1 50.0% LazyCompile: exp native math.js:41
+ 1 100.0% Script: exp.js
+
1 7.7% v8::internal::JSObject::LookupOwnRealNamedProperty(v8::internal::String*, v8::internal::LookupResult*)
1 100.0% Script: exp.js
@@ -63,6 +66,3 @@ Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
1 7.7% LoadIC: i
- 1 7.7% LazyCompile: exp native math.js:41
- 1 100.0% Script: exp.js
-
diff --git a/deps/v8/test/mjsunit/tools/tickprocessor.js b/deps/v8/test/mjsunit/tools/tickprocessor.js
index f460d349bb..b04b9a1765 100644
--- a/deps/v8/test/mjsunit/tools/tickprocessor.js
+++ b/deps/v8/test/mjsunit/tools/tickprocessor.js
@@ -323,7 +323,7 @@ CppEntriesProviderMock.prototype.parseVmSymbols = function(
function PrintMonitor(outputOrFileName) {
- var expectedOut = typeof outputOrFileName == 'string' ?
+ var expectedOut = this.expectedOut = typeof outputOrFileName == 'string' ?
this.loadExpectedOutput(outputOrFileName) : outputOrFileName;
var outputPos = 0;
var diffs = this.diffs = [];
@@ -359,7 +359,10 @@ PrintMonitor.prototype.loadExpectedOutput = function(fileName) {
PrintMonitor.prototype.finish = function() {
print = this.oldPrint;
if (this.diffs.length > 0 || this.unexpectedOut != null) {
+ print("===== actual output: =====");
print(this.realOut.join('\n'));
+ print("===== expected output: =====");
+ print(this.expectedOut.join('\n'));
assertEquals([], this.diffs);
assertNull(this.unexpectedOut);
}
@@ -383,7 +386,8 @@ function driveTickProcessorTest(
stateFilter,
undefined,
"0",
- "auto,auto");
+ "auto,auto",
+ false);
var pm = new PrintMonitor(testsPath + refOutput);
tp.processLogFileInTest(testsPath + logInput);
tp.printStatistics();