js/src/tests/js1_5/Array/regress-107138.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/Array/regress-107138.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,177 @@
     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 + * Date: 29 October 2001
    1.11 + *
    1.12 + * SUMMARY: Regression test for bug 107138
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=107138
    1.14 + *
    1.15 + * The bug: arr['1'] == undefined instead of arr['1'] == 'one'.
    1.16 + * The bug was intermittent and did not always occur...
    1.17 + *
    1.18 + * The cnSTRESS constant defines how many times to repeat this test.
    1.19 + */
    1.20 +//-----------------------------------------------------------------------------
    1.21 +var UBound = 0;
    1.22 +var cnSTRESS = 10;
    1.23 +var cnDASH = '-';
    1.24 +var BUGNUMBER = 107138;
    1.25 +var summary = 'Regression test for bug 107138';
    1.26 +var status = '';
    1.27 +var statusitems = [];
    1.28 +var actual = '';
    1.29 +var actualvalues = [];
    1.30 +var expect= '';
    1.31 +var expectedvalues = [];
    1.32 +
    1.33 +
    1.34 +var arr = ['zero', 'one', 'two', 'three', 'four', 'five',
    1.35 +           'six', 'seven', 'eight', 'nine', 'ten'];
    1.36 +
    1.37 +
    1.38 +// This bug was intermittent. Stress-test it.
    1.39 +for (var j=0; j<cnSTRESS; j++)
    1.40 +{
    1.41 +  status = inSection(j + cnDASH + 1);
    1.42 +  actual = arr[0];
    1.43 +  expect = 'zero';
    1.44 +  addThis();
    1.45 +
    1.46 +  status = inSection(j + cnDASH + 2);
    1.47 +  actual = arr['0'];
    1.48 +  expect = 'zero';
    1.49 +  addThis();
    1.50 +
    1.51 +  status = inSection(j + cnDASH + 3);
    1.52 +  actual = arr[1];
    1.53 +  expect = 'one';
    1.54 +  addThis();
    1.55 +
    1.56 +  status = inSection(j + cnDASH + 4);
    1.57 +  actual = arr['1'];
    1.58 +  expect = 'one';
    1.59 +  addThis();
    1.60 +
    1.61 +  status = inSection(j + cnDASH + 5);
    1.62 +  actual = arr[2];
    1.63 +  expect = 'two';
    1.64 +  addThis();
    1.65 +
    1.66 +  status = inSection(j + cnDASH + 6);
    1.67 +  actual = arr['2'];
    1.68 +  expect = 'two';
    1.69 +  addThis();
    1.70 +
    1.71 +  status = inSection(j + cnDASH + 7);
    1.72 +  actual = arr[3];
    1.73 +  expect = 'three';
    1.74 +  addThis();
    1.75 +
    1.76 +  status = inSection(j + cnDASH + 8);
    1.77 +  actual = arr['3'];
    1.78 +  expect = 'three';
    1.79 +  addThis();
    1.80 +
    1.81 +  status = inSection(j + cnDASH + 9);
    1.82 +  actual = arr[4];
    1.83 +  expect = 'four';
    1.84 +  addThis();
    1.85 +
    1.86 +  status = inSection(j + cnDASH + 10);
    1.87 +  actual = arr['4'];
    1.88 +  expect = 'four';
    1.89 +  addThis();
    1.90 +
    1.91 +  status = inSection(j + cnDASH + 11);
    1.92 +  actual = arr[5];
    1.93 +  expect = 'five';
    1.94 +  addThis();
    1.95 +
    1.96 +  status = inSection(j + cnDASH + 12);
    1.97 +  actual = arr['5'];
    1.98 +  expect = 'five';
    1.99 +  addThis();
   1.100 +
   1.101 +  status = inSection(j + cnDASH + 13);
   1.102 +  actual = arr[6];
   1.103 +  expect = 'six';
   1.104 +  addThis();
   1.105 +
   1.106 +  status = inSection(j + cnDASH + 14);
   1.107 +  actual = arr['6'];
   1.108 +  expect = 'six';
   1.109 +  addThis();
   1.110 +
   1.111 +  status = inSection(j + cnDASH + 15);
   1.112 +  actual = arr[7];
   1.113 +  expect = 'seven';
   1.114 +  addThis();
   1.115 +
   1.116 +  status = inSection(j + cnDASH + 16);
   1.117 +  actual = arr['7'];
   1.118 +  expect = 'seven';
   1.119 +  addThis();
   1.120 +
   1.121 +  status = inSection(j + cnDASH + 17);
   1.122 +  actual = arr[8];
   1.123 +  expect = 'eight';
   1.124 +  addThis();
   1.125 +
   1.126 +  status = inSection(j + cnDASH + 18);
   1.127 +  actual = arr['8'];
   1.128 +  expect = 'eight';
   1.129 +  addThis();
   1.130 +
   1.131 +  status = inSection(j + cnDASH + 19);
   1.132 +  actual = arr[9];
   1.133 +  expect = 'nine';
   1.134 +  addThis();
   1.135 +
   1.136 +  status = inSection(j + cnDASH + 20);
   1.137 +  actual = arr['9'];
   1.138 +  expect = 'nine';
   1.139 +  addThis();
   1.140 +
   1.141 +  status = inSection(j + cnDASH + 21);
   1.142 +  actual = arr[10];
   1.143 +  expect = 'ten';
   1.144 +  addThis();
   1.145 +
   1.146 +  status = inSection(j + cnDASH + 22);
   1.147 +  actual = arr['10'];
   1.148 +  expect = 'ten';
   1.149 +  addThis();
   1.150 +}
   1.151 +
   1.152 +
   1.153 +//-----------------------------------------------------------------------------
   1.154 +test();
   1.155 +//-----------------------------------------------------------------------------
   1.156 +
   1.157 +
   1.158 +
   1.159 +function addThis()
   1.160 +{
   1.161 +  statusitems[UBound] = status;
   1.162 +  actualvalues[UBound] = actual;
   1.163 +  expectedvalues[UBound] = expect;
   1.164 +  UBound++;
   1.165 +}
   1.166 +
   1.167 +
   1.168 +function test()
   1.169 +{
   1.170 +  enterFunc ('test');
   1.171 +  printBugNumber(BUGNUMBER);
   1.172 +  printStatus (summary);
   1.173 +
   1.174 +  for (var i=0; i<UBound; i++)
   1.175 +  {
   1.176 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   1.177 +  }
   1.178 +
   1.179 +  exitFunc ('test');
   1.180 +}

mercurial