]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_5/Object/regress-96284-002.js
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
19 * Contributor(s): pschwartau@netscape.com
20 * Date: 03 September 2001
22 * SUMMARY: Double quotes should be escaped in uneval(new Error('""'))
23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=96284
25 * The real point here is this: we should be able to reconstruct an object
26 * obj from uneval(obj). We'll test this on various types of objects.
28 * Method: define obj2 = eval(uneval(obj1)) and verify that
29 * obj2.toSource() == obj1.toSource().
31 //-----------------------------------------------------------------------------
34 var summary
= 'Double quotes should be escaped in Error.prototype.toSource()';
38 var actualvalues
= [];
40 var expectedvalues
= [];
43 var cnTestString
= '"This is a \" STUPID \" test string!!!"\\';
46 // various NativeError objects -
47 status
= inSection(1);
48 obj1
= Error(cnTestString
);
49 obj2
= eval(uneval(obj1
));
50 actual
= obj2
.toSource();
51 expect
= obj1
.toSource();
54 status
= inSection(2);
55 obj1
= EvalError(cnTestString
);
56 obj2
= eval(uneval(obj1
));
57 actual
= obj2
.toSource();
58 expect
= obj1
.toSource();
61 status
= inSection(3);
62 obj1
= RangeError(cnTestString
);
63 obj2
= eval(uneval(obj1
));
64 actual
= obj2
.toSource();
65 expect
= obj1
.toSource();
68 status
= inSection(4);
69 obj1
= ReferenceError(cnTestString
);
70 obj2
= eval(uneval(obj1
));
71 actual
= obj2
.toSource();
72 expect
= obj1
.toSource();
75 status
= inSection(5);
76 obj1
= SyntaxError(cnTestString
);
77 obj2
= eval(uneval(obj1
));
78 actual
= obj2
.toSource();
79 expect
= obj1
.toSource();
82 status
= inSection(6);
83 obj1
= TypeError(cnTestString
);
84 obj2
= eval(uneval(obj1
));
85 actual
= obj2
.toSource();
86 expect
= obj1
.toSource();
89 status
= inSection(7);
90 obj1
= URIError(cnTestString
);
91 obj2
= eval(uneval(obj1
));
92 actual
= obj2
.toSource();
93 expect
= obj1
.toSource();
97 // other types of objects -
98 status
= inSection(8);
99 obj1
= new String(cnTestString
);
100 obj2
= eval(uneval(obj1
));
101 actual
= obj2
.toSource();
102 expect
= obj1
.toSource();
105 status
= inSection(9);
106 obj1
= {color:'red', texture:cnTestString
, hasOwnProperty:42};
107 obj2
= eval(uneval(obj1
));
108 actual
= obj2
.toSource();
109 expect
= obj1
.toSource();
112 status
= inSection(10);
113 obj1 = function(x
) {function g(y
){return y
+1;} return g(x
);};
114 obj2
= eval(uneval(obj1
));
115 actual
= obj2
.toSource();
116 expect
= obj1
.toSource();
119 status
= inSection(11);
120 obj1
= new Number(eval('6'));
121 obj2
= eval(uneval(obj1
));
122 actual
= obj2
.toSource();
123 expect
= obj1
.toSource();
126 status
= inSection(12);
127 obj1
= /ad;(lf)kj(2309\/\/)\/\//;
128 obj2
= eval(uneval(obj1
));
129 actual
= obj2
.toSource();
130 expect
= obj1
.toSource();
135 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------
142 statusitems
[UBound
] = status
;
143 actualvalues
[UBound
] = actual
;
144 expectedvalues
[UBound
] = expect
;
152 printBugNumber (bug
);
153 printStatus (summary
);
155 for (var i
= 0; i
< UBound
; i
++)
157 reportCompare(expectedvalues
[i
], actualvalues
[i
], statusitems
[i
]);