Commit e261540b authored by littledan's avatar littledan Committed by Commit bot

Add class to existing lexical scoping tests

This patch strengthens testing of classes by verifying that the binding
that they export externally follows block scoping, as opposed to var-style
scoping. The tests are based on existing tests for let and const.

R=adamk
LOG=N
BUG=v8:3305

Review URL: https://codereview.chromium.org/1286923002

Cr-Commit-Position: refs/heads/master@{#30140}
parent a904b569
......@@ -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] + '})();');
......
......@@ -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() {}");
......
......@@ -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,22 +86,23 @@ 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; } }');
TestAll('f()(); class x { }; function f() { return function() { return x; } }');
for (var kw of ['let', 'const']) {
for (var kw of ['let x = 2', 'const x = 2', 'class x { }']) {
// Use before initialization with a dynamic lookup.
TestAll(`eval("x"); ${kw} x = 2;`);
TestAll(`eval("x + 1;"); ${kw} x = 2;`);
TestAll(`eval("x = 1;"); ${kw} x = 2;`);
TestAll(`eval("x += 1;"); ${kw} x = 2;`);
TestAll(`eval("++x;"); ${kw} x = 2;`);
TestAll(`eval("x++;"); ${kw} x = 2;`);
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} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); x = 1; }; f(); ${kw} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); x += 1; }; f(); ${kw} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); ++x; }; f(); ${kw} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); x++; }; f(); ${kw} x = 2;`);
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
......
......@@ -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();
......@@ -81,7 +81,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;",
......@@ -103,7 +107,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] + '}');
}
......@@ -116,8 +122,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.
......@@ -130,7 +140,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] + '})();');
......
......@@ -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() {}");
......
......@@ -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,22 +86,23 @@ 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; } }');
TestAll('f()(); class x { }; function f() { return function() { return x; } }');
for (var kw of ['let', 'const']) {
for (var kw of ['let x = 2', 'const x = 2', 'class x { }']) {
// Use before initialization with a dynamic lookup.
TestAll(`eval("x"); ${kw} x = 2;`);
TestAll(`eval("x + 1;"); ${kw} x = 2;`);
TestAll(`eval("x = 1;"); ${kw} x = 2;`);
TestAll(`eval("x += 1;"); ${kw} x = 2;`);
TestAll(`eval("++x;"); ${kw} x = 2;`);
TestAll(`eval("x++;"); ${kw} x = 2;`);
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} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); x = 1; }; f(); ${kw} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); x += 1; }; f(); ${kw} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); ++x; }; f(); ${kw} x = 2;`);
TestAll(`function f() { eval("var y = 2;"); x++; }; f(); ${kw} x = 2;`);
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
......
......@@ -47,15 +47,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()'));
}
}
......@@ -66,15 +70,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);
......@@ -89,9 +97,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'));
......@@ -99,6 +109,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();
}
......@@ -111,9 +123,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);
......@@ -121,6 +135,8 @@ function f5(one) {
assertEquals(4, z);
assertEquals(5, u);
assertEquals(6, v);
assertEquals(7, a.foo());
assertEquals(8, b.foo());
}
f();
}
......@@ -147,25 +163,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';
......@@ -223,16 +257,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);
......@@ -241,6 +277,7 @@ function f7(a) {
assertEquals(1,c);
assertEquals(1,d);
assertEquals(1,e);
assertEquals(1,f.foo());
}
f7(1);
......@@ -251,19 +288,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();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment