Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = "344139";
8 var summary = "Basic let functionality";
9 var actual, expect;
11 printBugNumber(BUGNUMBER);
12 printStatus(summary);
14 /**************
15 * BEGIN TEST *
16 **************/
18 var failed = false;
20 var x = 7;
22 function f1()
23 {
24 let x = 5;
25 return x;
26 }
28 function f2()
29 {
30 let x = 5;
31 x = 3;
32 return x;
33 }
35 function f3()
36 {
37 let x = 5;
38 x += x;
39 return x;
40 }
42 function f4()
43 {
44 var v = 5;
45 let q = 17;
47 // 0+1+2+...+8+9 == 45
48 for (let v = 0; v < 10; v++)
49 q += v;
51 if (q != 62)
52 throw "f4(): wrong value for q\n" +
53 " expected: 62\n" +
54 " actual: " + q;
56 return v;
57 }
59 try
60 {
61 if (f1() != 5 || x != 7)
62 throw "f1() == 5";
63 if (f2() != 3 || x != 7)
64 throw "f2() == 3";
65 if (f3() != 10 || x != 7)
66 throw "f3() == 10";
68 if (f4() != 5)
69 throw "f4() == 5";
71 var bad = true;
72 try
73 {
74 eval("q++"); // force error at runtime
75 }
76 catch (e)
77 {
78 if (e instanceof ReferenceError)
79 bad = false;
80 }
81 if (bad)
82 throw "f4(): q escaping scope!";
83 }
84 catch (e)
85 {
86 failed = e;
87 }
89 expect = false;
90 actual = failed;
92 reportCompare(expect, actual, summary);