js/src/tests/ecma_5/eval/strict-eval-json-object-repeated-property-name.js

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

     1 // Any copyright is dedicated to the Public Domain.
     2 // http://creativecommons.org/licenses/publicdomain/
     3 "use strict";
     5 //-----------------------------------------------------------------------------
     6 var BUGNUMBER = 657713;
     7 var summary =
     8   "eval JSON parser hack misfires in strict mode, for objects with duplicate " +
     9   "property names";
    11 print(BUGNUMBER + ": " + summary);
    13 /**************
    14  * BEGIN TEST *
    15  **************/
    17 try
    18 {
    19   var r = eval('({"a": 2, "a": 3})');
    20   throw new Error("didn't throw, returned " + r);
    21 }
    22 catch (e)
    23 {
    24   assertEq(e instanceof SyntaxError, true,
    25            "strict mode forbids objects with duplicated property names: " + e);
    26 }
    28 try
    29 {
    30   var r = Function("'use strict'; return eval('({\"a\": 2, \"a\": 3})');")();
    31   throw new Error("didn't throw, returned " + r);
    32 }
    33 catch (e)
    34 {
    35   assertEq(e instanceof SyntaxError, true,
    36            "strict mode forbids objects with duplicated property names: " + e);
    37 }
    39 /******************************************************************************/
    41 if (typeof reportCompare === "function")
    42   reportCompare(true, true);
    44 print("Tests complete!");

mercurial