]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_5/Regress/regress-168347.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) 2002
18 * the Initial Developer. All Rights Reserved.
20 * Contributor(s): desale@netscape.com, 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: Testing F.toString()
39 * See http://bugzilla.mozilla.org/show_bug.cgi?id=168347
42 //-----------------------------------------------------------------------------
45 var summary
= "Testing F.toString()";
49 var actualvalues
= [];
51 var expectedvalues
= [];
55 sFunc
+= 'function F()';
57 sFunc
+= ' var f = arguments.callee;';
62 sFunc
+= ' f.i = f.i + 1;';
63 sFunc
+= ' print("i = i+1 succeeded \ti = " + f.i);';
67 sFunc
+= ' print("i = i+1 failed with " + e + "\ti = " + f.i);';
73 sFunc
+= ' print("++i succeeded \t\ti = " + f.i);';
77 sFunc
+= ' print("++i failed with " + e + "\ti = " + f.i);';
83 sFunc
+= ' print("i++ succeeded \t\ti = " + f.i);';
87 sFunc
+= ' print("i++ failed with " + e + "\ti = " + f.i);';
93 sFunc
+= ' print("--i succeeded \t\ti = " + f.i);';
97 sFunc
+= ' print("--i failed with " + e + "\ti = " + f.i);';
103 sFunc
+= ' print("i-- succeeded \t\ti = " + f.i);';
105 sFunc
+= ' catch(e)';
107 sFunc
+= ' print("i-- failed with " + e + "\ti = " + f.i);';
113 * Use sFunc to define the function F. The test
114 * then rests on comparing F.toString() to sFunc.
120 * There are trivial whitespace differences between F.toString()
121 * and sFunc. So strip out whitespace before comparing them -
123 sFunc
= stripWhite(sFunc
);
124 FtoString
= stripWhite(F
.toString());
128 * Break comparison into sections to make any failures
129 * easier for the developer to track down -
131 status
= inSection(1);
132 actual
= FtoString
.substring(0,100);
133 expect
= sFunc
.substring(0,100);
136 status
= inSection(2);
137 actual
= FtoString
.substring(100,200);
138 expect
= sFunc
.substring(100,200);
141 status
= inSection(3);
142 actual
= FtoString
.substring(200,300);
143 expect
= sFunc
.substring(200,300);
146 status
= inSection(4);
147 actual
= FtoString
.substring(300,400);
148 expect
= sFunc
.substring(300,400);
151 status
= inSection(5);
152 actual
= FtoString
.substring(400,500);
153 expect
= sFunc
.substring(400,500);
156 status
= inSection(6);
157 actual
= FtoString
.substring(500,600);
158 expect
= sFunc
.substring(500,600);
161 status
= inSection(7);
162 actual
= FtoString
.substring(600,700);
163 expect
= sFunc
.substring(600,700);
166 status
= inSection(8);
167 actual
= FtoString
.substring(700,800);
168 expect
= sFunc
.substring(700,800);
171 status
= inSection(9);
172 actual
= FtoString
.substring(800,900);
173 expect
= sFunc
.substring(800,900);
178 //-----------------------------------------------------------------------------
180 //-----------------------------------------------------------------------------
186 statusitems
[UBound
] = status
;
187 actualvalues
[UBound
] = actual
;
188 expectedvalues
[UBound
] = expect
;
193 * Remove any whitespace characters; also
194 * any escaped tabs or escaped newlines.
196 function stripWhite(str
)
198 var re
= /\s|\\t|\\n/g;
199 return str
.replace(re
, '');
207 printStatus(summary
);
209 for (var i
=0; i
<UBound
; i
++)
211 reportCompare(expectedvalues
[i
], actualvalues
[i
], statusitems
[i
]);