Debian Codegraph @

rhino/testsrc/tests/js1_5/Array/regress-154338.js

raw symbols SCIP
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 *
8 * Date: 26 June 2002
9 * SUMMARY: Testing array.join() when separator is a variable, not a literal
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=154338
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var gTestfile = 'regress-154338.js';
15 var UBound = 0;
16 var BUGNUMBER = 154338;
17 var summary = 'Test array.join() when separator is a variable, not a literal';
18 var status = '';
19 var statusitems = [];
20 var actual = '';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
24
25
26 /*
27 * Note that x === 'H' and y === 'ome'.
28 *
29 * Yet for some reason, using |x| or |y| as the separator
30 * in arr.join() was causing out-of-memory errors, whereas
31 * using the literals 'H', 'ome' was not -
32 *
33 */
34 var x = 'Home'[0];
35 var y = ('Home'.split('H'))[1];
36
37
38 status = inSection(1);
39 var arr = Array('a', 'b');
40 actual = arr.join('H');
41 expect = 'aHb';
42 addThis();
43
44 status = inSection(2);
45 arr = Array('a', 'b');
46 actual = arr.join(x);
47 expect = 'aHb';
48 addThis();
49
50 status = inSection(3);
51 arr = Array('a', 'b');
52 actual = arr.join('ome');
53 expect = 'aomeb';
54 addThis();
55
56 status = inSection(4);
57 arr = Array('a', 'b');
58 actual = arr.join(y);
59 expect = 'aomeb';
60 addThis();
61
62
63
64 //-----------------------------------------------------------------------------
65 test();
66 //-----------------------------------------------------------------------------
67
68
69
70 function addThis()
71 {
72 statusitems[UBound] = status;
73 actualvalues[UBound] = actual;
74 expectedvalues[UBound] = expect;
75 UBound++;
76 }
77
78
79 function test()
80 {
81 enterFunc('test');
82 printBugNumber(BUGNUMBER);
83 printStatus(summary);
84
85 for (var i=0; i<UBound; i++)
86 {
87 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
88 }
89
90 exitFunc ('test');
91 }