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

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:52f67372d1d0
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 //-----------------------------------------------------------------------------
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 jit(true);
16
17 var f = function() {
18 var p = 1;
19
20 function g() {
21 for (var i = 0; i < 5; ++i) {
22 p = p * 2;
23 actual += p + ',';
24 }
25 }
26 g();
27 }
28
29 for (var i = 0; i < 5; ++i) {
30 f();
31 }
32
33 jit(false);
34 finish_test();
35 //-----------------------------------------------------------------------------
36
37 function start_test()
38 {
39 enterFunc ('test');
40 printBugNumber(BUGNUMBER);
41 printStatus (summary);
42 }
43
44 function finish_test()
45 {
46 reportCompare(expect, actual, summary);
47 exitFunc ('test');
48 }

mercurial