Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 231518;
8 var summary = 'decompiler must quote keywords and non-identifier property names';
9 var actual = '';
10 var expect = 'no error';
11 var status;
12 var object;
13 var result;
15 printBugNumber(BUGNUMBER);
16 printStatus (summary);
19 if (typeof uneval != 'undefined')
20 {
21 status = inSection(1) + ' eval(uneval({"if": false}))';
23 try
24 {
25 object = {'if': false };
26 result = uneval(object);
27 printStatus('uneval returns ' + result);
28 eval(result);
29 actual = 'no error';
30 }
31 catch(e)
32 {
33 actual = 'error';
34 }
36 reportCompare(expect, actual, status);
38 status = inSection(2) + ' eval(uneval({"if": "then"}))';
40 try
41 {
42 object = {'if': "then" };
43 result = uneval(object);
44 printStatus('uneval returns ' + result);
45 eval(result);
46 actual = 'no error';
47 }
48 catch(e)
49 {
50 actual = 'error';
51 }
53 reportCompare(expect, actual, status);
55 status = inSection(3) + ' eval(uneval(f))';
57 try
58 {
59 result = uneval(f);
60 printStatus('uneval returns ' + result);
61 eval(result);
62 actual = 'no error';
63 }
64 catch(e)
65 {
66 actual = 'error';
67 }
69 reportCompare(expect, actual, status);
71 status = inSection(2) + ' eval(uneval(g))';
73 try
74 {
75 result = uneval(g);
76 printStatus('uneval returns ' + result);
77 eval(result);
78 actual = 'no error';
79 }
80 catch(e)
81 {
82 actual = 'error';
83 }
85 reportCompare(expect, actual, status);
86 }
88 function f()
89 {
90 var obj = new Object();
92 obj['name'] = 'Just a name';
93 obj['if'] = false;
94 obj['some text'] = 'correct';
95 }
97 function g()
98 {
99 return {'if': "then"};
100 }