Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-290575.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 var gTestfile = 'regress-290575.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 290575;
9 var summary = 'Do not crash calling function with more than 32768 arguments';
10 var actual = 'No Crash';
11 var expect = 'No Crash';
12 printBugNumber(BUGNUMBER);
13 printStatus (summary);
14
15 function crashMe(n) {
16 var nasty, fn;
17
18 nasty = [];
19 while (n--)
20 nasty.push("a"+n); // Function arguments
21 nasty.push("void 0"); // Function body
22 fn = Function.apply(null, nasty);
23 fn.toString();
24 }
25
26 printStatus('crashMe(0x8001)');
27
28 crashMe(0x8001);
29
30 reportCompare(expect, actual, summary);
31
32 function crashMe2(n) {
33 var nasty = [], fn
34
35 while (n--) nasty[n] = "a"+n
36 fn = Function(nasty.join(), "void 0")
37 fn.toString()
38 }
39
40 printStatus('crashMe2(0x10000)');
41
42 summary = 'Syntax Error Function to string when more than 65536 arguments';
43 expect = 'Error';
44 try
45 {
46 crashMe2(0x10000);
47 actual = 'No Error';
48 reportCompare(expect, actual, summary);
49 }
50 catch(e)
51 {
52 actual = 'Error';
53 reportCompare(expect, actual, summary);
54 expect = 'SyntaxError';
55 actual = e.name;
56 reportCompare(expect, actual, summary);
57 }
58