Merge pull request #2118 from jugglinmike/refactor-for-parsers-with

Refactor `with` statement tests for parsers
This commit is contained in:
Leo Balter 2019-04-02 14:08:18 -04:00 committed by GitHub
commit 93f2bae981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 97 additions and 152 deletions

View File

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

View File

@ -1,15 +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-15-s
description: >
Strict Mode - SyntaxError is thrown when the RHS of a dot property
assignment utilizes WithStatement
flags: [onlyStrict]
---*/
assert.throws(SyntaxError, function() {
eval("var obj = {}; obj.get = function (a) { with(a){} }; ");
});

View File

@ -1,15 +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-16-s
description: >
Strict Mode - SyntaxError is thrown when the RHS of an object
indexer assignment utilizes WithStatement
flags: [onlyStrict]
---*/
assert.throws(SyntaxError, function() {
eval("var obj = {}; obj['get'] = function (a) { with(a){} }; ");
});

View File

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

View File

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

View File

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

View File

@ -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-9-s
description: >
with statement in strict mode throws SyntaxError (strict function
expression)
flags: [noStrict]
---*/
assert.throws(SyntaxError, function() {
eval("\
var f = function () {\
\'use strict\';\
var o = {}; \
with (o) {}; \
}\
");
});

View File

@ -4,12 +4,14 @@
/*---
es5id: 12.10.1-11-s
description: >
Strict Mode - SyntaxError is thrown when using WithStatement in
strict mode code
Strict Mode - SyntaxError is thrown when using WithStatement in strict mode
code
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
$DONOTEVALUATE();
assert.throws(SyntaxError, function() {
eval("with ({}) { throw new Error();}");
});
with ({}) {}

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

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

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

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

View File

@ -4,12 +4,14 @@
/*---
es5id: 12.10.1-14-s
description: >
Strict Mode - SyntaxError is thrown when the getter of a literal
object utilizes WithStatement
Strict Mode - SyntaxError is thrown when the getter of a literal object
utilizes WithStatement
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
$DONOTEVALUATE();
assert.throws(SyntaxError, function() {
eval("var obj = { get(a) { with(a){} } }; ");
});
var obj = { get(a) { with(a){} } };