Debian Codegraph @

rhino/testsrc/tests/js1_7/block/regress-343765.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-343765.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 343765;
9 var summary = 'Function defined in a let statement/expression does not work correctly outside the let scope';
10 var actual = '';
11 var expect = '';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 print("SECTION 1");
25 try {
26 let (a = 2, b = 3) { function f() { return String([a,b]); } f(); throw 42; }
27 } catch (e) {
28 f();
29 }
30
31 reportCompare(expect, actual, summary);
32
33 print("SECTION 2");
34 try {
35 with ({a:2,b:3}) { function f() { return String([a,b]); } f(); throw 42; }
36 } catch (e) {
37 f();
38 }
39
40 print("SECTION 3");
41 function g3() {
42 print("Here!");
43 with ({a:2,b:3}) {
44 function f() {
45 return String([a,b]);
46 }
47
48 f();
49 return f;
50 }
51 }
52
53 k = g3();
54 k();
55
56 print("SECTION 4");
57 function g4() {
58 print("Here!");
59 let (a=2,b=3) {
60 function f() {
61 return String([a,b]);
62 }
63
64 f();
65 return f;
66 }
67 }
68
69 k = g4();
70 k();
71
72 print("SECTION 5");
73 function g5() {
74 print("Here!");
75 let (a=2,b=3) {
76 function f() {
77 return String([a,b]);
78 }
79
80 f();
81 yield f;
82 }
83 }
84
85 k = g5().next();
86 k();
87
88 reportCompare(expect, actual, summary);
89
90 exitFunc ('test');
91 }
92
93 function returnResult(a)
94 {
95 return a + '';
96 }