OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 }; | 104 }; |
105 | 105 |
106 function testDefaultCustomError() { | 106 function testDefaultCustomError() { |
107 throw new CustomError("hep-hey", undefined); | 107 throw new CustomError("hep-hey", undefined); |
108 } | 108 } |
109 | 109 |
110 function testStrippedCustomError() { | 110 function testStrippedCustomError() { |
111 throw new CustomError("hep-hey", CustomError); | 111 throw new CustomError("hep-hey", CustomError); |
112 } | 112 } |
113 | 113 |
| 114 MyObj = function() { FAIL; } |
| 115 |
| 116 MyObjCreator = function() {} |
| 117 |
| 118 MyObjCreator.prototype.Create = function() { |
| 119 return new MyObj(); |
| 120 } |
| 121 |
| 122 function testClassNames() { |
| 123 (new MyObjCreator).Create(); |
| 124 } |
| 125 |
114 // Utility function for testing that the expected strings occur | 126 // Utility function for testing that the expected strings occur |
115 // in the stack trace produced when running the given function. | 127 // in the stack trace produced when running the given function. |
116 function testTrace(name, fun, expected, unexpected) { | 128 function testTrace(name, fun, expected, unexpected) { |
117 var threw = false; | 129 var threw = false; |
118 try { | 130 try { |
119 fun(); | 131 fun(); |
120 } catch (e) { | 132 } catch (e) { |
121 for (var i = 0; i < expected.length; i++) { | 133 for (var i = 0; i < expected.length; i++) { |
122 assertTrue(e.stack.indexOf(expected[i]) != -1, | 134 assertTrue(e.stack.indexOf(expected[i]) != -1, |
123 name + " doesn't contain expected[" + i + "] stack = " + e.stac
k); | 135 name + " doesn't contain expected[" + i + "] stack = " + e.stac
k); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 " at Outer (res://outer-eval:1:37)"]); | 259 " at Outer (res://outer-eval:1:37)"]); |
248 testTrace("testValue", testValue, ["at Number.causeError"]); | 260 testTrace("testValue", testValue, ["at Number.causeError"]); |
249 testTrace("testConstructor", testConstructor, ["new Plonk"]); | 261 testTrace("testConstructor", testConstructor, ["new Plonk"]); |
250 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); | 262 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); |
251 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); | 263 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); |
252 testTrace("testDefaultCustomError", testDefaultCustomError, | 264 testTrace("testDefaultCustomError", testDefaultCustomError, |
253 ["hep-hey", "new CustomError"], | 265 ["hep-hey", "new CustomError"], |
254 ["collectStackTrace"]); | 266 ["collectStackTrace"]); |
255 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], | 267 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], |
256 ["new CustomError", "collectStackTrace"]); | 268 ["new CustomError", "collectStackTrace"]); |
| 269 testTrace("testClassNames", testClassNames, |
| 270 ["new MyObj", "MyObjCreator.Create"]); |
257 testCallerCensorship(); | 271 testCallerCensorship(); |
258 testUnintendedCallerCensorship(); | 272 testUnintendedCallerCensorship(); |
259 testErrorsDuringFormatting(); | 273 testErrorsDuringFormatting(); |
260 | 274 |
261 testTraceNativeConversion(String); // Does ToString on argument. | 275 testTraceNativeConversion(String); // Does ToString on argument. |
262 testTraceNativeConversion(Number); // Does ToNumber on argument. | 276 testTraceNativeConversion(Number); // Does ToNumber on argument. |
263 testTraceNativeConversion(RegExp); // Does ToString on argument. | 277 testTraceNativeConversion(RegExp); // Does ToString on argument. |
264 | 278 |
265 testTraceNativeConstructor(String); // Does ToString on argument. | 279 testTraceNativeConstructor(String); // Does ToString on argument. |
266 testTraceNativeConstructor(Number); // Does ToNumber on argument. | 280 testTraceNativeConstructor(Number); // Does ToNumber on argument. |
267 testTraceNativeConstructor(RegExp); // Does ToString on argument. | 281 testTraceNativeConstructor(RegExp); // Does ToString on argument. |
268 testTraceNativeConstructor(Date); // Does ToNumber on argument. | 282 testTraceNativeConstructor(Date); // Does ToNumber on argument. |
269 | 283 |
270 // Omitted because QuickSort has builtins object as receiver, and is non-native | 284 // Omitted because QuickSort has builtins object as receiver, and is non-native |
271 // builtin. | 285 // builtin. |
272 testOmittedBuiltin(function(){ [thrower, 2].sort(function (a,b) { | 286 testOmittedBuiltin(function(){ [thrower, 2].sort(function (a,b) { |
273 (b < a) - (a < b); }); | 287 (b < a) - (a < b); }); |
274 }, "QuickSort"); | 288 }, "QuickSort"); |
275 | 289 |
276 // Omitted because ADD from runtime.js is non-native builtin. | 290 // Omitted because ADD from runtime.js is non-native builtin. |
277 testOmittedBuiltin(function(){ thrower + 2; }, "ADD"); | 291 testOmittedBuiltin(function(){ thrower + 2; }, "ADD"); |
OLD | NEW |