Bug 458113. Fix syntax error that broke OS/2 build. r+wuno
[wine-gecko.git] / js / tests / js1_5 / extensions / regress-96284-001.js
blob1a78f49a12cf3ac8d1149165c973aa341a2340b5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * pschwartau@netscape.com
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
40 * Date: 03 September 2001
42 * SUMMARY: Double quotes should be escaped in Error.prototype.toSource()
43 * See http://bugzilla.mozilla.org/show_bug.cgi?id=96284
45 * The real point here is this: we should be able to reconstruct an object
46 * from its toSource() property. We'll test this on various types of objects.
48 * Method: define obj2 = eval(obj1.toSource()) and verify that
49 * obj2.toSource() == obj1.toSource().
51 //-----------------------------------------------------------------------------
52 var gTestfile = 'regress-96284-001.js';
53 var UBound = 0;
54 var BUGNUMBER = 96284;
55 var summary = 'Double quotes should be escaped in Error.prototype.toSource()';
56 var status = '';
57 var statusitems = [];
58 var actual = '';
59 var actualvalues = [];
60 var expect= '';
61 var expectedvalues = [];
62 var obj1 = {};
63 var obj2 = {};
64 var cnTestString = '"This is a \" STUPID \" test string!!!"\\';
67 // various NativeError objects -
68 status = inSection(1);
69 obj1 = Error(cnTestString);
70 obj2 = eval(obj1.toSource());
71 actual = obj2.toSource();
72 expect = obj1.toSource();
73 addThis();
75 status = inSection(2);
76 obj1 = EvalError(cnTestString);
77 obj2 = eval(obj1.toSource());
78 actual = obj2.toSource();
79 expect = obj1.toSource();
80 addThis();
82 status = inSection(3);
83 obj1 = RangeError(cnTestString);
84 obj2 = eval(obj1.toSource());
85 actual = obj2.toSource();
86 expect = obj1.toSource();
87 addThis();
89 status = inSection(4);
90 obj1 = ReferenceError(cnTestString);
91 obj2 = eval(obj1.toSource());
92 actual = obj2.toSource();
93 expect = obj1.toSource();
94 addThis();
96 status = inSection(5);
97 obj1 = SyntaxError(cnTestString);
98 obj2 = eval(obj1.toSource());
99 actual = obj2.toSource();
100 expect = obj1.toSource();
101 addThis();
103 status = inSection(6);
104 obj1 = TypeError(cnTestString);
105 obj2 = eval(obj1.toSource());
106 actual = obj2.toSource();
107 expect = obj1.toSource();
108 addThis();
110 status = inSection(7);
111 obj1 = URIError(cnTestString);
112 obj2 = eval(obj1.toSource());
113 actual = obj2.toSource();
114 expect = obj1.toSource();
115 addThis();
118 // other types of objects -
119 status = inSection(8);
120 obj1 = new String(cnTestString);
121 obj2 = eval(obj1.toSource());
122 actual = obj2.toSource();
123 expect = obj1.toSource();
124 addThis();
126 status = inSection(9);
127 obj1 = {color:'red', texture:cnTestString, hasOwnProperty:42};
128 obj2 = eval(obj1.toSource());
129 actual = obj2.toSource();
130 expect = obj1.toSource();
131 addThis();
133 status = inSection(10);
134 obj1 = function(x) {function g(y){return y+1;} return g(x);};
135 obj2 = eval(obj1.toSource());
136 actual = obj2.toSource();
137 expect = obj1.toSource();
138 addThis();
140 status = inSection(11);
141 obj1 = new Number(eval('6'));
142 obj2 = eval(obj1.toSource());
143 actual = obj2.toSource();
144 expect = obj1.toSource();
145 addThis();
147 status = inSection(12);
148 obj1 = /ad;(lf)kj(2309\/\/)\/\//;
149 obj2 = eval(obj1.toSource());
150 actual = obj2.toSource();
151 expect = obj1.toSource();
152 addThis();
156 //-----------------------------------------------------------------------------
157 test();
158 //-----------------------------------------------------------------------------
161 function addThis()
163 statusitems[UBound] = status;
164 actualvalues[UBound] = actual;
165 expectedvalues[UBound] = expect;
166 UBound++;
170 function test()
172 enterFunc ('test');
173 printBugNumber(BUGNUMBER);
174 printStatus (summary);
176 for (var i = 0; i < UBound; i++)
178 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
181 exitFunc ('test');