Rename and refactor tests

The tests for the parsing of variable declarations 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 and instead express the expectations with literal
source text.
This commit is contained in:
Mike Pennisi 2018-09-23 21:32:37 -04:00
parent ceb79988ae
commit 6b00c8fbfe
14 changed files with 80 additions and 40 deletions

View File

@ -3,8 +3,9 @@
/*---
es5id: 12.2.1-12
esid: sec-variable-statement
description: arguments as local var identifier is allowed
flags: [noStrict]
---*/
eval("(function (){var arguments;})");
var arguments;

View File

@ -3,13 +3,16 @@
/*---
es5id: 12.2.1-28-s
esid: sec-variable-statement
description: >
arguments as local var identifier assigned to throws SyntaxError
in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var a, arguments = 42;}');
});
var a, arguments = 42;

View File

@ -3,11 +3,14 @@
/*---
es5id: 12.2.1-30-s
esid: sec-variable-statement
description: arguments as local var identifier throws SyntaxError in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var a = 42, arguments;}');
});
var a = 42, arguments;

View File

@ -3,11 +3,14 @@
/*---
es5id: 12.2.1-25-s
esid: sec-variable-statement
description: arguments as local var identifier throws SyntaxError in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var arguments, a;}');
});
var arguments, a;

View File

@ -3,11 +3,14 @@
/*---
es5id: 12.2.1-33-s
esid: sec-variable-statement
description: arguments as local var identifier throws SyntaxError in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var a, arguments, b;}');
});
var a, arguments, b;

View File

@ -3,13 +3,16 @@
/*---
es5id: 12.2.1-32-s
esid: sec-variable-statement
description: >
arguments as local var identifier defined twice and assigned once
throws SyntaxError in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var arguments, arguments = 42;}');
});
var arguments, arguments = 42;

View File

@ -3,13 +3,16 @@
/*---
es5id: 12.2.1-23-s
esid: sec-variable-statement
description: >
arguments as local var identifier assigned to throws SyntaxError
in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var arguments = 42;}');
});
var arguments = 42;

View File

@ -3,11 +3,14 @@
/*---
es5id: 12.2.1-12-s
esid: sec-variable-statement
description: arguments as local var identifier throws SyntaxError in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var arguments;}');
});
var arguments;

View File

@ -3,11 +3,14 @@
/*---
es5id: 12.2.1-26-s
esid: sec-variable-statement
description: eval as local var identifier throws SyntaxError in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var a, eval;}');
});
var a, eval;

View File

@ -3,13 +3,16 @@
/*---
es5id: 12.2.1-27-s
esid: sec-variable-statement
description: >
eval as local var identifier assigned to throws SyntaxError in
strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var eval = 42, a;}');
});
var eval = 42, a;

View File

@ -3,11 +3,14 @@
/*---
es5id: 12.2.1-29-s
esid: sec-variable-statement
description: eval as local var identifier throws SyntaxError in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var eval, a = 42;}');
});
var eval, a = 42;

View File

@ -3,13 +3,16 @@
/*---
es5id: 12.2.1-31-s
esid: sec-variable-statement
description: >
eval as local var identifier defined twice throws SyntaxError in
strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var eval, eval;}');
});
var eval, eval;

View File

@ -3,13 +3,16 @@
/*---
es5id: 12.2.1-24-s
esid: sec-variable-statement
description: >
eval as local var identifier assigned to throws SyntaxError in
strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var eval = 42;}');
});
var eval = 42;

View File

@ -3,13 +3,16 @@
/*---
es5id: 12.2.1-1-s
esid: sec-variable-statement
description: >
eval - a function declaring a var named 'eval' throws SyntaxError
in strict mode
flags: [onlyStrict]
negative:
phase: parse
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval('function foo() { var eval; }');
});
var eval;