From 1d96e257842d07783ff15bef60eea98c7fc8342d Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Sat, 3 Feb 2018 23:12:16 -0500 Subject: [PATCH] Refactor function literal tests for parsers A number of tests for the parsing of function literals were expressed using `eval`. This made the tests more complex than necessary and also prevented the tests from providing value to ECMAScript parsers. Remove the use of `eval` in the relevant tests and instead express the expectations with literal source text. --- .../function/name-arguments-non-strict.js | 2 +- .../function/name-arguments-strict-body.js | 10 ++-- .../function/name-arguments-strict.js | 10 ++-- .../function/name-eval-non-strict.js | 2 +- .../function/name-eval-strict-body.js | 10 ++-- .../expressions/function/name-eval-strict.js | 10 ++-- .../function/param-arguments-non-strict.js | 2 +- .../function/param-duplicated-non-strict.js | 2 +- .../function/param-duplicated-strict-1.js | 8 +-- .../function/param-duplicated-strict-2.js | 8 +-- .../function/param-duplicated-strict-3.js | 8 +-- .../param-duplicated-strict-body-1.js | 8 +-- .../param-duplicated-strict-body-2.js | 8 +-- .../param-duplicated-strict-body-3.js | 8 +-- .../function/param-eval-non-strict.js | 2 +- .../function/param-eval-strict-body.js | 8 +-- .../function/enable-strict-via-body.js | 21 ++++---- .../function/enable-strict-via-outer-body.js | 21 ++++---- .../enable-strict-via-outer-script.js | 17 ++++--- .../statements/function/invalid-2-names.js | 8 +-- .../statements/function/invalid-3-names.js | 8 +-- .../function/invalid-function-body-1.js | 17 +++++++ .../function/invalid-function-body-2.js | 17 +++++++ .../function/invalid-function-body-3.js | 17 +++++++ .../function/invalid-function-body.js | 49 ------------------- .../statements/function/invalid-name-dot.js | 10 ++-- .../function/invalid-name-two-dots.js | 11 +++-- .../function/line-terminator-non-strict.js | 8 ++- .../function/line-terminator-strict.js | 10 +++- .../function/name-arguments-non-strict.js | 2 +- .../function/name-arguments-strict-body.js | 8 +-- .../function/name-arguments-strict.js | 8 +-- .../function/name-eval-non-strict.js | 2 +- .../function/name-eval-strict-body.js | 8 +-- .../statements/function/name-eval-strict.js | 8 +-- .../function/param-arguments-non-strict.js | 2 +- .../function/param-arguments-strict-body.js | 8 +-- .../function/param-arguments-strict.js | 8 +-- .../function/param-duplicated-non-strict.js | 2 +- .../function/param-duplicated-strict-1.js | 8 +-- .../function/param-duplicated-strict-2.js | 8 +-- .../function/param-duplicated-strict-3.js | 8 +-- .../param-duplicated-strict-body-1.js | 8 +-- .../param-duplicated-strict-body-2.js | 8 +-- .../param-duplicated-strict-body-3.js | 8 +-- .../function/param-eval-non-strict.js | 2 +- .../function/param-eval-strict-body.js | 8 +-- .../statements/function/param-eval-strict.js | 8 +-- 48 files changed, 260 insertions(+), 182 deletions(-) create mode 100644 test/language/statements/function/invalid-function-body-1.js create mode 100644 test/language/statements/function/invalid-function-body-2.js create mode 100644 test/language/statements/function/invalid-function-body-3.js delete mode 100644 test/language/statements/function/invalid-function-body.js diff --git a/test/language/expressions/function/name-arguments-non-strict.js b/test/language/expressions/function/name-arguments-non-strict.js index 6e2d9e0ba6..ecfe0b8687 100644 --- a/test/language/expressions/function/name-arguments-non-strict.js +++ b/test/language/expressions/function/name-arguments-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("(function arguments (){});"); +(function arguments (){}); diff --git a/test/language/expressions/function/name-arguments-strict-body.js b/test/language/expressions/function/name-arguments-strict-body.js index 8e9a3fccb8..542026bf01 100644 --- a/test/language/expressions/function/name-arguments-strict-body.js +++ b/test/language/expressions/function/name-arguments-strict-body.js @@ -7,10 +7,12 @@ description: > StrictMode - SyntaxError is thrown if 'arguments' occurs as the Identifier of a FunctionExpression whose FunctionBody is contained in strict code +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ - var _13_1_42_s = {}; -assert.throws(SyntaxError, function() { - eval("_13_1_42_s.x = function arguments() {'use strict';};"); -}); +throw "Test262: This statement should not be evaluated."; + +(function arguments() {'use strict';}); diff --git a/test/language/expressions/function/name-arguments-strict.js b/test/language/expressions/function/name-arguments-strict.js index 902419038b..a88dd86db4 100644 --- a/test/language/expressions/function/name-arguments-strict.js +++ b/test/language/expressions/function/name-arguments-strict.js @@ -6,10 +6,12 @@ es5id: 13.1-14-s description: > StrictMode - SyntaxError is thrown if 'arguments' occurs as the Identifier of a FunctionExpression in strict mode +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ - var _13_1_14_s = {}; -assert.throws(SyntaxError, function() { - eval("_13_1_14_s.x = function arguments() {};"); -}); +throw "Test262: This statement should not be evaluated."; + +(function arguments() {}); diff --git a/test/language/expressions/function/name-eval-non-strict.js b/test/language/expressions/function/name-eval-non-strict.js index d3b2f6bf72..0b136c2859 100644 --- a/test/language/expressions/function/name-eval-non-strict.js +++ b/test/language/expressions/function/name-eval-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("(function eval(){});"); +(function eval(){}); diff --git a/test/language/expressions/function/name-eval-strict-body.js b/test/language/expressions/function/name-eval-strict-body.js index ac4db793dd..c373e46171 100644 --- a/test/language/expressions/function/name-eval-strict-body.js +++ b/test/language/expressions/function/name-eval-strict-body.js @@ -7,10 +7,12 @@ description: > StrictMode - SyntaxError is thrown if 'eval' occurs as the Identifier of a FunctionExpression whose FunctionBody is contained in strict code +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ - var _13_1_38_s = {}; -assert.throws(SyntaxError, function() { - eval("_13_1_38_s.x = function eval() {'use strict'; };"); -}); +throw "Test262: This statement should not be evaluated."; + +(function eval() {'use strict';}); diff --git a/test/language/expressions/function/name-eval-strict.js b/test/language/expressions/function/name-eval-strict.js index 9ab5a3d727..d1e81dd1c9 100644 --- a/test/language/expressions/function/name-eval-strict.js +++ b/test/language/expressions/function/name-eval-strict.js @@ -6,10 +6,12 @@ es5id: 13.1-12-s description: > StrictMode - SyntaxError is thrown if 'eval' occurs as the Identifier of a FunctionExpression in strict mode +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ - var _13_1_12_s = {}; -assert.throws(SyntaxError, function() { - eval("_13_1_12_s.x = function eval() {};"); -}); +throw "Test262: This statement should not be evaluated."; + +(function eval() {}); diff --git a/test/language/expressions/function/param-arguments-non-strict.js b/test/language/expressions/function/param-arguments-non-strict.js index 8db8bf9b22..e3a9167fb5 100644 --- a/test/language/expressions/function/param-arguments-non-strict.js +++ b/test/language/expressions/function/param-arguments-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("(function foo(arguments){});"); +(function foo(arguments){}); diff --git a/test/language/expressions/function/param-duplicated-non-strict.js b/test/language/expressions/function/param-duplicated-non-strict.js index 0db6d3ba79..a1710392db 100644 --- a/test/language/expressions/function/param-duplicated-non-strict.js +++ b/test/language/expressions/function/param-duplicated-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval('(function foo(a,a){})'); +(function foo(a,a){}); diff --git a/test/language/expressions/function/param-duplicated-strict-1.js b/test/language/expressions/function/param-duplicated-strict-1.js index 3f38c146aa..a1233a6956 100644 --- a/test/language/expressions/function/param-duplicated-strict-1.js +++ b/test/language/expressions/function/param-duplicated-strict-1.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if a function is created in 'strict mode' using a FunctionExpression and the function has two identical parameters +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("var _13_1_8_fun = function (param, param) { };"); -}); +(function (param, param) { }); diff --git a/test/language/expressions/function/param-duplicated-strict-2.js b/test/language/expressions/function/param-duplicated-strict-2.js index b107b86238..c4bd88ffc6 100644 --- a/test/language/expressions/function/param-duplicated-strict-2.js +++ b/test/language/expressions/function/param-duplicated-strict-2.js @@ -12,10 +12,12 @@ description: > 'strict mode' using a FunctionExpression and the function has two identical parameters, which are separated by a unique parameter name +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("var _13_1_9_fun = function (param1, param2, param1) { };"); -}); +(function (param1, param2, param1) { }); diff --git a/test/language/expressions/function/param-duplicated-strict-3.js b/test/language/expressions/function/param-duplicated-strict-3.js index c744d7ad8d..0f8b4df2e8 100644 --- a/test/language/expressions/function/param-duplicated-strict-3.js +++ b/test/language/expressions/function/param-duplicated-strict-3.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if a function is created in 'strict mode' using a FunctionExpression and the function has three identical parameters +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("var _13_1_10_fun = function (param, param, param) { };") -}); +(function (param, param, param) { }); diff --git a/test/language/expressions/function/param-duplicated-strict-body-1.js b/test/language/expressions/function/param-duplicated-strict-body-1.js index 3434df2d15..08c11c65c5 100644 --- a/test/language/expressions/function/param-duplicated-strict-body-1.js +++ b/test/language/expressions/function/param-duplicated-strict-body-1.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if a function is created using a FunctionExpression whose FunctionBody is contained in strict code and the function has two identical parameters +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("var _13_1_30_fun = function (param, param) { 'use strict'; };"); -}); +(function (param, param) { 'use strict'; }); diff --git a/test/language/expressions/function/param-duplicated-strict-body-2.js b/test/language/expressions/function/param-duplicated-strict-body-2.js index e7ff3ebca1..5d286c9c7f 100644 --- a/test/language/expressions/function/param-duplicated-strict-body-2.js +++ b/test/language/expressions/function/param-duplicated-strict-body-2.js @@ -12,10 +12,12 @@ description: > a FunctionExpression whose FunctionBody is strict and the function has two identical parameters, which are separated by a unique parameter name +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("var _13_1_32_fun = function (param1, param2, param1) { 'use strict'; };"); -}); +(function (param1, param2, param1) { 'use strict'; }); diff --git a/test/language/expressions/function/param-duplicated-strict-body-3.js b/test/language/expressions/function/param-duplicated-strict-body-3.js index a4d45d00cc..27807ffaf7 100644 --- a/test/language/expressions/function/param-duplicated-strict-body-3.js +++ b/test/language/expressions/function/param-duplicated-strict-body-3.js @@ -10,10 +10,12 @@ es5id: 13.1-34-s description: > Strict Mode - SyntaxError is thrown if a function declaration has three identical parameters with a strict mode body +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("var _13_1_34_fun = function (param, param, param) { 'use strict'; };") -}); +(function (param, param, param) { 'use strict'; }); diff --git a/test/language/expressions/function/param-eval-non-strict.js b/test/language/expressions/function/param-eval-non-strict.js index c3e856734f..29161ccf09 100644 --- a/test/language/expressions/function/param-eval-non-strict.js +++ b/test/language/expressions/function/param-eval-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("(function foo(eval){});"); +(function foo(eval){}); diff --git a/test/language/expressions/function/param-eval-strict-body.js b/test/language/expressions/function/param-eval-strict-body.js index a3df9f85c8..8b237ad055 100644 --- a/test/language/expressions/function/param-eval-strict-body.js +++ b/test/language/expressions/function/param-eval-strict-body.js @@ -11,10 +11,12 @@ description: > StrictMode - SyntaxError is thrown if the identifier 'eval' appears within a FormalParameterList of a strict mode FunctionExpression when FuctionBody is strict code +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("var _13_1_18_fun = function (eval) { 'use strict'; }"); -}); +(function (eval) { 'use strict'; }); diff --git a/test/language/statements/function/enable-strict-via-body.js b/test/language/statements/function/enable-strict-via-body.js index b476325727..5a7a830be2 100644 --- a/test/language/statements/function/enable-strict-via-body.js +++ b/test/language/statements/function/enable-strict-via-body.js @@ -10,16 +10,17 @@ description: > Strict Mode - SourceElements is evaluated as strict mode code when the code of this FunctionBody with an inner function contains a Use Strict Directive +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ - function _13_0_10_fun() { - function _13_0_10_inner() { - "use strict"; - eval("eval = 42;"); - } - _13_0_10_inner(); - }; -assert.throws(SyntaxError, function() { - _13_0_10_fun(); -}); +throw "Test262: This statement should not be evaluated."; + +function _13_0_10_fun() { + function _13_0_10_inner() { + "use strict"; + eval = 42; + } +} diff --git a/test/language/statements/function/enable-strict-via-outer-body.js b/test/language/statements/function/enable-strict-via-outer-body.js index 393033ff13..efd168aa46 100644 --- a/test/language/statements/function/enable-strict-via-outer-body.js +++ b/test/language/statements/function/enable-strict-via-outer-body.js @@ -10,16 +10,17 @@ description: > Strict Mode - SourceElements is evaluated as strict mode code when the code of this FunctionBody with an inner function which is in strict mode +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ - function _13_0_11_fun() { - "use strict"; - function _13_0_11_inner() { - eval("eval = 42;"); - } - _13_0_11_inner(); - }; -assert.throws(SyntaxError, function() { - _13_0_11_fun(); -}); +throw "Test262: This statement should not be evaluated."; + +function _13_0_11_fun() { + "use strict"; + function _13_0_11_inner() { + eval = 42; + } +} diff --git a/test/language/statements/function/enable-strict-via-outer-script.js b/test/language/statements/function/enable-strict-via-outer-script.js index da2066e989..f2f01d1e29 100644 --- a/test/language/statements/function/enable-strict-via-outer-script.js +++ b/test/language/statements/function/enable-strict-via-outer-script.js @@ -10,13 +10,16 @@ description: > Strict Mode - SourceElements is evaluated as strict mode code when a FunctionDeclaration that is contained in strict mode code has an inner function +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ - var _13_0_9_fun = function () { - function _13_0_9_inner() { eval("eval = 42;"); } - _13_0_9_inner(); - }; -assert.throws(SyntaxError, function() { - _13_0_9_fun(); -}); +throw "Test262: This statement should not be evaluated."; + +var _13_0_9_fun = function () { + function _13_0_9_inner() { + eval = 42; + } +}; diff --git a/test/language/statements/function/invalid-2-names.js b/test/language/statements/function/invalid-2-names.js index 33b5fd66e8..f7af44a721 100644 --- a/test/language/statements/function/invalid-2-names.js +++ b/test/language/statements/function/invalid-2-names.js @@ -6,9 +6,11 @@ es5id: 13.0-1 description: > 13.0 - multiple names in one function declaration is not allowed, two function names +negative: + phase: parse + type: SyntaxError ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function x, y() {}"); -}); +function x, y() {} diff --git a/test/language/statements/function/invalid-3-names.js b/test/language/statements/function/invalid-3-names.js index 7a3712f061..4d19df15de 100644 --- a/test/language/statements/function/invalid-3-names.js +++ b/test/language/statements/function/invalid-3-names.js @@ -6,9 +6,11 @@ es5id: 13.0-2 description: > 13.0 - multiple names in one function declaration is not allowed, three function names +negative: + phase: parse + type: SyntaxError ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function x,y,z(){}"); -}); +function x,y,z(){} diff --git a/test/language/statements/function/invalid-function-body-1.js b/test/language/statements/function/invalid-function-body-1.js new file mode 100644 index 0000000000..9888d4d8f5 --- /dev/null +++ b/test/language/statements/function/invalid-function-body-1.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The FunctionBody must be SourceElements +es5id: 13_A7_T2 +description: > + Inserting elements that is different from SourceElements into the + FunctionBody +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +function __func(){/ ABC} diff --git a/test/language/statements/function/invalid-function-body-2.js b/test/language/statements/function/invalid-function-body-2.js new file mode 100644 index 0000000000..bbd8c93ec8 --- /dev/null +++ b/test/language/statements/function/invalid-function-body-2.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The FunctionBody must be SourceElements +es5id: 13_A7_T2 +description: > + Inserting elements that is different from SourceElements into the + FunctionBody +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +function __func(){&1} diff --git a/test/language/statements/function/invalid-function-body-3.js b/test/language/statements/function/invalid-function-body-3.js new file mode 100644 index 0000000000..6087c3ac0d --- /dev/null +++ b/test/language/statements/function/invalid-function-body-3.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The FunctionBody must be SourceElements +es5id: 13_A7_T2 +description: > + Inserting elements that is different from SourceElements into the + FunctionBody +negative: + phase: parse + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +function __func(){# ABC} diff --git a/test/language/statements/function/invalid-function-body.js b/test/language/statements/function/invalid-function-body.js deleted file mode 100644 index b4ed77cab5..0000000000 --- a/test/language/statements/function/invalid-function-body.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: The FunctionBody must be SourceElements -es5id: 13_A7_T2 -description: > - Inserting elements that is different from SourceElements into the - FunctionBody ----*/ - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -try{ - eval("function __func(){/ ABC}"); - $ERROR('#1: eval("function __func(){/ ABC}") lead to throwing exception'); -} catch(e){ - if(!(e instanceof SyntaxError)){ - $ERROR('#1.1: eval("function __func(){/ ABC}") lead to throwing exception of SyntaxError. Actual: exception is '+e); - } -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#3 -try{ - eval("function __func(){&1}"); - $ERROR('#3: eval("function __func(){&1}") lead to throwing exception'); -} catch(e){ - if(!(e instanceof SyntaxError)){ - $ERROR('#3.1: eval("function __func(){&1}") lead to throwing exception of SyntaxError. Actual: exception is '+e); - } -} -// -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -//CHECK#4 -try{ - eval("function __func(){# ABC}"); - $ERROR('#4: eval("function __func(){# ABC}") lead to throwing exception'); -} catch(e){ - if(!(e instanceof SyntaxError)){ - $ERROR('#4.1: eval("function __func(){# ABC}") lead to throwing exception of SyntaxError. Actual: exception is '+e); - } -} -// -////////////////////////////////////////////////////////////////////////////// diff --git a/test/language/statements/function/invalid-name-dot.js b/test/language/statements/function/invalid-name-dot.js index f4eab6a1c8..7fa20cd00f 100644 --- a/test/language/statements/function/invalid-name-dot.js +++ b/test/language/statements/function/invalid-name-dot.js @@ -6,9 +6,11 @@ es5id: 13.0-3 description: > 13.0 - property names in function definition is not allowed, add a new property into object +negative: + phase: parse + type: SyntaxError ---*/ - var obj = {}; -assert.throws(SyntaxError, function() { - eval("function obj.tt() {};"); -}); +throw "Test262: This statement should not be evaluated."; + +function obj.tt() {} diff --git a/test/language/statements/function/invalid-name-two-dots.js b/test/language/statements/function/invalid-name-two-dots.js index ace2f52e13..b8b9eb62c9 100644 --- a/test/language/statements/function/invalid-name-two-dots.js +++ b/test/language/statements/function/invalid-name-two-dots.js @@ -6,10 +6,11 @@ es5id: 13.0-4 description: > 13.0 - multiple names in one function declaration is not allowed, add a new property into a property which is a object +negative: + phase: parse + type: SyntaxError ---*/ - var obj = {}; - obj.tt = { len: 10 }; -assert.throws(SyntaxError, function() { - eval("function obj.tt.ss() {};"); -}); +throw "Test262: This statement should not be evaluated."; + +function obj.tt.ss() {} diff --git a/test/language/statements/function/line-terminator-non-strict.js b/test/language/statements/function/line-terminator-non-strict.js index 11dba26c68..d585e3fce2 100644 --- a/test/language/statements/function/line-terminator-non-strict.js +++ b/test/language/statements/function/line-terminator-non-strict.js @@ -38,6 +38,12 @@ z z(); -eval("function\u0009\u2029w(\u000C)\u00A0{\u000D};"); +// The following function expression is expressed with literal unicode +// characters so that parsers may benefit from this test. The included code +// points are as follows: +// +// "function\u0009\u2029w(\u000C)\u00A0{\u000D}" + +function 
w() { } w(); diff --git a/test/language/statements/function/line-terminator-strict.js b/test/language/statements/function/line-terminator-strict.js index 00fbf5995e..3a00e1821a 100644 --- a/test/language/statements/function/line-terminator-strict.js +++ b/test/language/statements/function/line-terminator-strict.js @@ -37,4 +37,12 @@ z z(); -eval("function\u0009\u2029w(\u000C)\u00A0{\u000D}; w()"); +// The following function expression is expressed with literal unicode +// characters so that parsers may benefit from this test. The included code +// points are as follows: +// +// "function\u0009\u2029w(\u000C)\u00A0{\u000D}" + +function 
w() { } + +w(); diff --git a/test/language/statements/function/name-arguments-non-strict.js b/test/language/statements/function/name-arguments-non-strict.js index e9445cfd80..8027c96266 100644 --- a/test/language/statements/function/name-arguments-non-strict.js +++ b/test/language/statements/function/name-arguments-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("function arguments (){};"); +function arguments (){} diff --git a/test/language/statements/function/name-arguments-strict-body.js b/test/language/statements/function/name-arguments-strict-body.js index 8c77046075..9b13ce5cc4 100644 --- a/test/language/statements/function/name-arguments-strict-body.js +++ b/test/language/statements/function/name-arguments-strict-body.js @@ -7,10 +7,12 @@ description: > StrictMode - SyntaxError is thrown if 'arguments' occurs as the Identifier of a FunctionDeclaration whose FunctionBody is contained in strict code +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function arguments() { 'use strict'; };") -}); +function arguments() { 'use strict'; } diff --git a/test/language/statements/function/name-arguments-strict.js b/test/language/statements/function/name-arguments-strict.js index ca42171704..7b6f9bd5af 100644 --- a/test/language/statements/function/name-arguments-strict.js +++ b/test/language/statements/function/name-arguments-strict.js @@ -6,10 +6,12 @@ es5id: 13.1-13-s description: > StrictMode - SyntaxError is thrown if 'arguments' occurs as the function name of a FunctionDeclaration in strict mode +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function arguments() { };") -}); +function arguments() { } diff --git a/test/language/statements/function/name-eval-non-strict.js b/test/language/statements/function/name-eval-non-strict.js index fa2f589833..0206d33bf5 100644 --- a/test/language/statements/function/name-eval-non-strict.js +++ b/test/language/statements/function/name-eval-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("function eval(){};"); +function eval(){} diff --git a/test/language/statements/function/name-eval-strict-body.js b/test/language/statements/function/name-eval-strict-body.js index ce5c98ec0d..a11eea2256 100644 --- a/test/language/statements/function/name-eval-strict-body.js +++ b/test/language/statements/function/name-eval-strict-body.js @@ -7,10 +7,12 @@ description: > StrictMode - SyntaxError is thrown if 'eval' occurs as the function name of a FunctionDeclaration whose FunctionBody is in strict mode +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function eval() { 'use strict'; };") -}); +function eval() { 'use strict'; } diff --git a/test/language/statements/function/name-eval-strict.js b/test/language/statements/function/name-eval-strict.js index f518e3e3ec..a490c39ea0 100644 --- a/test/language/statements/function/name-eval-strict.js +++ b/test/language/statements/function/name-eval-strict.js @@ -6,10 +6,12 @@ es5id: 13.1-11-s description: > StrictMode - SyntaxError is thrown if 'eval' occurs as the function name of a FunctionDeclaration in strict mode +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function eval() { };") -}); +function eval() { } diff --git a/test/language/statements/function/param-arguments-non-strict.js b/test/language/statements/function/param-arguments-non-strict.js index 7d7f9cd00d..a65a50e95e 100644 --- a/test/language/statements/function/param-arguments-non-strict.js +++ b/test/language/statements/function/param-arguments-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("function foo(arguments){};"); +function foo(arguments){} diff --git a/test/language/statements/function/param-arguments-strict-body.js b/test/language/statements/function/param-arguments-strict-body.js index 6d8b18b2d1..5b9d2a1b07 100644 --- a/test/language/statements/function/param-arguments-strict-body.js +++ b/test/language/statements/function/param-arguments-strict-body.js @@ -11,10 +11,12 @@ description: > StrictMode - SyntaxError is thrown if the identifier 'arguments' appears within a FormalParameterList of a strict mode FunctionDeclaration when FuctionBody is strict code +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_20_fun(arguments) { 'use strict'; }"); -}); +function _13_1_20_fun(arguments) { 'use strict'; } diff --git a/test/language/statements/function/param-arguments-strict.js b/test/language/statements/function/param-arguments-strict.js index cb4c6cebba..4d37b8e877 100644 --- a/test/language/statements/function/param-arguments-strict.js +++ b/test/language/statements/function/param-arguments-strict.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if the identifier 'arguments' appears within a FormalParameterList of a strict mode FunctionDeclaration +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_3_fun(arguments) { }"); -}); +function _13_1_3_fun(arguments) { } diff --git a/test/language/statements/function/param-duplicated-non-strict.js b/test/language/statements/function/param-duplicated-non-strict.js index fe491ee044..0f8da7bc21 100644 --- a/test/language/statements/function/param-duplicated-non-strict.js +++ b/test/language/statements/function/param-duplicated-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval('function foo(a,a){}'); +function foo(a,a){} diff --git a/test/language/statements/function/param-duplicated-strict-1.js b/test/language/statements/function/param-duplicated-strict-1.js index 3f766c6799..b133910ed8 100644 --- a/test/language/statements/function/param-duplicated-strict-1.js +++ b/test/language/statements/function/param-duplicated-strict-1.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if a function is declared in 'strict mode' using a FunctionDeclaration and the function has two identical parameters +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_5_fun(param, param) { }"); -}); +function _13_1_5_fun(param, param) { } diff --git a/test/language/statements/function/param-duplicated-strict-2.js b/test/language/statements/function/param-duplicated-strict-2.js index cf5b51d3e9..3abd84005b 100644 --- a/test/language/statements/function/param-duplicated-strict-2.js +++ b/test/language/statements/function/param-duplicated-strict-2.js @@ -12,10 +12,12 @@ description: > 'strict mode' using a FunctionDeclaration and the function has two identical parameters, which are separated by a unique parameter name +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_6_fun(param1, param2, param1) { }"); -}); +function _13_1_6_fun(param1, param2, param1) { } diff --git a/test/language/statements/function/param-duplicated-strict-3.js b/test/language/statements/function/param-duplicated-strict-3.js index aefc23a81c..bbde6fb5d7 100644 --- a/test/language/statements/function/param-duplicated-strict-3.js +++ b/test/language/statements/function/param-duplicated-strict-3.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if a function is created in 'strict mode' using a FunctionDeclaration and the function has three identical parameters +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_7_fun(param, param, param) { }"); -}); +function _13_1_7_fun(param, param, param) { } diff --git a/test/language/statements/function/param-duplicated-strict-body-1.js b/test/language/statements/function/param-duplicated-strict-body-1.js index bfb7fc45be..fcbba06103 100644 --- a/test/language/statements/function/param-duplicated-strict-body-1.js +++ b/test/language/statements/function/param-duplicated-strict-body-1.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if a function is created using a FunctionDeclaration whose FunctionBody is contained in strict code and the function has two identical parameters +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_24_fun(param, param) { 'use strict'; }"); -}); +function _13_1_24_fun(param, param) { 'use strict'; } diff --git a/test/language/statements/function/param-duplicated-strict-body-2.js b/test/language/statements/function/param-duplicated-strict-body-2.js index bb385da51a..5266d30aa9 100644 --- a/test/language/statements/function/param-duplicated-strict-body-2.js +++ b/test/language/statements/function/param-duplicated-strict-body-2.js @@ -12,10 +12,12 @@ description: > a FunctionDeclaration whose FunctionBody is contained in strict code and the function has two identical parameters which are separated by a unique parameter name +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_26_fun(param1, param2, param1) { 'use strict'; }"); -}); +function _13_1_26_fun(param1, param2, param1) { 'use strict'; } diff --git a/test/language/statements/function/param-duplicated-strict-body-3.js b/test/language/statements/function/param-duplicated-strict-body-3.js index 54760ba6b2..6783272a15 100644 --- a/test/language/statements/function/param-duplicated-strict-body-3.js +++ b/test/language/statements/function/param-duplicated-strict-body-3.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if a function is created using a FunctionDeclaration whose FunctionBody is contained in strict code and the function has three identical parameters +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_28_fun(param, param, param) { 'use strict'; }"); -}); +function _13_1_28_fun(param, param, param) { 'use strict'; } diff --git a/test/language/statements/function/param-eval-non-strict.js b/test/language/statements/function/param-eval-non-strict.js index c517620a92..561b853770 100644 --- a/test/language/statements/function/param-eval-non-strict.js +++ b/test/language/statements/function/param-eval-non-strict.js @@ -9,4 +9,4 @@ description: > flags: [noStrict] ---*/ - eval("function foo(eval){};"); +function foo(eval){}; diff --git a/test/language/statements/function/param-eval-strict-body.js b/test/language/statements/function/param-eval-strict-body.js index 961dea507d..c47006eda9 100644 --- a/test/language/statements/function/param-eval-strict-body.js +++ b/test/language/statements/function/param-eval-strict-body.js @@ -11,10 +11,12 @@ description: > StrictMode - SyntaxError is thrown if the identifier 'eval' appears within a FormalParameterList of a strict mode FunctionDeclaration when FuctionBody is strict code +negative: + phase: parse + type: SyntaxError flags: [noStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_16_fun(eval) { 'use strict'; }"); -}); +function _13_1_16_fun(eval) { 'use strict'; } diff --git a/test/language/statements/function/param-eval-strict.js b/test/language/statements/function/param-eval-strict.js index 8f1702734d..f3e115f57a 100644 --- a/test/language/statements/function/param-eval-strict.js +++ b/test/language/statements/function/param-eval-strict.js @@ -11,10 +11,12 @@ description: > Strict Mode - SyntaxError is thrown if the identifier 'eval' appears within a FormalParameterList of a strict mode FunctionDeclaration +negative: + phase: parse + type: SyntaxError flags: [onlyStrict] ---*/ +throw "Test262: This statement should not be evaluated."; -assert.throws(SyntaxError, function() { - eval("function _13_1_1_fun(eval) { }"); -}); +function _13_1_1_fun(eval) { } -- GitLab