Debian Codegraph @

rhino/testsrc/tests/js1_5/Array/regress-108440.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: 30 October 2001
9 * SUMMARY: Regression test for bug 108440
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=108440
11 *
12 * We shouldn't crash trying to add an array as an element of itself (!)
13 *
14 * Brendan: "...it appears that Array.prototype.toString is unsafe,
15 * and what's more, ECMA-262 Edition 3 has no helpful words about
16 * avoiding recursive death on a cycle."
17 */
18 //-----------------------------------------------------------------------------
19 var gTestfile = 'regress-108440.js';
20 var BUGNUMBER = 108440;
21 var summary = "Shouldn't crash trying to add an array as an element of itself";
22 var self = this;
23 var temp = '';
24
25 printBugNumber(BUGNUMBER);
26 printStatus(summary);
27
28 /*
29 * Explicit test:
30 */
31 var a=[];
32 temp = (a[a.length]=a);
33
34 /*
35 * Implicit test (one of the properties of |self| is |a|)
36 */
37 a=[];
38 for(var prop in self)
39 {
40 temp = prop;
41 temp = (a[a.length] = self[prop]);
42 }
43
44 /*
45 * Stressful explicit test
46 */
47 a=[];
48 for (var i=0; i<10; i++)
49 {
50 a[a.length] = a;
51 }
52
53 /*
54 * Test toString()
55 */
56 a=[];
57 for (var i=0; i<10; i++)
58 {
59 a[a.length] = a.toString();
60 }
61
62 /*
63 * Test toSource() - but Rhino doesn't have this, so try...catch it
64 */
65 a=[];
66 try
67 {
68 for (var i=0; i<10; i++)
69 {
70 a[a.length] = a.toSource();
71 }
72 }
73 catch(e)
74 {
75 }
76
77 reportCompare('No Crash', 'No Crash', '');