Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor function literal tests for parsers #1404

Merged
merged 2 commits into from
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/

eval("(function arguments (){});");
(function arguments (){});
Original file line number Diff line number Diff line change
Expand Up @@ -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';});
Original file line number Diff line number Diff line change
Expand Up @@ -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() {});
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/

eval("(function eval(){});");
(function eval(){});
Original file line number Diff line number Diff line change
Expand Up @@ -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';});
Original file line number Diff line number Diff line change
Expand Up @@ -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() {});
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/

eval("(function foo(arguments){});");
(function foo(arguments){});
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/

eval('(function foo(a,a){})');
(function foo(a,a){});
Original file line number Diff line number Diff line change
Expand Up @@ -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) { });
Original file line number Diff line number Diff line change
Expand Up @@ -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) { });
Original file line number Diff line number Diff line change
Expand Up @@ -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) { });
Original file line number Diff line number Diff line change
Expand Up @@ -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'; });
Original file line number Diff line number Diff line change
Expand Up @@ -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'; });
Original file line number Diff line number Diff line change
Expand Up @@ -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'; });
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ description: >
flags: [noStrict]
---*/

eval("(function foo(eval){});");
(function foo(eval){});
Original file line number Diff line number Diff line change
Expand Up @@ -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'; });
49 changes: 0 additions & 49 deletions test/language/statements/function/S13_A7_T2.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Original file line number Diff line number Diff line change
Expand Up @@ -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(){}
17 changes: 17 additions & 0 deletions test/language/statements/function/invalid-function-body-1.js
Original file line number Diff line number Diff line change
@@ -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}
Loading