|
1 // Any copyright is dedicated to the Public Domain. |
|
2 // http://creativecommons.org/licenses/publicdomain/ |
|
3 "use strict"; |
|
4 |
|
5 //----------------------------------------------------------------------------- |
|
6 var BUGNUMBER = 657713; |
|
7 var summary = |
|
8 "eval JSON parser hack misfires in strict mode, for objects with duplicate " + |
|
9 "property names"; |
|
10 |
|
11 print(BUGNUMBER + ": " + summary); |
|
12 |
|
13 /************** |
|
14 * BEGIN TEST * |
|
15 **************/ |
|
16 |
|
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 } |
|
27 |
|
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 } |
|
38 |
|
39 /******************************************************************************/ |
|
40 |
|
41 if (typeof reportCompare === "function") |
|
42 reportCompare(true, true); |
|
43 |
|
44 print("Tests complete!"); |