1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Regress/regress-159334.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,95 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * 1.11 + * Date: 31 Oct 2002 1.12 + * SUMMARY: Testing script with at least 64K of different string literals 1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=159334 1.14 + * 1.15 + * Testing that script engine can handle scripts with at least 64K of different 1.16 + * string literals. The following will evaluate, via eval(), a script like this: 1.17 + * 1.18 + * f('0') 1.19 + * f('1') 1.20 + * ... 1.21 + * f('N - 1') 1.22 + * 1.23 + * where N is 0xFFFE 1.24 + * 1.25 + */ 1.26 +//----------------------------------------------------------------------------- 1.27 +var UBound = 0; 1.28 +var BUGNUMBER = 159334; 1.29 +var summary = 'Testing script with at least 64K of different string literals'; 1.30 +var status = ''; 1.31 +var statusitems = []; 1.32 +var actual = ''; 1.33 +var actualvalues = []; 1.34 +var expect= ''; 1.35 +var expectedvalues = []; 1.36 + 1.37 + 1.38 +var N = 0xFFFE; 1.39 + 1.40 +// Create big string for eval recursively to avoid N*N behavior 1.41 +// on string concatenation 1.42 +var long_eval = buildEval_r(0, N); 1.43 + 1.44 +// Run it 1.45 +var test_sum = 0; 1.46 +function f(str) { test_sum += Number(str); } 1.47 +eval(long_eval); 1.48 + 1.49 +status = inSection(1); 1.50 +actual = (test_sum == N * (N - 1) / 2); 1.51 +expect = true; 1.52 +addThis(); 1.53 + 1.54 + 1.55 + 1.56 +//----------------------------------------------------------------------------- 1.57 +test(); 1.58 +//----------------------------------------------------------------------------- 1.59 + 1.60 + 1.61 + 1.62 +function buildEval_r(beginLine, endLine) 1.63 +{ 1.64 + var count = endLine - beginLine; 1.65 + 1.66 + if (count == 0) 1.67 + return ""; 1.68 + 1.69 + if (count == 1) 1.70 + return "f('" + beginLine + "')\n"; 1.71 + 1.72 + var middle = beginLine + (count >>> 1); 1.73 + return buildEval_r(beginLine, middle) + buildEval_r(middle, endLine); 1.74 +} 1.75 + 1.76 + 1.77 +function addThis() 1.78 +{ 1.79 + statusitems[UBound] = status; 1.80 + actualvalues[UBound] = actual; 1.81 + expectedvalues[UBound] = expect; 1.82 + UBound++; 1.83 +} 1.84 + 1.85 + 1.86 +function test() 1.87 +{ 1.88 + enterFunc('test'); 1.89 + printBugNumber(BUGNUMBER); 1.90 + printStatus(summary); 1.91 + 1.92 + for (var i=0; i<UBound; i++) 1.93 + { 1.94 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.95 + } 1.96 + 1.97 + exitFunc ('test'); 1.98 +}