Debian Codegraph @

js/src/tests/non262/extensions/uneval/regress-385729.js

raw
1 // |reftest| skip-if(!this.uneval)
2
3 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 //-----------------------------------------------------------------------------
9 var BUGNUMBER = 385729;
10 var summary = 'uneval(eval(expression closure))';
11 var actual = 'No Crash';
12 var expect = 'No Crash';
13
14 function normalizeSource(source) {
15 source = String(source);
16 source = source.replace(/([(){},.:\[\]])/mg, ' $1 ');
17 source = source.replace(/\s+/mg, ' ');
18
19 return source;
20 }
21
22 //-----------------------------------------------------------------------------
23 test();
24 //-----------------------------------------------------------------------------
25
26 function test()
27 {
28 printBugNumber(BUGNUMBER);
29 printStatus (summary);
30
31 expect = '(function f () /x/g)';
32 try
33 {
34 // mozilla 1.9
35 actual = uneval(eval(expect));
36 }
37 catch(ex)
38 {
39 // mozilla 1.8
40 expect = 'SyntaxError: missing { before function body';
41 actual = ex + '';
42 }
43 compareSource(normalizeSource(expect), normalizeSource(actual), summary);
44
45 expect = '({get f () /x/g})';
46 try
47 {
48 // mozilla 1.9
49 actual = uneval(eval("({get f () /x/g})"));
50 }
51 catch(ex)
52 {
53 // mozilla 1.8
54 expect = 'SyntaxError: missing { before function body';
55 actual = ex + '';
56 }
57 compareSource(normalizeSource(expect), normalizeSource(actual), summary);
58 }