Skip to content
Snippets Groups Projects
Commit baa5d94b authored by Mike Pennisi's avatar Mike Pennisi Committed by Rick Waldron
Browse files

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.
parent 4455b101
No related branches found
No related tags found
No related merge requests found
Showing
with 105 additions and 79 deletions
// 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});");
// 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_6-2-2-s
description: >
Strict Mode - SyntaxError is thrown when an assignment to a
reserved word or a future reserved word is made inside a strict
mode FunctionBody of a PropertyAssignment
negative:
type: SyntaxError
phase: parse
flags: [noStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var obj = {\
get _11_1_5_6_2_2() {\
\"use strict\";\
public = 42;\
return public;\
}\
};\
var _11_1_5_6_2_2 = obj._11_1_5_6_2_2;");
});
void {
get x() {
"use strict";
public = 42;
}
};
// 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_6-2-1-s
description: >
Strict Mode - SyntaxError is thrown when an assignment to a
reserved word or a future reserved word is contained in strict code
negative:
type: SyntaxError
phase: parse
flags: [onlyStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var obj = {\
get _11_1_5_6_2_1() {\
public = 42;\
return public;\
}\
};");
var _11_1_5_6_2_1 = obj._11_1_5_6_2_1;
});
void {
get x() {
public = 42;
}
};
......@@ -14,4 +14,7 @@ description: >
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
---*/
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
---*/
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)
---*/
eval("({get foo(){}, get foo(){}});");
void {
get foo() {},
get foo() {}
};
......@@ -8,4 +8,8 @@ description: >
(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
---*/
eval("({set foo(x){}, foo : 1});");
void {
set foo(x) {},
foo: 1
};
......@@ -8,4 +8,8 @@ description: >
(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)
---*/
eval("({set foo(arg){}, set foo(arg1){}});");
void {
set foo(arg) {},
set foo(arg1) {}
};
// 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_7-2-2-s
description: >
Strict Mode - SyntaxError is thrown when an assignment to a
reserved word is made in a strict FunctionBody of a
PropertyAssignment
flags: [onlyStrict]
negative:
type: SyntaxError
phase: parse
flags: [noStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var data = \"data\";\
var obj = {\
set _11_1_5_7_2_2(value) {\
public = 42;\
data = value;\
}\
};\
obj._11_1_5_7_2_2 = 1;");
});
void {
set x(value) {
"use strict";
public = 42;
}
};
// 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_7-2-1-s
description: >
Strict Mode - SyntaxError is thrown when an assignment to a
reserved word is contained in strict code
negative:
type: SyntaxError
phase: parse
flags: [onlyStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var data = \"data\";\
var obj = {\
set _11_1_5_7_2_1(value) {\
public = 42;\
data = value;\
}\
};\
obj._11_1_5_7_2_1 = 1;");
});
void {
set x(value) {
public = 42;
}
};
// 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-s
description: >
Strict Mode - SyntaxError is thrown when 'arguments' occurs as
the Identifier in a PropertySetParameterList of a
PropertyAssignment if its FunctionBody is strict code
negative:
type: SyntaxError
phase: parse
flags: [noStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var obj = {set _11_1_5_4_fun(arguments) {\"use strict\";}};");
});
void {
set x(arguments) {
"use strict";
}
};
// 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-2-s
description: >
Strict Mode - SyntaxError is thrown when 'arguments' occurs as the
Identifier in a PropertySetParameterList of a PropertyAssignment
that is contained in strict code
negative:
type: SyntaxError
phase: parse
flags: [onlyStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var obj = {set _11_1_5_2_fun(arguments) {} };");
});
void {
set x(arguments) {}
};
// 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-3-s
description: >
Strict Mode - SyntaxError is thrown when 'evals' occurs as the
Identifier in a PropertySetParameterList of a PropertyAssignment
if its FunctionBody is strict code
negative:
type: SyntaxError
phase: parse
flags: [noStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var obj = {set _11_1_5_3_fun(eval) { \"use strict\"; }};");
});
void {
set x(eval) {
"use strict";
}
};
// 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-1-s
description: >
Strict Mode - SyntaxError is thrown when 'eval' occurs as the
Identifier in a PropertySetParameterList of a PropertyAssignment
that is contained in strict code
negative:
type: SyntaxError
phase: parse
flags: [onlyStrict]
---*/
throw "Test262: This statement should not be evaluated.";
assert.throws(SyntaxError, function() {
eval("var obj = {set _11_1_5_1_fun(eval) {}};");
});
void {
set x(eval) {}
};
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