diff options
Diffstat (limited to 'deps/v8/test/mjsunit/es6')
40 files changed, 1391 insertions, 106 deletions
diff --git a/deps/v8/test/mjsunit/es6/array-iterator.js b/deps/v8/test/mjsunit/es6/array-iterator.js index 767991eafe..5fab0fbf86 100644 --- a/deps/v8/test/mjsunit/es6/array-iterator.js +++ b/deps/v8/test/mjsunit/es6/array-iterator.js @@ -47,6 +47,9 @@ function TestArrayPrototype() { assertHasOwnProperty(Array.prototype, 'entries', DONT_ENUM); assertHasOwnProperty(Array.prototype, 'keys', DONT_ENUM); assertHasOwnProperty(Array.prototype, Symbol.iterator, DONT_ENUM); + assertEquals('entries', Array.prototype.entries.name); + assertEquals('keys', Array.prototype.keys.name); + assertEquals('values', Array.prototype[Symbol.iterator].name); } TestArrayPrototype(); diff --git a/deps/v8/test/mjsunit/es6/array-reverse-order.js b/deps/v8/test/mjsunit/es6/array-reverse-order.js new file mode 100644 index 0000000000..590491cb68 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/array-reverse-order.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. + +// ES6 specifically says that elements should be checked with [[HasElement]] before +// [[Get]]. This is observable in case a getter deletes elements. ES5 put the +// [[HasElement]] after the [[Get]]. + +assertTrue(1 in Array.prototype.reverse.call( + {length:2, get 0(){delete this[0];}, 1: "b"})) diff --git a/deps/v8/test/mjsunit/es6/block-conflicts.js b/deps/v8/test/mjsunit/es6/block-conflicts.js index fdd581dd70..0e3d4e5a2a 100644 --- a/deps/v8/test/mjsunit/es6/block-conflicts.js +++ b/deps/v8/test/mjsunit/es6/block-conflicts.js @@ -79,7 +79,11 @@ var letbinds = [ "let x;", "const x = function() {};", "const x = 2, y = 3;", "const y = 4, x = 5;", + "class x { }", ]; +function forCompatible(bind) { + return !bind.startsWith('class'); +} var varbinds = [ "var x;", "var x = 0;", "var x = undefined;", @@ -101,7 +105,9 @@ for (var l = 0; l < letbinds.length; ++l) { TestNoConflict(varbinds[v] + '{' + letbinds[l] + '}'); TestNoConflict('{' + letbinds[l] + '}' + varbinds[v]); // For loop. - TestConflict('for (' + letbinds[l] + '0;) {' + varbinds[v] + '}'); + if (forCompatible(letbinds[l])) { + TestConflict('for (' + letbinds[l] + '0;) {' + varbinds[v] + '}'); + } TestNoConflict('for (' + varbinds[v] + '0;) {' + letbinds[l] + '}'); } @@ -114,8 +120,12 @@ for (var l = 0; l < letbinds.length; ++l) { TestNoConflict(letbinds[l] + '{ ' + letbinds[k] + '}'); TestNoConflict('{' + letbinds[k] +'} ' + letbinds[l]); // For loop. - TestNoConflict('for (' + letbinds[l] + '0;) {' + letbinds[k] + '}'); - TestNoConflict('for (' + letbinds[k] + '0;) {' + letbinds[l] + '}'); + if (forCompatible(letbinds[l])) { + TestNoConflict('for (' + letbinds[l] + '0;) {' + letbinds[k] + '}'); + } + if (forCompatible(letbinds[k])) { + TestNoConflict('for (' + letbinds[k] + '0;) {' + letbinds[l] + '}'); + } } // Test conflicting function/let bindings. @@ -128,7 +138,9 @@ for (var l = 0; l < letbinds.length; ++l) { TestNoConflict(funbind + '{' + letbinds[l] + '}'); TestNoConflict('{' + letbinds[l] + '}' + funbind); // For loop. - TestNoConflict('for (' + letbinds[l] + '0;) {' + funbind + '}'); + if (forCompatible(letbinds[l])) { + TestNoConflict('for (' + letbinds[l] + '0;) {' + funbind + '}'); + } // Test conflicting parameter/let bindings. TestConflict('(function(x) {' + letbinds[l] + '})();'); diff --git a/deps/v8/test/mjsunit/es6/block-const-assign.js b/deps/v8/test/mjsunit/es6/block-const-assign.js index f78faa689d..541dc0d97b 100644 --- a/deps/v8/test/mjsunit/es6/block-const-assign.js +++ b/deps/v8/test/mjsunit/es6/block-const-assign.js @@ -25,8 +25,6 @@ // (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-computed-property-names - // Test that we throw early syntax errors in harmony mode // when using an immutable binding in an assigment or with // prefix/postfix decrement/increment operators. diff --git a/deps/v8/test/mjsunit/es6/block-leave.js b/deps/v8/test/mjsunit/es6/block-leave.js index 338631b76e..4c63b77319 100644 --- a/deps/v8/test/mjsunit/es6/block-leave.js +++ b/deps/v8/test/mjsunit/es6/block-leave.js @@ -175,7 +175,7 @@ try { // Verify that the context is correctly set in the stack frame after exiting -// from with. +// from eval. function f() {} (function(x) { diff --git a/deps/v8/test/mjsunit/es6/block-let-declaration.js b/deps/v8/test/mjsunit/es6/block-let-declaration.js index 5fbb12824b..a138144d18 100644 --- a/deps/v8/test/mjsunit/es6/block-let-declaration.js +++ b/deps/v8/test/mjsunit/es6/block-let-declaration.js @@ -33,17 +33,20 @@ let x; let y = 2; const z = 4; +class c { static foo() { return 1; } } // Block local { let y; let x = 3; const z = 5; + class c { static foo() { return 2; } } } assertEquals(undefined, x); assertEquals(2,y); assertEquals(4,z); +assertEquals(1, c.foo()); if (true) { let y; @@ -106,6 +109,16 @@ TestLocalDoesNotThrow("for (;false;) var x;"); TestLocalDoesNotThrow("switch (true) { case true: var x; }"); TestLocalDoesNotThrow("switch (true) { default: var x; }"); +// Test class declarations with initialisers in statement positions. +TestLocalThrows("if (true) class x { };", SyntaxError); +TestLocalThrows("if (true) {} else class x { };", SyntaxError); +TestLocalThrows("do class x { }; while (false)", SyntaxError); +TestLocalThrows("while (false) class x { };", SyntaxError); +TestLocalThrows("label: class x { };", SyntaxError); +TestLocalThrows("for (;false;) class x { };", SyntaxError); +TestLocalDoesNotThrow("switch (true) { case true: class x { }; }"); +TestLocalDoesNotThrow("switch (true) { default: class x { }; }"); + // Test that redeclarations of functions are only allowed in outermost scope. TestLocalThrows("{ let f; var f; }"); TestLocalThrows("{ var f; let f; }"); @@ -113,9 +126,13 @@ TestLocalThrows("{ function f() {} let f; }"); TestLocalThrows("{ let f; function f() {} }"); TestLocalThrows("{ function f() {} var f; }"); TestLocalThrows("{ var f; function f() {} }"); +TestLocalThrows("{ function f() {} class f {} }"); +TestLocalThrows("{ class f {}; function f() {} }"); TestLocalThrows("{ function f() {} function f() {} }"); TestLocalThrows("function f() {} let f;"); TestLocalThrows("let f; function f() {}"); +TestLocalThrows("function f() {} class f {}"); +TestLocalThrows("class f {}; function f() {}"); TestLocalDoesNotThrow("function arg() {}"); TestLocalDoesNotThrow("function f() {} var f;"); TestLocalDoesNotThrow("var f; function f() {}"); diff --git a/deps/v8/test/mjsunit/es6/block-let-semantics.js b/deps/v8/test/mjsunit/es6/block-let-semantics.js index b0a826a007..59eec1ceea 100644 --- a/deps/v8/test/mjsunit/es6/block-let-semantics.js +++ b/deps/v8/test/mjsunit/es6/block-let-semantics.js @@ -70,6 +70,7 @@ TestAll('x += 1; let x;'); TestAll('++x; let x;'); TestAll('x++; let x;'); TestAll('let y = x; const x = 1;'); +TestAll('let y = x; class x {}'); TestAll('f(); let x; function f() { return x + 1; }'); TestAll('f(); let x; function f() { x = 1; }'); @@ -77,6 +78,7 @@ TestAll('f(); let x; function f() { x += 1; }'); TestAll('f(); let x; function f() { ++x; }'); TestAll('f(); let x; function f() { x++; }'); TestAll('f(); const x = 1; function f() { return x; }'); +TestAll('f(); class x { }; function f() { return x; }'); TestAll('f()(); let x; function f() { return function() { return x + 1; } }'); TestAll('f()(); let x; function f() { return function() { x = 1; } }'); @@ -84,21 +86,24 @@ TestAll('f()(); let x; function f() { return function() { x += 1; } }'); TestAll('f()(); let x; function f() { return function() { ++x; } }'); TestAll('f()(); let x; function f() { return function() { x++; } }'); TestAll('f()(); const x = 1; function f() { return function() { return x; } }'); - -// Use before initialization with a dynamic lookup. -TestAll('eval("x + 1;"); let x;'); -TestAll('eval("x = 1;"); let x;'); -TestAll('eval("x += 1;"); let x;'); -TestAll('eval("++x;"); let x;'); -TestAll('eval("x++;"); let x;'); -TestAll('eval("x"); const x = 1;'); - -// Use before initialization with check for eval-shadowed bindings. -TestAll('function f() { eval("var y = 2;"); x + 1; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); x = 1; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); x += 1; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); ++x; }; f(); let x;'); -TestAll('function f() { eval("var y = 2;"); x++; }; f(); let x;'); +TestAll('f()(); class x { }; function f() { return function() { return x; } }'); + +for (var kw of ['let x = 2', 'const x = 2', 'class x { }']) { + // Use before initialization with a dynamic lookup. + TestAll(`eval("x"); ${kw};`); + TestAll(`eval("x + 1;"); ${kw};`); + TestAll(`eval("x = 1;"); ${kw};`); + TestAll(`eval("x += 1;"); ${kw};`); + TestAll(`eval("++x;"); ${kw};`); + TestAll(`eval("x++;"); ${kw};`); + + // Use before initialization with check for eval-shadowed bindings. + TestAll(`function f() { eval("var y = 2;"); x + 1; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); x = 1; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); x += 1; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); ++x; }; f(); ${kw};`); + TestAll(`function f() { eval("var y = 2;"); x++; }; f(); ${kw};`); +} // Test that variables introduced by function declarations are created and // initialized upon entering a function / block scope. diff --git a/deps/v8/test/mjsunit/es6/block-scoping.js b/deps/v8/test/mjsunit/es6/block-scoping.js index 5f481b8bf2..719f5231ce 100644 --- a/deps/v8/test/mjsunit/es6/block-scoping.js +++ b/deps/v8/test/mjsunit/es6/block-scoping.js @@ -49,15 +49,19 @@ function f2(one) { var x = one + 1; let y = one + 2; const u = one + 4; + class a { static foo() { return one + 6; } } { let z = one + 3; const v = one + 5; + class b { static foo() { return one + 7; } } assertEquals(1, eval('one')); assertEquals(2, eval('x')); assertEquals(3, eval('y')); assertEquals(4, eval('z')); assertEquals(5, eval('u')); assertEquals(6, eval('v')); + assertEquals(7, eval('a.foo()')); + assertEquals(8, eval('b.foo()')); } } @@ -68,15 +72,19 @@ function f3(one) { var x = one + 1; let y = one + 2; const u = one + 4; + class a { static foo() { return one + 6; } } { let z = one + 3; const v = one + 5; + class b { static foo() { return one + 7; } } assertEquals(1, one); assertEquals(2, x); assertEquals(3, y); assertEquals(4, z); assertEquals(5, u); assertEquals(6, v); + assertEquals(7, a.foo()); + assertEquals(8, b.foo()); } } for (var j = 0; j < 5; ++j) f3(1); @@ -91,9 +99,11 @@ function f4(one) { var x = one + 1; let y = one + 2; const u = one + 4; + class a { static foo() { return one + 6; } } { let z = one + 3; const v = one + 5; + class b { static foo() { return one + 7; } } function f() { assertEquals(1, eval('one')); assertEquals(2, eval('x')); @@ -101,6 +111,8 @@ function f4(one) { assertEquals(4, eval('z')); assertEquals(5, eval('u')); assertEquals(6, eval('v')); + assertEquals(7, eval('a.foo()')); + assertEquals(8, eval('b.foo()')); } f(); } @@ -113,9 +125,11 @@ function f5(one) { var x = one + 1; let y = one + 2; const u = one + 4; + class a { static foo() { return one + 6; } } { let z = one + 3; const v = one + 5; + class b { static foo() { return one + 7; } } function f() { assertEquals(1, one); assertEquals(2, x); @@ -123,6 +137,8 @@ function f5(one) { assertEquals(4, z); assertEquals(5, u); assertEquals(6, v); + assertEquals(7, a.foo()); + assertEquals(8, b.foo()); } f(); } @@ -149,25 +165,43 @@ function f7(a) { var c = 1; var d = 1; const e = 1; - { // let variables shadowing argument, let, const and var variables + class f { static foo() { return 1; } } + { // let variables shadowing argument, let, const, class and var variables let a = 2; let b = 2; let c = 2; let e = 2; + let f = 2; assertEquals(2,a); assertEquals(2,b); assertEquals(2,c); assertEquals(2,e); + assertEquals(2,f); } { // const variables shadowing argument, let, const and var variables const a = 2; const b = 2; const c = 2; const e = 2; + const f = 2; assertEquals(2,a); assertEquals(2,b); assertEquals(2,c); assertEquals(2,e); + assertEquals(2,f); + } + { // class variables shadowing argument, let, const and var variables + class a { static foo() { return 2; } } + class b { static foo() { return 2; } } + class c { static foo() { return 2; } } + class d { static foo() { return 2; } } + class e { static foo() { return 2; } } + class f { static foo() { return 2; } } + assertEquals(2,a.foo()); + assertEquals(2,b.foo()); + assertEquals(2,c.foo()); + assertEquals(2,e.foo()); + assertEquals(2,f.foo()); } try { throw 'stuff1'; @@ -225,16 +259,18 @@ function f7(a) { c = 2; } assertEquals(1,c); - (function(a,b,c,e) { - // arguments shadowing argument, let, const and var variable + (function(a,b,c,e,f) { + // arguments shadowing argument, let, const, class and var variable a = 2; b = 2; c = 2; e = 2; + f = 2; assertEquals(2,a); assertEquals(2,b); assertEquals(2,c); assertEquals(2,e); + assertEquals(2,f); // var variable shadowing var variable var d = 2; })(1,1); @@ -243,6 +279,7 @@ function f7(a) { assertEquals(1,c); assertEquals(1,d); assertEquals(1,e); + assertEquals(1,f.foo()); } f7(1); @@ -253,19 +290,23 @@ function f8() { var let_accessors = []; var var_accessors = []; var const_accessors = []; + var class_accessors = []; for (var i = 0; i < 10; i++) { let x = i; var y = i; const z = i; + class a { static foo() { return x; } } let_accessors[i] = function() { return x; } var_accessors[i] = function() { return y; } const_accessors[i] = function() { return z; } + class_accessors[i] = function() { return a; } } for (var j = 0; j < 10; j++) { y = j + 10; assertEquals(j, let_accessors[j]()); assertEquals(y, var_accessors[j]()); assertEquals(j, const_accessors[j]()); + assertEquals(j, class_accessors[j]().foo()); } } f8(); diff --git a/deps/v8/test/mjsunit/es6/class-computed-property-names-super.js b/deps/v8/test/mjsunit/es6/class-computed-property-names-super.js new file mode 100644 index 0000000000..cb9f25157c --- /dev/null +++ b/deps/v8/test/mjsunit/es6/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-sloppy +// Flags: --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/es6/computed-property-names-classes.js b/deps/v8/test/mjsunit/es6/computed-property-names-classes.js new file mode 100644 index 0000000000..eebf99aef5 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/computed-property-names-classes.js @@ -0,0 +1,461 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +'use strict'; + + +function 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', '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', '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', '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() { + assertThrows(function() { + class C { + static ['prototype']() { + return 1; + } + } + }, TypeError); + + assertThrows(function() { + class C2 { + static get ['prototype']() { + return 2; + } + } + }, TypeError); + + assertThrows(function() { + class C3 { + static set ['prototype'](x) { + assertEquals(3, x); + } + } + }, TypeError); + + assertThrows(function() { + class C4 { + static *['prototype']() { + yield 1; + yield 2; + } + } + }, TypeError); +})(); + + +(function TestPrototypeConcat() { + assertThrows(function() { + class C { + static ['pro' + 'tot' + 'ype']() { + return 1; + } + } + }, TypeError); + + assertThrows(function() { + class C2 { + static get ['pro' + 'tot' + 'ype']() { + return 2; + } + } + }, TypeError); + + assertThrows(function() { + class C3 { + static set ['pro' + 'tot' + 'ype'](x) { + assertEquals(3, x); + } + } + }, TypeError); + + assertThrows(function() { + class C4 { + static *['pro' + 'tot' + 'ype']() { + yield 1; + yield 2; + } + } + }, TypeError); +})(); + + +(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()); +})(); + + +(function TestExceptionInName() { + function MyError() {}; + function throwMyError() { + throw new MyError(); + } + assertThrows(function() { + class C { + [throwMyError()]() {} + } + }, MyError); + assertThrows(function() { + class C { + get [throwMyError()]() { return 42; } + } + }, MyError); + assertThrows(function() { + class C { + set [throwMyError()](_) { } + } + }, MyError); +})(); + + +(function TestTdzName() { + assertThrows(function() { + class C { + [C]() {} + } + }, ReferenceError); + assertThrows(function() { + class C { + get [C]() { return 42; } + } + }, ReferenceError); + assertThrows(function() { + class C { + set [C](_) { } + } + }, ReferenceError); +})(); diff --git a/deps/v8/test/mjsunit/es6/computed-property-names-deopt.js b/deps/v8/test/mjsunit/es6/computed-property-names-deopt.js new file mode 100644 index 0000000000..2f3a597f11 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/computed-property-names-deopt.js @@ -0,0 +1,30 @@ +// 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 TestProtoDeopt() { + var proto = {}; + + function deoptMe() { + %DeoptimizeFunction(f); + return proto; + } + + function checkObject(name, value, o) { + assertSame(proto, Object.getPrototypeOf(o)); + assertTrue(o.hasOwnProperty(name)); + assertEquals(value, o[name]); + } + + function f(name, value) { + return { [name]: value, __proto__: deoptMe() }; + } + + checkObject("a", 1, f("a", 1)); + checkObject("b", 2, f("b", 2)); + %OptimizeFunctionOnNextCall(f); + checkObject("c", 3, f("c", 3)); +})(); diff --git a/deps/v8/test/mjsunit/es6/computed-property-names-object-literals-methods.js b/deps/v8/test/mjsunit/es6/computed-property-names-object-literals-methods.js new file mode 100644 index 0000000000..a5f380ceac --- /dev/null +++ b/deps/v8/test/mjsunit/es6/computed-property-names-object-literals-methods.js @@ -0,0 +1,119 @@ +// 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 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/es6/computed-property-names-super.js b/deps/v8/test/mjsunit/es6/computed-property-names-super.js new file mode 100644 index 0000000000..40b0eab942 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/computed-property-names-super.js @@ -0,0 +1,78 @@ +// 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 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/es6/computed-property-names.js b/deps/v8/test/mjsunit/es6/computed-property-names.js new file mode 100644 index 0000000000..d75278cfe3 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/computed-property-names.js @@ -0,0 +1,356 @@ +// 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 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)); +})(); + + +(function TestExceptionInName() { + function MyError() {}; + function throwMyError() { + throw new MyError(); + } + assertThrows(function() { + var o = { + [throwMyError()]: 42 + }; + }, MyError); + assertThrows(function() { + var o = { + get [throwMyError()]() { return 42; } + }; + }, MyError); + assertThrows(function() { + var o = { + set [throwMyError()](_) { } + }; + }, MyError); +})(); + + +(function TestNestedLiterals() { + var array = [ + 42, + { a: 'A', + ['b']: 'B', + c: 'C', + [ID('d')]: 'D', + }, + 43, + ]; + assertEquals(42, array[0]); + assertEquals(43, array[2]); + assertEquals('A', array[1].a); + assertEquals('B', array[1].b); + assertEquals('C', array[1].c); + assertEquals('D', array[1].d); + var object = { + outer: 42, + inner: { + a: 'A', + ['b']: 'B', + c: 'C', + [ID('d')]: 'D', + }, + outer2: 43, + }; + assertEquals(42, object.outer); + assertEquals(43, object.outer2); + assertEquals('A', object.inner.a); + assertEquals('B', object.inner.b); + assertEquals('C', object.inner.c); + assertEquals('D', object.inner.d); + var object = { + outer: 42, + array: [ + 43, + { a: 'A', + ['b']: 'B', + c: 'C', + [ID('d')]: 'D', + }, + 44, + ], + outer2: 45 + }; + assertEquals(42, object.outer); + assertEquals(45, object.outer2); + assertEquals(43, object.array[0]); + assertEquals(44, object.array[2]); + assertEquals('A', object.array[1].a); + assertEquals('B', object.array[1].b); + assertEquals('C', object.array[1].c); + assertEquals('D', object.array[1].d); +})(); diff --git a/deps/v8/test/mjsunit/es6/debug-blockscopes.js b/deps/v8/test/mjsunit/es6/debug-blockscopes.js index 31208d41f4..3f890ebd54 100644 --- a/deps/v8/test/mjsunit/es6/debug-blockscopes.js +++ b/deps/v8/test/mjsunit/es6/debug-blockscopes.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 --allow-natives-syntax // The functions used for testing backtraces. They are at the top to make the // testing of source line/column easier. @@ -187,6 +187,14 @@ function CheckScopeContent(content, number, exec_state) { } +function assertEqualsUnlessOptimized(expected, value, f) { + try { + assertEquals(expected, value); + } catch (e) { + assertOptimized(f); + } +} + // Simple empty block scope in local scope. BeginTest("Local block 1"); @@ -517,11 +525,11 @@ function shadowing_1() { { let i = 5; debugger; - assertEquals(27, i); + assertEqualsUnlessOptimized(27, i, shadowing_1); } assertEquals(0, i); debugger; - assertEquals(27, i); + assertEqualsUnlessOptimized(27, i, shadowing_1); } listener_delegate = function (exec_state) { @@ -538,9 +546,9 @@ function shadowing_2() { { let j = 5; debugger; - assertEquals(27, j); + assertEqualsUnlessOptimized(27, j, shadowing_2); } - assertEquals(0, i); + assertEqualsUnlessOptimized(0, i, shadowing_2); } listener_delegate = function (exec_state) { diff --git a/deps/v8/test/mjsunit/es6/debug-function-scopes.js b/deps/v8/test/mjsunit/es6/debug-function-scopes.js index e7049ee3c0..c1a20e7b9e 100644 --- a/deps/v8/test/mjsunit/es6/debug-function-scopes.js +++ b/deps/v8/test/mjsunit/es6/debug-function-scopes.js @@ -45,7 +45,7 @@ function CheckScope(scope_mirror, scope_expectations, expected_scope_type) { } } -// A copy of the scope types from mirror-debugger.js. +// A copy of the scope types from debug/mirrors.js. var ScopeType = { Global: 0, Local: 1, With: 2, diff --git a/deps/v8/test/mjsunit/es6/debug-promises/events.js b/deps/v8/test/mjsunit/es6/debug-promises/events.js index a9f94543f4..3fcb22ff27 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/events.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/events.js @@ -116,9 +116,7 @@ function testDone(iteration) { } var iteration = iteration || 0; - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-all.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-all.js index 0fca57730a..fd4770ebee 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-all.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-all.js @@ -63,10 +63,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-by-default-reject-handler.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-by-default-reject-handler.js index 63151df016..b7c5861c1f 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-by-default-reject-handler.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-by-default-reject-handler.js @@ -77,10 +77,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-all.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-all.js index beaf1878fe..0b0c0c8e38 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-all.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-all.js @@ -60,10 +60,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-late.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-late.js index 4a883da13a..db58790e39 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-late.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-late.js @@ -67,10 +67,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js index 86e2a815e7..ac23b48b6f 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js @@ -60,10 +60,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js index fc6233da8d..fa263458c4 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js @@ -66,10 +66,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js index 15e464ec60..6b7dc1a77c 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js @@ -78,10 +78,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js index d11c01ff73..4c57cf0237 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js @@ -66,10 +66,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-all.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-all.js index 2fbf05141d..bd6d343f82 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-all.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-all.js @@ -62,10 +62,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.js index 36b5565e5f..3c30ad3f7c 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.js @@ -78,10 +78,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-all.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-all.js index 72f800bf5b..c4bc6c44e3 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-all.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-all.js @@ -61,10 +61,7 @@ function testDone(iteration) { } } - // Rerun testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js index 69aa8ebbd2..ba82a1f8cb 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js @@ -61,10 +61,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js index 1ea1c7f9ff..bd39a155cc 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js @@ -81,10 +81,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-with-undefined-reject.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-with-undefined-reject.js index 94dcdffa22..c88feb9c39 100644 --- a/deps/v8/test/mjsunit/es6/debug-promises/throw-with-undefined-reject.js +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-with-undefined-reject.js @@ -79,10 +79,7 @@ function testDone(iteration) { } } - // Run testDone through the Object.observe processing loop. - var dummy = {}; - Object.observe(dummy, checkResult); - dummy.dummy = dummy; + %EnqueueMicrotask(checkResult); } testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js b/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js index 8dbdb3457a..98510ff52b 100644 --- a/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js +++ b/deps/v8/test/mjsunit/es6/debug-stepin-microtasks.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Flags: --harmony-object-observe // Flags: --allow-natives-syntax --expose-debug-as debug Debug = debug.Debug diff --git a/deps/v8/test/mjsunit/es6/microtask-delivery.js b/deps/v8/test/mjsunit/es6/microtask-delivery.js index f74385e635..01b971ddc0 100644 --- a/deps/v8/test/mjsunit/es6/microtask-delivery.js +++ b/deps/v8/test/mjsunit/es6/microtask-delivery.js @@ -25,6 +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-object-observe // Flags: --allow-natives-syntax var ordering = []; diff --git a/deps/v8/test/mjsunit/es6/promises.js b/deps/v8/test/mjsunit/es6/promises.js index 63b6d2f94a..19239b601b 100644 --- a/deps/v8/test/mjsunit/es6/promises.js +++ b/deps/v8/test/mjsunit/es6/promises.js @@ -29,7 +29,6 @@ // Make sure we don't rely on functions patchable by monkeys. var call = Function.prototype.call.call.bind(Function.prototype.call) -var observe = Object.observe; var getOwnPropertyNames = Object.getOwnPropertyNames; var defineProperty = Object.defineProperty; var numberPrototype = Number.prototype; @@ -87,19 +86,15 @@ function assertAsync(b, s) { } function assertAsyncDone(iteration) { - var iteration = iteration || 0 - var dummy = {} - observe(dummy, - function() { - if (asyncAssertsExpected === 0) - assertAsync(true, "all") - else if (iteration > 10) // Shouldn't take more. - assertAsync(false, "all") - else - assertAsyncDone(iteration + 1) - } - ) - dummy.dummy = dummy + var iteration = iteration || 0; + %EnqueueMicrotask(function() { + if (asyncAssertsExpected === 0) + assertAsync(true, "all") + else if (iteration > 10) // Shouldn't take more. + assertAsync(false, "all") + else + assertAsyncDone(iteration + 1) + }); } diff --git a/deps/v8/test/mjsunit/es6/regress/regress-3750.js b/deps/v8/test/mjsunit/es6/regress/regress-3750.js index a425def2b7..10509bff51 100644 --- a/deps/v8/test/mjsunit/es6/regress/regress-3750.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-3750.js @@ -1,6 +1,8 @@ // 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-object-observe 'use strict'; class Example { } diff --git a/deps/v8/test/mjsunit/es6/regress/regress-cr512574.js b/deps/v8/test/mjsunit/es6/regress/regress-cr512574.js new file mode 100644 index 0000000000..2c10e19315 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/regress/regress-cr512574.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: --harmony-destructuring + +function f({}) { + for (var v in []); +}; diff --git a/deps/v8/test/mjsunit/es6/templates.js b/deps/v8/test/mjsunit/es6/templates.js index feb7364613..621b06074e 100644 --- a/deps/v8/test/mjsunit/es6/templates.js +++ b/deps/v8/test/mjsunit/es6/templates.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-unicode - var num = 5; var str = "str"; function fn() { return "result"; } diff --git a/deps/v8/test/mjsunit/es6/typedarray-set-length.js b/deps/v8/test/mjsunit/es6/typedarray-set-length.js new file mode 100644 index 0000000000..6dd5bf76e0 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/typedarray-set-length.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. + +var typedArrayConstructors = [ + Uint8Array, + Int8Array, + Uint16Array, + Int16Array, + Uint32Array, + Int32Array, + Uint8ClampedArray, + Float32Array, + Float64Array +]; + +var lengthCalled = false; +function lengthValue() { + assertFalse(lengthCalled); + lengthCalled = true; + return 5; +} + +// ToLength should convert these to usable lengths. +var goodNonIntegerLengths = [ + function() { return 4.6; }, + function() { return -5; }, + function() { return NaN; }, + function() { return "5"; }, + function() { return "abc"; }, + function() { return true; }, + function() { return null; }, + function() { return undefined; } +]; + +// This will fail if you use ToLength on it. +function badNonIntegerLength() { + return Symbol("5"); +} + +for (var constructor of typedArrayConstructors) { + lengthCalled = false; + var a = new constructor(10); + a.set({length: {valueOf: lengthValue}}); + assertTrue(lengthCalled); + + for (var lengthFun of goodNonIntegerLengths) { + a.set({length: {valueOf: lengthFun}}); + } + + assertThrows(function() { + a.set({length: {valueOf: badNonIntegerLength}}); + }, TypeError); +} diff --git a/deps/v8/test/mjsunit/es6/typedarray.js b/deps/v8/test/mjsunit/es6/typedarray.js index ef7955ce92..7b1cc06e1c 100644 --- a/deps/v8/test/mjsunit/es6/typedarray.js +++ b/deps/v8/test/mjsunit/es6/typedarray.js @@ -417,6 +417,7 @@ var typedArrayConstructors = [ function TestPropertyTypeChecks(constructor) { function CheckProperty(name) { + assertThrows(function() { 'use strict'; new constructor(10)[name] = 0; }) var d = Object.getOwnPropertyDescriptor(constructor.prototype, name); var o = {}; assertThrows(function() {d.get.call(o);}, TypeError); @@ -756,3 +757,13 @@ TestArbitrary(new DataView(new ArrayBuffer(256))); // Test direct constructor call assertThrows(function() { ArrayBuffer(); }, TypeError); assertThrows(function() { DataView(new ArrayBuffer()); }, TypeError); + +function TestNonConfigurableProperties(constructor) { + var arr = new constructor([100]) + assertFalse(Object.getOwnPropertyDescriptor(arr,"0").configurable) + assertFalse(delete arr[0]) +} + +for(i = 0; i < typedArrayConstructors.length; i++) { + TestNonConfigurableProperties(typedArrayConstructors[i]); +} diff --git a/deps/v8/test/mjsunit/es6/unicode-escapes.js b/deps/v8/test/mjsunit/es6/unicode-escapes.js new file mode 100644 index 0000000000..be269366cf --- /dev/null +++ b/deps/v8/test/mjsunit/es6/unicode-escapes.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. + +// ES6 extends the \uxxxx escape and also allows \u{xxxxx}. + +// Unicode escapes in variable names. + +(function TestVariableNames1() { + var foobar = 1; + assertEquals(foob\u0061r, 1); + assertEquals(foob\u{0061}r, 1); + assertEquals(foob\u{61}r, 1); + assertEquals(foob\u{0000000061}r, 1); +})(); + +(function TestVariableNames2() { + var foobar = 1; + assertEquals(\u0066oobar, 1); + assertEquals(\u{0066}oobar, 1); + assertEquals(\u{66}oobar, 1); + assertEquals(\u{0000000066}oobar, 1); +})(); + +// Unicode escapes in strings. + +(function TestStrings() { + var s1 = "foob\u0061r"; + assertEquals(s1, "foobar"); + var s2 = "foob\u{0061}r"; + assertEquals(s2, "foobar"); + var s3 = "foob\u{61}r"; + assertEquals(s3, "foobar"); + var s4 = "foob\u{0000000061}r"; + assertEquals(s4, "foobar"); +})(); + + +(function TestSurrogates() { + // U+10E6D corresponds to the surrogate pair [U+D803, U+DE6D]. + var s1 = "foo\u{10e6d}"; + var s2 = "foo\u{d803}\u{de6d}"; + assertEquals(s1, s2); +})(); |