js/src/tests/js1_5/GC/regress-319980-01.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/GC/regress-319980-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,127 @@
     1.4 +// |reftest| skip-if(!xulRuntime.shell) slow
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +//-----------------------------------------------------------------------------
    1.11 +var BUGNUMBER = 319980;
    1.12 +var summary = 'GC not called during non-fatal out of memory';
    1.13 +var actual = '';
    1.14 +var expect = 'Normal Exit';
    1.15 +
    1.16 +printBugNumber(BUGNUMBER);
    1.17 +printStatus (summary);
    1.18 +print ('This test should never fail explicitly. ' +
    1.19 +       'You must view the memory usage during the test. ' +
    1.20 +       'This test fails if memory usage for each subtest grows');
    1.21 +
    1.22 +var timeOut  = 45 * 1000;
    1.23 +var interval = 0.01  * 1000;
    1.24 +var testFuncWatcherId;
    1.25 +var testFuncTimerId;
    1.26 +var maxTests = 5;
    1.27 +var currTest = 0;
    1.28 +
    1.29 +if (typeof setTimeout == 'undefined')
    1.30 +{
    1.31 +  setTimeout = function() {};
    1.32 +  clearTimeout = function() {};
    1.33 +  actual = 'Normal Exit';
    1.34 +  reportCompare(expect, actual, summary);
    1.35 +}
    1.36 +else
    1.37 +{
    1.38 +  // delay start until after js-test-driver-end runs.
    1.39 +  // delay test driver end
    1.40 +  gDelayTestDriverEnd = true;
    1.41 +
    1.42 +  setTimeout(testFuncWatcher, 1000);
    1.43 +}
    1.44 +
    1.45 +function testFuncWatcher()
    1.46 +{
    1.47 +  a = null;
    1.48 +
    1.49 +  gc();
    1.50 +
    1.51 +  clearTimeout(testFuncTimerId);
    1.52 +  testFuncWatcherId = testFuncTimerId = null;
    1.53 +  if (currTest >= maxTests)
    1.54 +  {
    1.55 +    actual = 'Normal Exit';
    1.56 +    reportCompare(expect, actual, summary);
    1.57 +    printStatus('Test Completed');
    1.58 +    gDelayTestDriverEnd = false;
    1.59 +    jsTestDriverEnd();
    1.60 +    return;
    1.61 +  }
    1.62 +  ++currTest;
    1.63 + 
    1.64 +  print('Executing test ' + currTest + '\n');
    1.65 +
    1.66 +  testFuncWatcherId = setTimeout("testFuncWatcher()", timeOut);
    1.67 +  testFuncTimerId = setTimeout(testFunc, interval);
    1.68 +}
    1.69 +
    1.70 +
    1.71 +var a;
    1.72 +function testFunc()
    1.73 +{
    1.74 +
    1.75 +  var i;
    1.76 +
    1.77 +  switch(currTest)
    1.78 +  {
    1.79 +  case 1:
    1.80 +    a = new Array(100000);
    1.81 +    for (i = 0; i < 100000; i++ )
    1.82 +    {
    1.83 +      a[i] = i;
    1.84 +    }
    1.85 +    break;
    1.86 +
    1.87 +  case 2:
    1.88 +    a = new Array(100000);
    1.89 +    for (i = 0; i < 100000; i++)
    1.90 +    {
    1.91 +      a[i] = new Number();
    1.92 +      a[i] = i;
    1.93 +    }
    1.94 +    break;
    1.95 +
    1.96 +  case 3:
    1.97 +    a = new String() ;
    1.98 +    a = new Array(100000);
    1.99 +    for ( i = 0; i < 100000; i++ )
   1.100 +    {
   1.101 +      a[i] = i;
   1.102 +    }
   1.103 +
   1.104 +    break;
   1.105 +
   1.106 +  case 4:
   1.107 +    a = new Array();
   1.108 +    a[0] = new Array(100000);
   1.109 +    for (i = 0; i < 100000; i++ )
   1.110 +    {
   1.111 +      a[0][i] = i;
   1.112 +    }
   1.113 +    break;
   1.114 +
   1.115 +  case 5:
   1.116 +    a = new Array();
   1.117 +    for (i = 0; i < 100000; i++ )
   1.118 +    {
   1.119 +      a[i] = i;
   1.120 +    }
   1.121 +    break;
   1.122 +  }
   1.123 +
   1.124 +  if (testFuncTimerId)
   1.125 +  {
   1.126 +    testFuncTimerId = setTimeout(testFunc, interval);
   1.127 +  }
   1.128 +}
   1.129 +
   1.130 +

mercurial