mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 15:04:43 +02:00
Refactor object initializer tests for parsers
A number of tests for the parsing of object initializers 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` in the relevant tests and instead express the expectations with literal source text.
This commit is contained in:
parent
4455b1017e
commit
baa5d94bc5
@ -1,10 +0,0 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
es5id: 11.1.5-4-4-a-1-s
|
|
||||||
description: >
|
|
||||||
Object literal - No SyntaxError for duplicate data property names
|
|
||||||
---*/
|
|
||||||
|
|
||||||
eval("({foo:0,foo:1});");
|
|
@ -1,23 +1,22 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5_6-2-2-s
|
es5id: 11.1.5_6-2-2-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when an assignment to a
|
Strict Mode - SyntaxError is thrown when an assignment to a
|
||||||
reserved word or a future reserved word is made inside a strict
|
reserved word or a future reserved word is made inside a strict
|
||||||
mode FunctionBody of a PropertyAssignment
|
mode FunctionBody of a PropertyAssignment
|
||||||
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
flags: [noStrict]
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var obj = {\
|
get x() {
|
||||||
get _11_1_5_6_2_2() {\
|
"use strict";
|
||||||
\"use strict\";\
|
public = 42;
|
||||||
public = 42;\
|
}
|
||||||
return public;\
|
};
|
||||||
}\
|
|
||||||
};\
|
|
||||||
var _11_1_5_6_2_2 = obj._11_1_5_6_2_2;");
|
|
||||||
});
|
|
@ -1,22 +1,20 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5_6-2-1-s
|
es5id: 11.1.5_6-2-1-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when an assignment to a
|
Strict Mode - SyntaxError is thrown when an assignment to a
|
||||||
reserved word or a future reserved word is contained in strict code
|
reserved word or a future reserved word is contained in strict code
|
||||||
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var obj = {\
|
get x() {
|
||||||
get _11_1_5_6_2_1() {\
|
public = 42;
|
||||||
public = 42;\
|
}
|
||||||
return public;\
|
};
|
||||||
}\
|
|
||||||
};");
|
|
||||||
|
|
||||||
var _11_1_5_6_2_1 = obj._11_1_5_6_2_1;
|
|
||||||
});
|
|
@ -14,4 +14,7 @@ description: >
|
|||||||
strict mode
|
strict mode
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({foo:0,foo:1});");
|
void {
|
||||||
|
foo: 0,
|
||||||
|
foo: 1
|
||||||
|
};
|
@ -8,4 +8,7 @@ description: >
|
|||||||
followed by set accessor definition with the same name
|
followed by set accessor definition with the same name
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({foo : 1, set foo(x){}});");
|
void {
|
||||||
|
foo: 1,
|
||||||
|
set foo(x) {}
|
||||||
|
};
|
@ -8,4 +8,7 @@ description: >
|
|||||||
is followed by a data property definition with the same name
|
is followed by a data property definition with the same name
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({get foo(){}, foo : 1});");
|
void {
|
||||||
|
get foo() {},
|
||||||
|
foo: 1
|
||||||
|
};
|
@ -6,4 +6,7 @@ es5id: 11.1.5_4-4-d-1
|
|||||||
description: Object literal - No SyntaxError for duplicate property name (get,get)
|
description: Object literal - No SyntaxError for duplicate property name (get,get)
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({get foo(){}, get foo(){}});");
|
void {
|
||||||
|
get foo() {},
|
||||||
|
get foo() {}
|
||||||
|
};
|
@ -8,4 +8,8 @@ description: >
|
|||||||
(get,set,get)
|
(get,set,get)
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({get foo(){}, set foo(arg){}, get foo(){}});");
|
void {
|
||||||
|
get foo() {},
|
||||||
|
set foo(arg) {},
|
||||||
|
get foo() {}
|
||||||
|
};
|
@ -8,4 +8,7 @@ description: >
|
|||||||
is followed by a data property definition with the same name
|
is followed by a data property definition with the same name
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({set foo(x){}, foo : 1});");
|
void {
|
||||||
|
set foo(x) {},
|
||||||
|
foo: 1
|
||||||
|
};
|
@ -8,4 +8,8 @@ description: >
|
|||||||
(set,get,set)
|
(set,get,set)
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({set foo(arg){}, get foo(){}, set foo(arg1){}});");
|
void {
|
||||||
|
set foo(arg) {},
|
||||||
|
get foo() {},
|
||||||
|
set foo(arg1) {}
|
||||||
|
};
|
@ -6,4 +6,7 @@ es5id: 11.1.5_4-4-d-2
|
|||||||
description: Object literal - No SyntaxError for duplicate property name (set,set)
|
description: Object literal - No SyntaxError for duplicate property name (set,set)
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
eval("({set foo(arg){}, set foo(arg1){}});");
|
void {
|
||||||
|
set foo(arg) {},
|
||||||
|
set foo(arg1) {}
|
||||||
|
};
|
@ -1,23 +1,22 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5_7-2-2-s
|
es5id: 11.1.5_7-2-2-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when an assignment to a
|
Strict Mode - SyntaxError is thrown when an assignment to a
|
||||||
reserved word is made in a strict FunctionBody of a
|
reserved word is made in a strict FunctionBody of a
|
||||||
PropertyAssignment
|
PropertyAssignment
|
||||||
flags: [onlyStrict]
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var data = \"data\";\
|
set x(value) {
|
||||||
var obj = {\
|
"use strict";
|
||||||
set _11_1_5_7_2_2(value) {\
|
public = 42;
|
||||||
public = 42;\
|
}
|
||||||
data = value;\
|
};
|
||||||
}\
|
|
||||||
};\
|
|
||||||
obj._11_1_5_7_2_2 = 1;");
|
|
||||||
});
|
|
@ -1,22 +1,20 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5_7-2-1-s
|
es5id: 11.1.5_7-2-1-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when an assignment to a
|
Strict Mode - SyntaxError is thrown when an assignment to a
|
||||||
reserved word is contained in strict code
|
reserved word is contained in strict code
|
||||||
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var data = \"data\";\
|
set x(value) {
|
||||||
var obj = {\
|
public = 42;
|
||||||
set _11_1_5_7_2_1(value) {\
|
}
|
||||||
public = 42;\
|
};
|
||||||
data = value;\
|
|
||||||
}\
|
|
||||||
};\
|
|
||||||
obj._11_1_5_7_2_1 = 1;");
|
|
||||||
});
|
|
@ -1,16 +1,21 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5-4-s
|
es5id: 11.1.5-4-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when 'arguments' occurs as
|
Strict Mode - SyntaxError is thrown when 'arguments' occurs as
|
||||||
the Identifier in a PropertySetParameterList of a
|
the Identifier in a PropertySetParameterList of a
|
||||||
PropertyAssignment if its FunctionBody is strict code
|
PropertyAssignment if its FunctionBody is strict code
|
||||||
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
flags: [noStrict]
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var obj = {set _11_1_5_4_fun(arguments) {\"use strict\";}};");
|
set x(arguments) {
|
||||||
});
|
"use strict";
|
||||||
|
}
|
||||||
|
};
|
@ -1,16 +1,19 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5-2-s
|
es5id: 11.1.5-2-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when 'arguments' occurs as the
|
Strict Mode - SyntaxError is thrown when 'arguments' occurs as the
|
||||||
Identifier in a PropertySetParameterList of a PropertyAssignment
|
Identifier in a PropertySetParameterList of a PropertyAssignment
|
||||||
that is contained in strict code
|
that is contained in strict code
|
||||||
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var obj = {set _11_1_5_2_fun(arguments) {} };");
|
set x(arguments) {}
|
||||||
});
|
};
|
@ -1,16 +1,21 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5-3-s
|
es5id: 11.1.5-3-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when 'evals' occurs as the
|
Strict Mode - SyntaxError is thrown when 'evals' occurs as the
|
||||||
Identifier in a PropertySetParameterList of a PropertyAssignment
|
Identifier in a PropertySetParameterList of a PropertyAssignment
|
||||||
if its FunctionBody is strict code
|
if its FunctionBody is strict code
|
||||||
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
flags: [noStrict]
|
flags: [noStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var obj = {set _11_1_5_3_fun(eval) { \"use strict\"; }};");
|
set x(eval) {
|
||||||
});
|
"use strict";
|
||||||
|
}
|
||||||
|
};
|
@ -1,16 +1,19 @@
|
|||||||
// Copyright (c) 2012 Ecma International. All rights reserved.
|
// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es5id: 11.1.5-1-s
|
es5id: 11.1.5-1-s
|
||||||
description: >
|
description: >
|
||||||
Strict Mode - SyntaxError is thrown when 'eval' occurs as the
|
Strict Mode - SyntaxError is thrown when 'eval' occurs as the
|
||||||
Identifier in a PropertySetParameterList of a PropertyAssignment
|
Identifier in a PropertySetParameterList of a PropertyAssignment
|
||||||
that is contained in strict code
|
that is contained in strict code
|
||||||
|
negative:
|
||||||
|
type: SyntaxError
|
||||||
|
phase: parse
|
||||||
flags: [onlyStrict]
|
flags: [onlyStrict]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
assert.throws(SyntaxError, function() {
|
void {
|
||||||
eval("var obj = {set _11_1_5_1_fun(eval) {}};");
|
set x(eval) {}
|
||||||
});
|
};
|
Loading…
x
Reference in New Issue
Block a user