Merge pull request #1404 from jugglinmike/refactor-for-parsers-function

Refactor function literal tests for parsers
This commit is contained in:
Leo Balter 2018-02-05 11:44:03 -05:00 committed by GitHub
commit 31dfa8761a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 260 additions and 182 deletions

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("(function arguments (){});");
(function arguments (){});

View File

@ -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';});

View File

@ -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() {});

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("(function eval(){});");
(function eval(){});

View File

@ -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';});

View File

@ -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() {});

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("(function foo(arguments){});");
(function foo(arguments){});

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval('(function foo(a,a){})');
(function foo(a,a){});

View File

@ -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) { });

View File

@ -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) { });

View File

@ -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) { });

View File

@ -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'; });

View File

@ -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'; });

View File

@ -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'; });

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("(function foo(eval){});");
(function foo(eval){});

View File

@ -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'; });

View File

@ -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);
}
}
//
//////////////////////////////////////////////////////////////////////////////

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
};

View File

@ -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() {}

View File

@ -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(){}

View File

@ -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}

View File

@ -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}

View File

@ -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}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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();

View File

@ -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();

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("function arguments (){};");
function arguments (){}

View File

@ -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'; }

View File

@ -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() { }

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("function eval(){};");
function eval(){}

View File

@ -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'; }

View File

@ -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() { }

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("function foo(arguments){};");
function foo(arguments){}

View File

@ -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'; }

View File

@ -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) { }

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval('function foo(a,a){}');
function foo(a,a){}

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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'; }

View File

@ -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'; }

View File

@ -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'; }

View File

@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/
eval("function foo(eval){};");
function foo(eval){};

View File

@ -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'; }

View File

@ -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) { }