Debian Codegraph @

rhino/testsrc/tests/js1_7/block/regress-411279.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-411279.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 411279;
9 var summary = 'let declaration as direct child of switch body block';
10 var actual = 'No Crash';
11 var expect = 'No Crash';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 function f(x)
25 {
26 var value = '';
27
28 switch(x)
29 {
30 case 1:
31 value = "1 " + y;
32 break;
33 case 2:
34 let y = 42;
35 value = "2 " + y;
36 break;
37 default:
38 value = "default " + y;
39 }
40
41 return value;
42 }
43
44 expect = 'function f(x) { var value = ""; switch (x) { '
45 + 'case 1: value = "1 " + y; break; '
46 + 'case 2: let y = 42; value = "2 " + y; break; '
47 + 'default: value = "default " + y; } return value; }';
48
49 actual = f + '';
50
51 compareSource(expect, actual, summary);
52
53 expect = '1 undefined';
54 actual = f(1);
55 reportCompare(expect, actual, summary + ': f(1)');
56
57 expect = '2 42';
58 actual = f(2);
59 reportCompare(expect, actual, summary + ': f(2)');
60
61 expect = 'default undefined';
62 actual = f(3);
63 reportCompare(expect, actual, summary + ': f(3)');
64
65 exitFunc ('test');
66 }