Debian Codegraph @

js/src/tests/non262/regress/regress-507053.js

raw
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 507053;
8 var summary = 'TM: invalid results with setting a closure variable in a loop'
9 var actual = '';
10 var expect = '2,4,8,16,32,2,4,8,16,32,2,4,8,16,32,2,4,8,16,32,2,4,8,16,32,';
11
12
13 //-----------------------------------------------------------------------------
14 start_test();
15
16 var f = function() {
17 var p = 1;
18
19 function g() {
20 for (var i = 0; i < 5; ++i) {
21 p = p * 2;
22 actual += p + ',';
23 }
24 }
25 g();
26 }
27
28 for (var i = 0; i < 5; ++i) {
29 f();
30 }
31
32 finish_test();
33 //-----------------------------------------------------------------------------
34
35 function start_test()
36 {
37 printBugNumber(BUGNUMBER);
38 printStatus (summary);
39 }
40
41 function finish_test()
42 {
43 reportCompare(expect, actual, summary);
44 }