mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1041128 - Allow duplicate properties in object literals r=jorendorff
* * * Bug 1041128 - Duplicate property name in object literal is allowed in ES6 strict mode part 2 r=Waldo
This commit is contained in:
parent
aefa35c4e1
commit
cfe3259e10
@ -7092,18 +7092,6 @@ Parser<ParseHandler>::objectLiteral()
|
||||
{
|
||||
JS_ASSERT(tokenStream.isCurrentTokenType(TOK_LC));
|
||||
|
||||
/*
|
||||
* A map from property names we've seen thus far to a mask of property
|
||||
* assignment types.
|
||||
*/
|
||||
AtomIndexMap seen;
|
||||
|
||||
enum AssignmentType {
|
||||
GET = 0x1,
|
||||
SET = 0x2,
|
||||
VALUE = 0x4 | GET | SET
|
||||
};
|
||||
|
||||
Node literal = handler.newObjectLiteral(pos().begin);
|
||||
if (!literal)
|
||||
return null();
|
||||
@ -7297,49 +7285,6 @@ Parser<ParseHandler>::objectLiteral()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for duplicate property names. Duplicate data properties
|
||||
* only conflict in strict mode. Duplicate getter or duplicate
|
||||
* setter halves always conflict. A data property conflicts with
|
||||
* any part of an accessor property.
|
||||
*/
|
||||
AssignmentType assignType;
|
||||
if (op == JSOP_INITPROP)
|
||||
assignType = VALUE;
|
||||
else if (op == JSOP_INITPROP_GETTER)
|
||||
assignType = GET;
|
||||
else if (op == JSOP_INITPROP_SETTER)
|
||||
assignType = SET;
|
||||
else
|
||||
MOZ_CRASH("bad opcode in object initializer");
|
||||
|
||||
AtomIndexAddPtr p = seen.lookupForAdd(atom);
|
||||
if (p) {
|
||||
jsatomid index = p.value();
|
||||
AssignmentType oldAssignType = AssignmentType(index);
|
||||
if ((oldAssignType & assignType) &&
|
||||
(oldAssignType != VALUE || assignType != VALUE || pc->sc->needStrictChecks()))
|
||||
{
|
||||
JSAutoByteString name;
|
||||
if (!AtomToPrintableString(context, atom, &name))
|
||||
return null();
|
||||
|
||||
ParseReportKind reportKind =
|
||||
(oldAssignType == VALUE && assignType == VALUE && !pc->sc->needStrictChecks())
|
||||
? ParseWarning
|
||||
: (pc->sc->needStrictChecks() ? ParseStrictError : ParseError);
|
||||
if (!report(reportKind, pc->sc->strict, null(),
|
||||
JSMSG_DUPLICATE_PROPERTY, name.ptr()))
|
||||
{
|
||||
return null();
|
||||
}
|
||||
}
|
||||
p.value() = assignType | oldAssignType;
|
||||
} else {
|
||||
if (!seen.add(p, atom, assignType))
|
||||
return null();
|
||||
}
|
||||
|
||||
TokenKind tt = tokenStream.getToken();
|
||||
if (tt == TOK_RC)
|
||||
break;
|
||||
|
308
js/src/tests/dupl-prop-changes.diff
Normal file
308
js/src/tests/dupl-prop-changes.diff
Normal file
@ -0,0 +1,308 @@
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5-4-4-a-1-s.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5-4-4-a-1-s.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5-4-4-a-1-s.js
|
||||
+++ /dev/null
|
||||
@@ -1,31 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * a. This production is contained in strict code and IsDataDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5-4-4-a-1-s.js
|
||||
- * @description Object literal - SyntaxError for duplicate date property name in strict mode
|
||||
- * @onlyStrict
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
-
|
||||
- try
|
||||
- {
|
||||
- eval("'use strict'; ({foo:0,foo:1});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return (e instanceof SyntaxError);
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-b-1.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-b-1.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-b-1.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-b-1.js
|
||||
- * @description Object literal - SyntaxError if a data property definition is followed by get accessor definition with the same name
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({foo : 1, get foo(){}});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-b-2.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-b-2.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-b-2.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-b-2.js
|
||||
- * @description Object literal - SyntaxError if a data property definition is followed by set accessor definition with the same name
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({foo : 1, set foo(x){}});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-c-1.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-c-1.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-c-1.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-c-1.js
|
||||
- * @description Object literal - SyntaxError if a get accessor property definition is followed by a data property definition with the same name
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({get foo(){}, foo : 1});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-c-2.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-c-2.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-c-2.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-c-2.js
|
||||
- * @description Object literal - SyntaxError if a set accessor property definition is followed by a data property definition with the same name
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({set foo(x){}, foo : 1});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-1.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-1.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-1.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-d-1.js
|
||||
- * @description Object literal - SyntaxError for duplicate property name (get,get)
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({get foo(){}, get foo(){}});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-2.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-2.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-2.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-d-2.js
|
||||
- * @description Object literal - SyntaxError for duplicate property name (set,set)
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({set foo(arg){}, set foo(arg1){}});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-3.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-3.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-3.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-d-3.js
|
||||
- * @description Object literal - SyntaxError for duplicate property name (get,set,get)
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({get foo(){}, set foo(arg){}, get foo(){}});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
||||
diff --git a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-4.js b/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-4.js
|
||||
deleted file mode 100644
|
||||
--- a/js/src/tests/test262/ch11/11.1/11.1.5/11.1.5_4-4-d-4.js
|
||||
+++ /dev/null
|
||||
@@ -1,29 +0,0 @@
|
||||
-/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
-/// Ecma International makes this code available under the terms and conditions set
|
||||
-/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
-/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
-/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
-/**
|
||||
- * Refer 11.1.5;
|
||||
- * The production
|
||||
- * PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
- * 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
- * d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
- *
|
||||
- * @path ch11/11.1/11.1.5/11.1.5_4-4-d-4.js
|
||||
- * @description Object literal - SyntaxError for duplicate property name (set,get,set)
|
||||
- */
|
||||
-
|
||||
-
|
||||
-function testcase() {
|
||||
- try
|
||||
- {
|
||||
- eval("({set foo(arg){}, get foo(){}, set foo(arg1){}});");
|
||||
- return false;
|
||||
- }
|
||||
- catch(e)
|
||||
- {
|
||||
- return e instanceof SyntaxError;
|
||||
- }
|
||||
- }
|
||||
-runTestCase(testcase);
|
@ -1,44 +0,0 @@
|
||||
// Any copyright is dedicated to the Public Domain.
|
||||
// http://creativecommons.org/licenses/publicdomain/
|
||||
"use strict";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 657713;
|
||||
var summary =
|
||||
"eval JSON parser hack misfires in strict mode, for objects with duplicate " +
|
||||
"property names";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
/**************
|
||||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
try
|
||||
{
|
||||
var r = eval('({"a": 2, "a": 3})');
|
||||
throw new Error("didn't throw, returned " + r);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
assertEq(e instanceof SyntaxError, true,
|
||||
"strict mode forbids objects with duplicated property names: " + e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var r = Function("'use strict'; return eval('({\"a\": 2, \"a\": 3})');")();
|
||||
throw new Error("didn't throw, returned " + r);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
assertEq(e instanceof SyntaxError, true,
|
||||
"strict mode forbids objects with duplicated property names: " + e);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
||||
print("Tests complete!");
|
@ -8,7 +8,7 @@
|
||||
/* Simple identifier labels. */
|
||||
assertEq(testLenientAndStrict('({x:1, x:1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({x:1, y:1})',
|
||||
@ -18,39 +18,39 @@ assertEq(testLenientAndStrict('({x:1, y:1})',
|
||||
|
||||
assertEq(testLenientAndStrict('({x:1, y:1, x:1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
/* Property names can be written as strings, too. */
|
||||
assertEq(testLenientAndStrict('({x:1, "x":1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({"x":1, x:1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({"x":1, "x":1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
/* Numeric property names. */
|
||||
assertEq(testLenientAndStrict('({1.5:1, 1.5:1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({1.5:1, 15e-1:1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({6.02214179e23:1, 6.02214179e23:1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({6.02214179e23:1, 3.1415926535:1})',
|
||||
@ -60,22 +60,22 @@ assertEq(testLenientAndStrict('({6.02214179e23:1, 3.1415926535:1})',
|
||||
|
||||
assertEq(testLenientAndStrict('({ 1: 1, "1": 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({ "1": 1, 1: 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({ 2.5: 1, "2.5": 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({ "2.5": 1, 2.5: 2 })',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
/* Many properties, to exercise JSAtomList's hash-table variant. */
|
||||
@ -86,7 +86,7 @@ assertEq(testLenientAndStrict('({a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:
|
||||
|
||||
assertEq(testLenientAndStrict('({a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:1, k:1, l:1, m:1, n:1, o:1, p:1, q:1, r:1, s:1, t:1, u:1, v:1, w:1, x:1, y:1, a:1})',
|
||||
parsesSuccessfully,
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
/*
|
||||
@ -94,43 +94,43 @@ assertEq(testLenientAndStrict('({a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:
|
||||
* appropriate.
|
||||
*/
|
||||
assertEq(testLenientAndStrict('({get x() {}, x:1})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({x:1, get x() {}})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({set x(q) {}, x:1})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({x:1, set x(q) {}})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({1:1, set 1(q) {}})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({set 1(q) {}, 1:1})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({"1":1, set 1(q) {}})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({set 1(q) {}, "1":1})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({get x() {}, set x(q) {}})',
|
||||
@ -144,23 +144,23 @@ assertEq(testLenientAndStrict('({set x(q) {}, get x() {}})',
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({get x() {}, set x(q) {}, x:1})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({set x(q) {}, get x() {}, x:1})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({get x() {}, get x() {}})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({set x() {}, set x() {}})',
|
||||
parseRaisesException(SyntaxError),
|
||||
parseRaisesException(SyntaxError)),
|
||||
assertEq(testLenientAndStrict('({set x(q) {}, set x(q) {}})',
|
||||
parsesSuccessfully,
|
||||
parsesSuccessfully),
|
||||
true);
|
||||
|
||||
assertEq(testLenientAndStrict('({get x() {}, set x(q) {}, y:1})',
|
||||
|
@ -143,6 +143,23 @@ var obj = {
|
||||
}
|
||||
assertEq(obj.a.call(), "hey");
|
||||
|
||||
// Duplicates
|
||||
var obj = {
|
||||
meth : 3,
|
||||
meth() { return 4; },
|
||||
meth() { return 5; }
|
||||
}
|
||||
assertEq(obj.meth(), 5);
|
||||
|
||||
var obj = {
|
||||
meth() { return 4; },
|
||||
meth() { return 5; },
|
||||
meth : 3
|
||||
}
|
||||
assertEq(obj.meth, 3);
|
||||
assertThrowsInstanceOf(function() {obj.meth();}, TypeError);
|
||||
|
||||
|
||||
// Tests provided by benvie in the bug to distinguish from ES5 desugar.
|
||||
assertEq(({ method() {} }).method.name, "method");
|
||||
assertThrowsInstanceOf(function() {({ method() { method() } }).method() }, ReferenceError);
|
||||
|
116
js/src/tests/ecma_6/Object/duplProps.js
Normal file
116
js/src/tests/ecma_6/Object/duplProps.js
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* ES6 allows duplicate property names in object literals, even in strict mode.
|
||||
* These tests modify the tests in test262 to reflect this change.
|
||||
*/
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5-4-4-a-1-s.js
|
||||
a = function() { "use strict"; return { foo: 0, foo : 1 }};
|
||||
assertEq(a().foo, 1);
|
||||
a = function() { return { foo: 0, foo : 1 }};
|
||||
assertEq(a().foo, 1);
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-b-1.js
|
||||
a = function() { "use strict"; return { foo : 1, get foo() { return 2; }}};
|
||||
assertEq(a().foo, 2);
|
||||
a = function() { return { foo : 1, get foo() { return 2;} }};
|
||||
assertEq(a().foo, 2);
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-c-1.js
|
||||
a = function() { "use strict"; return { get foo() { return 2; }, foo : 1 }};
|
||||
assertEq(a().foo, 1);
|
||||
a = function() { return { get foo() { return 2; }, foo : 1 }};
|
||||
assertEq(a().foo, 1);
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-b-2.js
|
||||
a = function() { "use strict"; return { foo : 1, set foo(a) { throw 2; }}};
|
||||
try {
|
||||
a().foo = 5;
|
||||
throw new Error("2 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 2)
|
||||
throw new Error("2 should be thrown here");
|
||||
}
|
||||
a = function() { return { foo : 1, set foo(a) { throw 2;} }};
|
||||
try {
|
||||
a().foo = 5;
|
||||
throw new Error("2 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 2)
|
||||
throw new Error("2 should be thrown here");
|
||||
}
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-1.js
|
||||
a = function() { "use strict"; return { get foo() { return 2; }, get foo() { return 3; } }};
|
||||
assertEq(a().foo, 3);
|
||||
a = function() { return { get foo() { return 2; }, get foo() { return 3; } }};
|
||||
assertEq(a().foo, 3);
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-c-2.js
|
||||
a = function() { "use strict"; return { set foo(a) { throw 2; }, foo : 1 }};
|
||||
assertEq(a().foo, 1);
|
||||
a = function() { return { set foo(a) { throw 2; }, foo : 1 }};
|
||||
assertEq(a().foo, 1);
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-2.js
|
||||
a = function() { "use strict"; return { set foo(a) { throw 2; }, set foo(a) { throw 3; }}};
|
||||
try {
|
||||
a().foo = 5;
|
||||
throw new Error("3 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 3)
|
||||
throw new Error("3 should be thrown here");
|
||||
}
|
||||
a = function() { return { set foo(a) { throw 2; }, set foo(a) { throw 3; }}};
|
||||
try {
|
||||
a().foo = 5;
|
||||
throw new Error("3 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 3)
|
||||
throw new Error("3 should be thrown here");
|
||||
}
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-3.js
|
||||
a = function() { "use strict"; return { get foo() { return 2; }, set foo(a) { throw 3; },
|
||||
get foo() { return 4; }}};
|
||||
try {
|
||||
assertEq(a().foo, 4);
|
||||
a().foo = 5;
|
||||
throw new Error("3 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 3)
|
||||
throw new Error("3 should be thrown here");
|
||||
}
|
||||
a = function() { return { get foo() { return 2; }, set foo(a) { throw 3; },
|
||||
get foo() { return 4; }}};
|
||||
try {
|
||||
assertEq(a().foo, 4);
|
||||
a().foo = 5;
|
||||
throw new Error("3 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 3)
|
||||
throw new Error("3 should be thrown here");
|
||||
}
|
||||
|
||||
// test262/ch11/11.1/11.1.5/11.1.5_4-4-d-4.js
|
||||
a = function() { "use strict"; return { set foo(a) { throw 2; }, get foo() { return 4; },
|
||||
set foo(a) { throw 3; }}};
|
||||
try {
|
||||
assertEq(a().foo, 4);
|
||||
a().foo = 5;
|
||||
throw new Error("3 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 3)
|
||||
throw new Error("3 should be thrown here");
|
||||
}
|
||||
a = function() { return { set foo(a) { throw 2; }, get foo() { return 4; },
|
||||
set foo(a) { throw 3; }}};
|
||||
try {
|
||||
assertEq(a().foo, 4);
|
||||
a().foo = 5;
|
||||
throw new Error("3 should be thrown here");
|
||||
} catch (e) {
|
||||
if (e !== 3)
|
||||
throw new Error("3 should be thrown here");
|
||||
}
|
||||
|
||||
reportCompare(0, 0);
|
@ -29,37 +29,6 @@ function test()
|
||||
options('werror');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expect = 'SyntaxError: property name a appears more than once in object literal';
|
||||
eval('({a:4, a:5})');
|
||||
// syntax warning, need to eval to catch
|
||||
actual = 'No warning';
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
actual = ex + '';
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
|
||||
print('test crash from bug 371292 Comment 3');
|
||||
|
||||
try
|
||||
{
|
||||
expect = 'SyntaxError: property name 1 appears more than once in object literal';
|
||||
eval('({1:1, 1:2})');
|
||||
// syntax warning, need to eval to catch
|
||||
actual = 'No warning';
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
actual = ex + '';
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
|
||||
|
||||
print('test crash from bug 371292 Comment 9');
|
||||
|
||||
try
|
||||
|
@ -1,31 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* a. This production is contained in strict code and IsDataDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5-4-4-a-1-s.js
|
||||
* @description Object literal - SyntaxError for duplicate date property name in strict mode
|
||||
* @onlyStrict
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
|
||||
try
|
||||
{
|
||||
eval("'use strict'; ({foo:0,foo:1});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return (e instanceof SyntaxError);
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-b-1.js
|
||||
* @description Object literal - SyntaxError if a data property definition is followed by get accessor definition with the same name
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({foo : 1, get foo(){}});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-b-2.js
|
||||
* @description Object literal - SyntaxError if a data property definition is followed by set accessor definition with the same name
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({foo : 1, set foo(x){}});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-c-1.js
|
||||
* @description Object literal - SyntaxError if a get accessor property definition is followed by a data property definition with the same name
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({get foo(){}, foo : 1});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-c-2.js
|
||||
* @description Object literal - SyntaxError if a set accessor property definition is followed by a data property definition with the same name
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({set foo(x){}, foo : 1});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-d-1.js
|
||||
* @description Object literal - SyntaxError for duplicate property name (get,get)
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({get foo(){}, get foo(){}});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-d-2.js
|
||||
* @description Object literal - SyntaxError for duplicate property name (set,set)
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({set foo(arg){}, set foo(arg1){}});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-d-3.js
|
||||
* @description Object literal - SyntaxError for duplicate property name (get,set,get)
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({get foo(){}, set foo(arg){}, get foo(){}});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -1,29 +0,0 @@
|
||||
/// Copyright (c) 2012 Ecma International. All rights reserved.
|
||||
/// Ecma International makes this code available under the terms and conditions set
|
||||
/// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
|
||||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
/**
|
||||
* Refer 11.1.5;
|
||||
* The production
|
||||
* PropertyNameAndValueList : PropertyNameAndValueList , PropertyAssignment
|
||||
* 4. If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
* d. IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true and either both previous and propId.descriptor have [[Get]] fields or both previous and propId.descriptor have [[Set]] fields
|
||||
*
|
||||
* @path ch11/11.1/11.1.5/11.1.5_4-4-d-4.js
|
||||
* @description Object literal - SyntaxError for duplicate property name (set,get,set)
|
||||
*/
|
||||
|
||||
|
||||
function testcase() {
|
||||
try
|
||||
{
|
||||
eval("({set foo(arg){}, get foo(){}, set foo(arg1){}});");
|
||||
return false;
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
return e instanceof SyntaxError;
|
||||
}
|
||||
}
|
||||
runTestCase(testcase);
|
@ -135,6 +135,7 @@ hg addremove ${test262_dir}
|
||||
# for spec changes, or where we're experimenting with semantics that disagree
|
||||
# with those in test262. See below: this isn't every test we don't pass!
|
||||
patch -d "${js_src_tests_dir}" -p4 < ./function-arguments-caller-changes.diff
|
||||
patch -d "${js_src_tests_dir}" -p4 < ./dupl-prop-changes.diff
|
||||
|
||||
# The alert reader may now be wondering: what about test262 tests that we don't
|
||||
# pass? (And what about any test262 tests whose format we don't yet support?)
|
||||
|
Loading…
Reference in New Issue
Block a user