Bug 1083458 - Remove expression closures from tests. r=jandem

--HG--
extra : rebase_source : d20246f9d855c9d1cc883d1b9516561405348eb2
extra : histedit_source : 492352a4e3e3aa7edca557a95f1c9bc38814e76c
This commit is contained in:
Tom Schuster 2018-03-21 19:06:17 +01:00
parent 3d059d5b19
commit 7241fe1308
12 changed files with 0 additions and 360 deletions

View File

@ -1102,14 +1102,6 @@ function test_syntax(postfixes, check_error, ignore_opts) {
// ==== Legacy ====
// Expression closures
enableExpressionClosures();
test("function f() 1 ");
test("function f() 1; ");
test("(function () 1 ");
test("(function () 1); ");
// ==== asm.js ====
test("(function() { 'use asm'; ");

View File

@ -1,12 +1,6 @@
load(libdir + "asm.js");
load(libdir + "asserts.js");
enableExpressionClosures();
assertAsmTypeFail(USE_ASM + 'function f() 0');
assertAsmTypeFail(USE_ASM + 'function f() 0; return 0');
assertAsmTypeFail(USE_ASM + 'function f() 0; return f');
assertAsmTypeFail(USE_ASM);
assertAsmTypeFail(USE_ASM + 'return');
assertAsmTypeFail(USE_ASM + 'function f(){}');

View File

@ -10,7 +10,3 @@ f = Function("");
assertEq(f.toString(), "function anonymous(\n) {\n\n}");
f = Function("", "(abc)");
assertEq(f.toString(), "function anonymous(\n) {\n(abc)\n}");
enableExpressionClosures();
f = Function("", "return function (a,b) a + b;")();
assertEq(f.toString(), "function (a,b) a + b");

View File

@ -1,34 +0,0 @@
enableExpressionClosures();
eval(`
function f1(foo, bar) foo + bar;
assertEq(f1.toString(), "function f1(foo, bar) foo + bar");
assertEq(f1.toString(), f1.toSource());
assertEq(decompileFunction(f1), f1.toString());
// No semicolon on purpose
function f2(foo, bar) foo + bar
assertEq(f2.toString(), "function f2(foo, bar) foo + bar");
assertEq(f2.toString(), f2.toSource());
var f3 = function (foo, bar) foo + bar;
assertEq(f3.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f3.toString(), "function (foo, bar) foo + bar");
// No semicolon on purpose
var f4 = function (foo, bar) foo + bar
assertEq(f4.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f4.toString(), "function (foo, bar) foo + bar");
var f5 = function (foo, bar) foo + bar ;
assertEq(f5.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f5.toString(), "function (foo, bar) foo + bar");
var f6 = function (foo, bar) foo + bar; var a = 42
assertEq(f6.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f6.toString(), "function (foo, bar) foo + bar");
var f7 = function (foo, bar) foo + bar + '\
long\
string\
test\
'
// a comment followed by some space
assertEq(f7.toString(), "function (foo, bar) foo + bar + '\\\nlong\\\nstring\\\ntest\\\n'");
assertEq(f7.toSource(), "(" + f7.toString() + ")");
`);

View File

@ -1,44 +0,0 @@
enableExpressionClosures();
eval(`
m = {
i() {},
n() {},
d() {},
n() {},
n() {},
n() {},
s() {}
};
function c()
function ()
function ()
function ()
function ()[{
f() {}
}, {
v() {}
}, {
n() {}
}, {
v() {}
}, {
f() {}
}, {
n() {}
}, {
n() {}
}, {
n() {}
}, {
n() {}
}, {
v() {}
}, {
n() {}
}, {
n() {}
}];
t = function () {};
getLcovInfo();
relazifyFunctions();
`);

View File

@ -1,11 +0,0 @@
enableExpressionClosures();
eval(`
function f() {
// The expression closure is deliberate here, testing the semicolon after
// one when it appears as a FunctionDeclaration from B.3.4
// FunctionDeclarations in IfStatement Statement Clauses.
if (0)
function g() x;
else;
}
f();`)

View File

@ -1,65 +0,0 @@
// Expression closure should be warned once and only once.
var release_or_beta = getBuildConfiguration().release_or_beta;
enableExpressionClosures();
function testWarn(code) {
if (release_or_beta) {
// Warning for expression closure is non-release-only (not Release/Beta).
testPass(code);
return;
}
enableLastWarning();
var g = newGlobal();
g.code = code;
g.eval('eval(code)');
var warning = getLastWarning();
assertEq(warning !== null, true, "warning should be caught for " + code);
assertEq(warning.name, "Warning");
clearLastWarning();
g.eval('eval(code)');
warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for 2nd ocurrence");
clearLastWarning();
g = newGlobal();
g.code = code;
g.eval('Reflect.parse(code);');
warning = getLastWarning();
assertEq(warning !== null, true, "warning should be caught for " + code);
assertEq(warning.name, "Warning");
clearLastWarning();
g.eval('Reflect.parse(code);');
warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for 2nd ocurrence");
disableLastWarning();
}
function testPass(code) {
enableLastWarning();
var g = newGlobal();
g.code = code;
g.eval('eval(code)');
var warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for " + code);
clearLastWarning();
g = newGlobal();
g.code = code;
g.eval('Reflect.parse(code);');
warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for " + code);
disableLastWarning();
}
testWarn("function f() 1");
testWarn("(function() 1)");
testWarn("({ get x() 1 })");
testWarn("({ set x(v) 1 })");
testPass("function f() { 1 }");
testPass("() => 1");

View File

@ -1,83 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// ArrowFunctions with block bodies appearing at the end of the
// AssignmentExpression returned by SpiderMonkey-specific function expression
// closures, where subsequent token-examination must use the Operand modifier
// to avoid an assertion.
enableExpressionClosures();
eval(`
var ec1 = function() 0 ? 1 : a => {};
assertEq(typeof ec1, "function");
assertEq(typeof ec1(), "function");
assertEq(ec1()(), undefined);
function inFunction1()
{
var ec1f = function() 0 ? 1 : a => {};
assertEq(typeof ec1f, "function");
assertEq(typeof ec1f(), "function");
assertEq(ec1f()(), undefined);
}
inFunction1();
var ec2 = function() 0 ? 1 : a => {} // deliberately exercise ASI here
assertEq(typeof ec2, "function");
assertEq(typeof ec2(), "function");
assertEq(ec2()(), undefined);
function inFunction2()
{
var ec2f = function() 0 ? 1 : a => {} // deliberately exercise ASI here
assertEq(typeof ec2f, "function");
assertEq(typeof ec2f(), "function");
assertEq(ec2f()(), undefined);
}
inFunction2();
function ec3() 0 ? 1 : a => {} // exercise ASI here
assertEq(typeof ec3(), "function");
function inFunction3()
{
function ec3f() 0 ? 1 : a => {} // exercise ASI here
assertEq(typeof ec3f(), "function");
}
inFunction3();
function ec4() 0 ? 1 : a => {};
assertEq(typeof ec4(), "function");
function inFunction4()
{
function ec4f() 0 ? 1 : a => {};
assertEq(typeof ec4f(), "function");
}
var needle = "@";
var x = 42;
var g = { test() { assertEq(true, false, "shouldn't be called"); } };
function ec5() 0 ? 1 : a => {} // ASI
/x/g.test((needle = "x"));
assertEq(needle, "x");
function inFunction5()
{
var needle = "@";
var x = 42;
var g = { test() { assertEq(true, false, "shouldn't be called"); } };
function ec5f() 0 ? 1 : a => {} // ASI
/x/g.test((needle = "x"));
assertEq(needle, "x");
}
inFunction5();
`);
if (typeof reportCompare === "function")
reportCompare(true, true);

View File

@ -1,28 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
* Contributor: Brendan Eich
*/
var summary = "Flat expression closure source coordinate fencepost test";
enableExpressionClosures();
eval(`
function f(a) {
if (a) {
let b = 42;
let c = function () a+b;
++b;
return c;
}
return null;
}
var expect = 44;
var actual = f(1)();
`);
reportCompare(expect, actual, summary);

View File

@ -1,28 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
* Contributor: Brendan Eich
*/
var summary = "Partial flat expression closure upvar order test";
enableExpressionClosures();
eval(`
function f(a) {
if (a) {
let b = 42;
let c = function () b+a;
++b;
return c;
}
return null;
}
var expect = 44;
var actual = f(1)();
`);
reportCompare(expect, actual, summary);

View File

@ -1,13 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
function test() {
// expression closures
enableExpressionClosures();
assertDecl("function inc(x) (x + 1)", funDecl(ident("inc"), [ident("x")], binExpr("+", ident("x"), lit(1))));
assertExpr("(function(x) (x+1))", funExpr(null, [ident("x")], binExpr("+", ident("x"), lit(1))));
}
runtest(test);

View File

@ -1,36 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 384758;
var summary = 'Statement can not follow expression closure with out intervening ;';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
printBugNumber(BUGNUMBER);
printStatus (summary);
enableExpressionClosures();
expect = 'SyntaxError: unexpected token: identifier';
try
{
eval('(function() { if(t) function x() foo() bar(); })');
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary);
}