]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_5/Regress/regress-118849.js
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Netscape Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/NPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is JavaScript Engine testing utilities.
16 * The Initial Developer of the Original Code is Netscape Communications Corp.
17 * Portions created by the Initial Developer are Copyright (C) 2001
18 * the Initial Developer. All Rights Reserved.
20 * Contributor(s): pschwartau@netscape.com
22 * Alternatively, the contents of this file may be used under the terms of
23 * either the GNU General Public License Version 2 or later (the "GPL"), or
24 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25 * in which case the provisions of the GPL or the LGPL are applicable instead
26 * of those above. If you wish to allow use of your version of this file only
27 * under the terms of either the GPL or the LGPL, and not to allow others to
28 * use your version of this file under the terms of the NPL, indicate your
29 * decision by deleting the provisions above and replace them with the notice
30 * and other provisions required by the GPL or the LGPL. If you do not delete
31 * the provisions above, a recipient may use your version of this file under
32 * the terms of any one of the NPL, the GPL or the LGPL.
34 * ***** END LICENSE BLOCK *****
38 * SUMMARY: Just testing that we don't crash on this code
39 * See http://bugzilla.mozilla.org/show_bug.cgi?id=118849
41 * http://developer.netscape.com:80/docs/manuals/js/core/jsref/function.htm
42 * The Function constructor:
43 * Function ([arg1[, arg2[, ... argN]],] functionBody)
46 * arg1, arg2, ... argN
47 * (Optional) Names to be used by the function as formal argument names.
48 * Each must be a string that corresponds to a valid JavaScript identifier.
51 * A string containing JS statements comprising the function definition.
53 //-----------------------------------------------------------------------------
56 var summary
= 'Should not crash if we provide Function() with bad arguments'
60 var actualvalues
= [];
62 var expectedvalues
= [];
63 var cnFAIL_1
= 'LEGAL call to Function() caused an ERROR!!!';
64 var cnFAIL_2
= 'ILLEGAL call to Function() FAILED to cause an error';
65 var cnSTRING
= 'ASDF';
69 /***********************************************************/
70 /**** THESE ARE LEGITMATE CALLS AND SHOULD ALL SUCCEED ***/
71 /***********************************************************/
72 status
= inSection(1);
73 actual
= cnFAIL_1
; // initialize to failure
77 Function(cnNUMBER
); // cnNUMBER is a valid functionBody
78 Function(cnSTRING
,cnSTRING
);
79 Function(cnSTRING
,cnNUMBER
);
80 Function(cnSTRING
,cnSTRING
,cnNUMBER
);
82 new Function(cnSTRING
);
83 new Function(cnNUMBER
);
84 new Function(cnSTRING
,cnSTRING
);
85 new Function(cnSTRING
,cnNUMBER
);
86 new Function(cnSTRING
,cnSTRING
,cnNUMBER
);
97 /**********************************************************/
98 /*** EACH CASE THAT FOLLOWS SHOULD TRIGGER AN ERROR ***/
99 /*** (BUT NOT A CRASH) ***/
100 /*** NOTE WE NOW USE cnFAIL_2 INSTEAD OF cnFAIL_1 ***/
101 /**********************************************************/
102 status
= inSection(2);
106 Function(cnNUMBER
,cnNUMBER
); // cnNUMBER is an invalid JS identifier name
115 status
= inSection(3);
119 Function(cnNUMBER
,cnSTRING
,cnSTRING
);
128 status
= inSection(4);
132 new Function(cnNUMBER
,cnNUMBER
);
141 status
= inSection(5);
145 new Function(cnNUMBER
,cnSTRING
,cnSTRING
);
155 //-----------------------------------------------------------------------------
157 //-----------------------------------------------------------------------------
162 statusitems
[UBound
] = status
;
163 actualvalues
[UBound
] = actual
;
164 expectedvalues
[UBound
] = expect
;
172 printBugNumber (bug
);
173 printStatus (summary
);
175 for (var i
= 0; i
< UBound
; i
++)
177 reportCompare(expectedvalues
[i
], actualvalues
[i
], statusitems
[i
]);