]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_4/Regress/function-002.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 * File Name: function-002.js
26 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=330462
27 * js> function f(a){var a,b;}
29 * causes an an assert on a null 'sprop' in the 'Variables' function in
30 * jsparse.c This will crash non-debug build.
32 * Author: christine@netscape.com
33 * Date: 11 August 1998
34 * REVISED: 04 February 2001
35 * (changed the comma expressions from trivial to non-trivial)
36 * Author: pschwartau@netscape.com
38 * Brendan: "The test seemed to require something that ECMA does not
39 * guarantee, and that JS1.4 didn't either. For example, given
41 * dec2 = "function f2(){1,2}";
43 * the engine is free to decompile a function object compiled from this source,
44 * via Function.prototype.toString(), into some other string that compiles to
45 * an equivalent function. The engine now eliminates the useless comma expression
46 * 1,2, giving function f2(){}. This should be legal by the testsuite's lights."
49 var SECTION
= "function-002.js";
50 var VERSION
= "JS1_4";
51 var TITLE
= "Regression test case for 325843";
52 var BUGNUMBER
="330462";
56 writeHeaderToLog( SECTION
+ " "+ TITLE
);
58 var testcases
= new Array();
60 dec1
= "function f1(x,y){++x, --y}";
61 dec2
= "function f2(){var y; f1(1,2); y=new Date(); print(y.toString())}";
66 testcases
[tc
++] = new TestCase(
73 // force a function decompilation
74 testcases
[tc
++] = new TestCase(
76 "f1.toString() == dec1",
78 StripSpaces(f1
.toString()) == StripSpaces(dec1
));
80 testcases
[tc
++] = new TestCase(
86 // force a function decompilation
88 testcases
[tc
++] = new TestCase(
90 "f2.toString() == dec2",
92 StripSpaces(f2
.toString()) == StripSpaces(dec2
));
96 function StripSpaces( s
) {
97 var strippedString
= "";
98 for ( var currentChar
= 0; currentChar
< s
.length
; currentChar
++ ) {
99 if (!IsWhiteSpace(s
.charAt(currentChar
))) {
100 strippedString
+= s
.charAt(currentChar
);
103 return strippedString
;
106 function IsWhiteSpace( string
) {
107 var cc
= string
.charCodeAt(0);
116 case ( 59 ): // let's strip out semicolons, too