|
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/. */ |
|
5 |
|
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; |
|
14 |
|
15 printBugNumber(BUGNUMBER); |
|
16 printStatus (summary); |
|
17 |
|
18 |
|
19 if (typeof uneval != 'undefined') |
|
20 { |
|
21 status = inSection(1) + ' eval(uneval({"if": false}))'; |
|
22 |
|
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 } |
|
35 |
|
36 reportCompare(expect, actual, status); |
|
37 |
|
38 status = inSection(2) + ' eval(uneval({"if": "then"}))'; |
|
39 |
|
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 } |
|
52 |
|
53 reportCompare(expect, actual, status); |
|
54 |
|
55 status = inSection(3) + ' eval(uneval(f))'; |
|
56 |
|
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 } |
|
68 |
|
69 reportCompare(expect, actual, status); |
|
70 |
|
71 status = inSection(2) + ' eval(uneval(g))'; |
|
72 |
|
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 } |
|
84 |
|
85 reportCompare(expect, actual, status); |
|
86 } |
|
87 |
|
88 function f() |
|
89 { |
|
90 var obj = new Object(); |
|
91 |
|
92 obj['name'] = 'Just a name'; |
|
93 obj['if'] = false; |
|
94 obj['some text'] = 'correct'; |
|
95 } |
|
96 |
|
97 function g() |
|
98 { |
|
99 return {'if': "then"}; |
|
100 } |
|
101 |