Skip to content
Snippets Groups Projects
Unverified Commit 31dfa876 authored by Leo Balter's avatar Leo Balter Committed by GitHub
Browse files

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

Refactor function literal tests for parsers
parents 82c61489 1d96e257
No related branches found
No related tags found
No related merge requests found
Showing
with 75 additions and 101 deletions
...@@ -9,4 +9,4 @@ description: > ...@@ -9,4 +9,4 @@ description: >
flags: [noStrict] flags: [noStrict]
---*/ ---*/
eval("(function arguments (){});"); (function arguments (){});
...@@ -7,10 +7,12 @@ description: > ...@@ -7,10 +7,12 @@ description: >
StrictMode - SyntaxError is thrown if 'arguments' occurs as the StrictMode - SyntaxError is thrown if 'arguments' occurs as the
Identifier of a FunctionExpression whose FunctionBody is contained Identifier of a FunctionExpression whose FunctionBody is contained
in strict code in strict code
negative:
phase: parse
type: SyntaxError
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var _13_1_42_s = {}; throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("_13_1_42_s.x = function arguments() {'use strict';};"); (function arguments() {'use strict';});
});
...@@ -6,10 +6,12 @@ es5id: 13.1-14-s ...@@ -6,10 +6,12 @@ es5id: 13.1-14-s
description: > description: >
StrictMode - SyntaxError is thrown if 'arguments' occurs as the StrictMode - SyntaxError is thrown if 'arguments' occurs as the
Identifier of a FunctionExpression in strict mode Identifier of a FunctionExpression in strict mode
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict] flags: [onlyStrict]
---*/ ---*/
var _13_1_14_s = {}; throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("_13_1_14_s.x = function arguments() {};"); (function arguments() {});
});
...@@ -9,4 +9,4 @@ description: > ...@@ -9,4 +9,4 @@ description: >
flags: [noStrict] flags: [noStrict]
---*/ ---*/
eval("(function eval(){});"); (function eval(){});
...@@ -7,10 +7,12 @@ description: > ...@@ -7,10 +7,12 @@ description: >
StrictMode - SyntaxError is thrown if 'eval' occurs as the StrictMode - SyntaxError is thrown if 'eval' occurs as the
Identifier of a FunctionExpression whose FunctionBody is contained Identifier of a FunctionExpression whose FunctionBody is contained
in strict code in strict code
negative:
phase: parse
type: SyntaxError
flags: [noStrict] flags: [noStrict]
---*/ ---*/
var _13_1_38_s = {}; throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("_13_1_38_s.x = function eval() {'use strict'; };"); (function eval() {'use strict';});
});
...@@ -6,10 +6,12 @@ es5id: 13.1-12-s ...@@ -6,10 +6,12 @@ es5id: 13.1-12-s
description: > description: >
StrictMode - SyntaxError is thrown if 'eval' occurs as the StrictMode - SyntaxError is thrown if 'eval' occurs as the
Identifier of a FunctionExpression in strict mode Identifier of a FunctionExpression in strict mode
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict] flags: [onlyStrict]
---*/ ---*/
var _13_1_12_s = {}; throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("_13_1_12_s.x = function eval() {};"); (function eval() {});
});
...@@ -9,4 +9,4 @@ description: > ...@@ -9,4 +9,4 @@ description: >
flags: [noStrict] flags: [noStrict]
---*/ ---*/
eval("(function foo(arguments){});"); (function foo(arguments){});
...@@ -9,4 +9,4 @@ description: > ...@@ -9,4 +9,4 @@ description: >
flags: [noStrict] flags: [noStrict]
---*/ ---*/
eval('(function foo(a,a){})'); (function foo(a,a){});
...@@ -11,10 +11,12 @@ description: > ...@@ -11,10 +11,12 @@ description: >
Strict Mode - SyntaxError is thrown if a function is created in Strict Mode - SyntaxError is thrown if a function is created in
'strict mode' using a FunctionExpression and the function has two 'strict mode' using a FunctionExpression and the function has two
identical parameters identical parameters
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict] flags: [onlyStrict]
---*/ ---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() { (function (param, param) { });
eval("var _13_1_8_fun = function (param, param) { };");
});
...@@ -12,10 +12,12 @@ description: > ...@@ -12,10 +12,12 @@ description: >
'strict mode' using a FunctionExpression and the function has two 'strict mode' using a FunctionExpression and the function has two
identical parameters, which are separated by a unique parameter identical parameters, which are separated by a unique parameter
name name
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict] flags: [onlyStrict]
---*/ ---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() { (function (param1, param2, param1) { });
eval("var _13_1_9_fun = function (param1, param2, param1) { };");
});
...@@ -11,10 +11,12 @@ description: > ...@@ -11,10 +11,12 @@ description: >
Strict Mode - SyntaxError is thrown if a function is created in Strict Mode - SyntaxError is thrown if a function is created in
'strict mode' using a FunctionExpression and the function has 'strict mode' using a FunctionExpression and the function has
three identical parameters three identical parameters
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict] flags: [onlyStrict]
---*/ ---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() { (function (param, param, param) { });
eval("var _13_1_10_fun = function (param, param, param) { };")
});
...@@ -11,10 +11,12 @@ description: > ...@@ -11,10 +11,12 @@ description: >
Strict Mode - SyntaxError is thrown if a function is created using Strict Mode - SyntaxError is thrown if a function is created using
a FunctionExpression whose FunctionBody is contained in strict a FunctionExpression whose FunctionBody is contained in strict
code and the function has two identical parameters code and the function has two identical parameters
negative:
phase: parse
type: SyntaxError
flags: [noStrict] flags: [noStrict]
---*/ ---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() { (function (param, param) { 'use strict'; });
eval("var _13_1_30_fun = function (param, param) { 'use strict'; };");
});
...@@ -12,10 +12,12 @@ description: > ...@@ -12,10 +12,12 @@ description: >
a FunctionExpression whose FunctionBody is strict and the function a FunctionExpression whose FunctionBody is strict and the function
has two identical parameters, which are separated by a unique has two identical parameters, which are separated by a unique
parameter name parameter name
negative:
phase: parse
type: SyntaxError
flags: [noStrict] flags: [noStrict]
---*/ ---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() { (function (param1, param2, param1) { 'use strict'; });
eval("var _13_1_32_fun = function (param1, param2, param1) { 'use strict'; };");
});
...@@ -10,10 +10,12 @@ es5id: 13.1-34-s ...@@ -10,10 +10,12 @@ es5id: 13.1-34-s
description: > description: >
Strict Mode - SyntaxError is thrown if a function declaration has Strict Mode - SyntaxError is thrown if a function declaration has
three identical parameters with a strict mode body three identical parameters with a strict mode body
negative:
phase: parse
type: SyntaxError
flags: [noStrict] flags: [noStrict]
---*/ ---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() { (function (param, param, param) { 'use strict'; });
eval("var _13_1_34_fun = function (param, param, param) { 'use strict'; };")
});
...@@ -9,4 +9,4 @@ description: > ...@@ -9,4 +9,4 @@ description: >
flags: [noStrict] flags: [noStrict]
---*/ ---*/
eval("(function foo(eval){});"); (function foo(eval){});
...@@ -11,10 +11,12 @@ description: > ...@@ -11,10 +11,12 @@ description: >
StrictMode - SyntaxError is thrown if the identifier 'eval' StrictMode - SyntaxError is thrown if the identifier 'eval'
appears within a FormalParameterList of a strict mode appears within a FormalParameterList of a strict mode
FunctionExpression when FuctionBody is strict code FunctionExpression when FuctionBody is strict code
negative:
phase: parse
type: SyntaxError
flags: [noStrict] flags: [noStrict]
---*/ ---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() { (function (eval) { 'use strict'; });
eval("var _13_1_18_fun = function (eval) { 'use strict'; }");
});
// 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);
}
}
//
//////////////////////////////////////////////////////////////////////////////
...@@ -10,16 +10,17 @@ description: > ...@@ -10,16 +10,17 @@ description: >
Strict Mode - SourceElements is evaluated as strict mode code when Strict Mode - SourceElements is evaluated as strict mode code when
the code of this FunctionBody with an inner function contains a the code of this FunctionBody with an inner function contains a
Use Strict Directive Use Strict Directive
negative:
phase: parse
type: SyntaxError
flags: [noStrict] flags: [noStrict]
---*/ ---*/
function _13_0_10_fun() { throw "Test262: This statement should not be evaluated.";
function _13_0_10_inner() {
"use strict"; function _13_0_10_fun() {
eval("eval = 42;"); function _13_0_10_inner() {
} "use strict";
_13_0_10_inner(); eval = 42;
}; }
assert.throws(SyntaxError, function() { }
_13_0_10_fun();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment