js/src/tests/js1_5/Array/regress-154338.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-154338.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,90 @@
     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:    26 June 2002
    1.12 + * SUMMARY: Testing array.join() when separator is a variable, not a literal
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=154338
    1.14 + *
    1.15 + */
    1.16 +//-----------------------------------------------------------------------------
    1.17 +var UBound = 0;
    1.18 +var BUGNUMBER = 154338;
    1.19 +var summary = 'Test array.join() when separator is a variable, not a literal';
    1.20 +var status = '';
    1.21 +var statusitems = [];
    1.22 +var actual = '';
    1.23 +var actualvalues = [];
    1.24 +var expect= '';
    1.25 +var expectedvalues = [];
    1.26 +
    1.27 +
    1.28 +/*
    1.29 + * Note that x === 'H' and y === 'ome'.
    1.30 + *
    1.31 + * Yet for some reason, using |x| or |y| as the separator
    1.32 + * in arr.join() was causing out-of-memory errors, whereas
    1.33 + * using the literals 'H', 'ome' was not -
    1.34 + *
    1.35 + */
    1.36 +var x = 'Home'[0];
    1.37 +var y = ('Home'.split('H'))[1];
    1.38 +
    1.39 +
    1.40 +status = inSection(1);
    1.41 +var arr = Array('a', 'b');
    1.42 +actual = arr.join('H');
    1.43 +expect = 'aHb';
    1.44 +addThis();
    1.45 +
    1.46 +status = inSection(2);
    1.47 +arr = Array('a', 'b');
    1.48 +actual = arr.join(x);
    1.49 +expect = 'aHb';
    1.50 +addThis();
    1.51 +
    1.52 +status = inSection(3);
    1.53 +arr = Array('a', 'b');
    1.54 +actual = arr.join('ome');
    1.55 +expect = 'aomeb';
    1.56 +addThis();
    1.57 +
    1.58 +status = inSection(4);
    1.59 +arr = Array('a', 'b');
    1.60 +actual = arr.join(y);
    1.61 +expect = 'aomeb';
    1.62 +addThis();
    1.63 +
    1.64 +
    1.65 +
    1.66 +//-----------------------------------------------------------------------------
    1.67 +test();
    1.68 +//-----------------------------------------------------------------------------
    1.69 +
    1.70 +
    1.71 +
    1.72 +function addThis()
    1.73 +{
    1.74 +  statusitems[UBound] = status;
    1.75 +  actualvalues[UBound] = actual;
    1.76 +  expectedvalues[UBound] = expect;
    1.77 +  UBound++;
    1.78 +}
    1.79 +
    1.80 +
    1.81 +function test()
    1.82 +{
    1.83 +  enterFunc('test');
    1.84 +  printBugNumber(BUGNUMBER);
    1.85 +  printStatus(summary);
    1.86 +
    1.87 +  for (var i=0; i<UBound; i++)
    1.88 +  {
    1.89 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    1.90 +  }
    1.91 +
    1.92 +  exitFunc ('test');
    1.93 +}

mercurial