Debian Codegraph @

rhino/testsrc/tests/js1_7/decompilation/regress-351070-01.js

raw symbols SCIP
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 var gTestfile = 'regress-351070-01.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 351070;
9 var summary = 'decompilation of let declaration should not change scope';
10 var summarytrunk = 'let declaration must be direct child of block or top-level implicit block';
11
12 var actual = '';
13 var expect = '';
14
15
16 //-----------------------------------------------------------------------------
17 test();
18 //-----------------------------------------------------------------------------
19
20 function test()
21 {
22 enterFunc ('test');
23 printBugNumber(BUGNUMBER);
24 printStatus (summary);
25
26 var f;
27 var c;
28
29 try
30 {
31 c = '(function () { var a = 2; if (!!true) let a = 3; return a; })';
32 f = eval(c);
33 expect = 'function () { var a = 2; if (!!true) let a = 3; return a; }';
34 actual = f + '';
35 compareSource(expect, actual, summary);
36
37 expect = 3;
38 actual = f();
39 reportCompare(expect, actual, summary);
40 }
41 catch(ex)
42 {
43 // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
44 expect = 'SyntaxError';
45 actual = ex.name;
46 reportCompare(expect, actual, summarytrunk + ': ' + c);
47 }
48
49 try
50 {
51 c = '(function () { var a = 2; if (!!true) {let a = 3;} return a; })';
52 f = eval(c);
53 expect = 'function () { var a = 2; if (!!true) { let a = 3;} return a; }';
54 actual = f + '';
55 compareSource(expect, actual, summary);
56
57 expect = 2;
58 actual = f();
59 reportCompare(expect, actual, summary);
60 }
61 catch(ex)
62 {
63 // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957
64 expect = 'SyntaxError';
65 actual = ex.name;
66 reportCompare(expect, actual, summarytrunk + ': ' + c);
67 }
68
69 exitFunc ('test');
70 }