mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 07:54:41 +02:00
Refactor with
statement tests for parsers
The tests for the parsing of the `with` statement 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. Rename the files to make each test's purpose more clear.
This commit is contained in:
parent
255338141b
commit
9b396d0b0b
@ -1,21 +0,0 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
es5id: 12.10.1-1-s
|
|
||||||
description: with statement in strict mode throws SyntaxError (strict function)
|
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
|
||||||
// wrapping it in eval since this needs to be a syntax error. The
|
|
||||||
// exception thrown must be a SyntaxError exception.
|
|
||||||
eval("\
|
|
||||||
function f() {\
|
|
||||||
\'use strict\';\
|
|
||||||
var o = {}; \
|
|
||||||
with (o) {};\
|
|
||||||
}\
|
|
||||||
");
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
es5id: 12.10.1-2-s
|
|
||||||
description: >
|
|
||||||
with statement in strict mode throws SyntaxError (nested function
|
|
||||||
where container is strict)
|
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
|
||||||
// wrapping it in eval since this needs to be a syntax error. The
|
|
||||||
// exception thrown must be a SyntaxError exception.
|
|
||||||
eval("\
|
|
||||||
function foo() {\
|
|
||||||
\'use strict\'; \
|
|
||||||
function f() {\
|
|
||||||
var o = {}; \
|
|
||||||
with (o) {};\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
");
|
|
||||||
});
|
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
es5id: 12.10.1-3-s
|
|
||||||
description: >
|
|
||||||
with statement in strict mode throws SyntaxError (nested strict
|
|
||||||
function)
|
|
||||||
flags: [noStrict]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
|
||||||
// wrapping it in eval since this needs to be a syntax error. The
|
|
||||||
// exception thrown must be a SyntaxError exception.
|
|
||||||
eval("\
|
|
||||||
function foo() {\
|
|
||||||
function f() {\
|
|
||||||
\'use strict\'; \
|
|
||||||
var o = {}; \
|
|
||||||
with (o) {};\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
");
|
|
||||||
});
|
|
@ -1,20 +0,0 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
es5id: 12.10.1-7-s
|
|
||||||
description: >
|
|
||||||
with statement in strict mode throws SyntaxError (function
|
|
||||||
expression, where the container function is directly evaled from
|
|
||||||
strict code)
|
|
||||||
flags: [onlyStrict]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
|
||||||
eval("var f = function () {\
|
|
||||||
var o = {}; \
|
|
||||||
with (o) {}; \
|
|
||||||
}\
|
|
||||||
");
|
|
||||||
});
|
|
@ -4,12 +4,14 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.10.1-11-s
|
es5id: 12.10.1-11-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when using WithStatement in
|
Strict Mode - SyntaxError is thrown when using WithStatement in strict mode
|
||||||
strict mode code
|
code
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
with ({}) {}
|
||||||
eval("with ({}) { throw new Error();}");
|
|
||||||
});
|
|
23
test/language/statements/with/strict-fn-decl-nested-1.js
Normal file
23
test/language/statements/with/strict-fn-decl-nested-1.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es5id: 12.10.1-2-s
|
||||||
|
description: >
|
||||||
|
with statement in strict mode throws SyntaxError (nested function where
|
||||||
|
container is strict)
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
'use strict';
|
||||||
|
function f() {
|
||||||
|
var o = {};
|
||||||
|
with (o) {};
|
||||||
|
}
|
||||||
|
}
|
22
test/language/statements/with/strict-fn-decl-nested-2.js
Normal file
22
test/language/statements/with/strict-fn-decl-nested-2.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es5id: 12.10.1-3-s
|
||||||
|
description: >
|
||||||
|
with statement in strict mode throws SyntaxError (nested strict function)
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
flags: [noStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
function foo() {
|
||||||
|
function f() {
|
||||||
|
'use strict';
|
||||||
|
var o = {};
|
||||||
|
with (o) {};
|
||||||
|
}
|
||||||
|
}
|
19
test/language/statements/with/strict-fn-decl.js
Normal file
19
test/language/statements/with/strict-fn-decl.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es5id: 12.10.1-1-s
|
||||||
|
description: with statement in strict mode throws SyntaxError (strict function)
|
||||||
|
flags: [noStrict]
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
function f() {
|
||||||
|
'use strict';
|
||||||
|
var o = {};
|
||||||
|
with (o) {};
|
||||||
|
}
|
19
test/language/statements/with/strict-fn-expr.js
Normal file
19
test/language/statements/with/strict-fn-expr.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es5id: 12.10.1-7-s
|
||||||
|
description: >
|
||||||
|
with statement in strict mode throws SyntaxError (function expression)
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
flags: [onlyStrict]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
|
var f = function () {
|
||||||
|
var o = {};
|
||||||
|
with (o) {};
|
||||||
|
};
|
@ -4,12 +4,14 @@
|
|||||||
/*---
|
/*---
|
||||||
es5id: 12.10.1-14-s
|
es5id: 12.10.1-14-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when the getter of a literal
|
Strict Mode - SyntaxError is thrown when the getter of a literal object
|
||||||
object utilizes WithStatement
|
utilizes WithStatement
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
$DONOTEVALUATE();
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
var obj = { get(a) { with(a){} } };
|
||||||
eval("var obj = { get(a) { with(a){} } }; ");
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user