diff -r 000000000000 -r 6474c204b198 js/src/tests/ecma_5/eval/strict-eval-json-object-repeated-property-name.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/src/tests/ecma_5/eval/strict-eval-json-object-repeated-property-name.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,44 @@ +// 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!");