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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 try { | 245 try { |
246 nativeFunc(thrower); | 246 nativeFunc(thrower); |
247 assertUnreachable(nativeFuncName); | 247 assertUnreachable(nativeFuncName); |
248 } catch (e) { | 248 } catch (e) { |
249 assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName); | 249 assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 | 253 |
254 function testOmittedBuiltin(throwing, omitted) { | 254 function testOmittedBuiltin(throwing, omitted) { |
255 var reached = false; | |
255 try { | 256 try { |
256 throwing(); | 257 throwing(); |
257 assertUnreachable(omitted); | 258 reached = true; |
258 } catch (e) { | 259 } catch (e) { |
259 assertTrue(e.stack.indexOf(omitted) < 0, omitted); | 260 assertTrue(e.stack.indexOf(omitted) < 0, omitted); |
261 } finally { | |
262 assertFalse(reached); | |
260 } | 263 } |
261 } | 264 } |
262 | 265 |
263 | 266 |
264 testTrace("testArrayNative", testArrayNative, ["Array.map (native)"]); | 267 testTrace("testArrayNative", testArrayNative, ["Array.map (native)"]); |
265 testTrace("testNested", testNested, ["at one", "at two", "at three"]); | 268 testTrace("testNested", testNested, ["at one", "at two", "at three"]); |
266 testTrace("testMethodNameInference", testMethodNameInference, ["at Foo.bar"]); | 269 testTrace("testMethodNameInference", testMethodNameInference, ["at Foo.bar"]); |
267 testTrace("testImplicitConversion", testImplicitConversion, ["at Nirk.valueOf"]) ; | 270 testTrace("testImplicitConversion", testImplicitConversion, ["at Nirk.valueOf"]) ; |
268 testTrace("testEval", testEval, ["at Doo (eval at testEval"]); | 271 testTrace("testEval", testEval, ["at Doo (eval at testEval"]); |
269 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]); | 272 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]); |
(...skipping 28 matching lines...) Expand all Loading... | |
298 | 301 |
299 // Omitted because QuickSort has builtins object as receiver, and is non-native | 302 // Omitted because QuickSort has builtins object as receiver, and is non-native |
300 // builtin. | 303 // builtin. |
301 testOmittedBuiltin(function(){ [thrower, 2].sort(function (a,b) { | 304 testOmittedBuiltin(function(){ [thrower, 2].sort(function (a,b) { |
302 (b < a) - (a < b); }); | 305 (b < a) - (a < b); }); |
303 }, "QuickSort"); | 306 }, "QuickSort"); |
304 | 307 |
305 // Omitted because ADD from runtime.js is non-native builtin. | 308 // Omitted because ADD from runtime.js is non-native builtin. |
306 testOmittedBuiltin(function(){ thrower + 2; }, "ADD"); | 309 testOmittedBuiltin(function(){ thrower + 2; }, "ADD"); |
307 | 310 |
311 var reached = false; | |
308 var error = new Error(); | 312 var error = new Error(); |
309 error.toString = function() { assertUnreachable(); }; | 313 error.toString = function() { reached = true; }; |
310 error.stack; | 314 error.stack; |
315 assertFalse(reached); | |
311 | 316 |
317 reached = false; | |
312 error = new Error(); | 318 error = new Error(); |
313 error.name = { toString: function() { assertUnreachable(); }}; | 319 Array.prototype.push = function(x) { reached = true; }; |
jgruber
2016/08/03 16:20:27
This test was completely removed since the spec ac
| |
314 error.message = { toString: function() { assertUnreachable(); }}; | 320 Array.prototype.join = function(x) { reached = true; }; |
315 error.stack; | 321 error.stack; |
316 | 322 assertFalse(reached); |
317 error = new Error(); | |
318 Array.prototype.push = function(x) { assertUnreachable(); }; | |
319 Array.prototype.join = function(x) { assertUnreachable(); }; | |
320 error.stack; | |
321 | 323 |
322 var fired = false; | 324 var fired = false; |
323 error = new Error({ toString: function() { fired = true; } }); | 325 error = new Error({ toString: function() { fired = true; } }); |
324 assertTrue(fired); | 326 assertTrue(fired); |
325 error.stack; | 327 error.stack; |
326 assertTrue(fired); | 328 assertTrue(fired); |
327 | 329 |
328 // Check that throwing exception in a custom stack trace formatting function | 330 // Check that throwing exception in a custom stack trace formatting function |
329 // does not lead to recursion. | 331 // does not lead to recursion. |
330 Error.prepareStackTrace = function() { throw new Error("abc"); }; | 332 Error.prepareStackTrace = function() { throw new Error("abc"); }; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 assertTrue(err.stack.indexOf("prepareStackTrace") != -1); | 433 assertTrue(err.stack.indexOf("prepareStackTrace") != -1); |
432 | 434 |
433 // Check that the callsite constructor throws. | 435 // Check that the callsite constructor throws. |
434 | 436 |
435 Error.prepareStackTrace = (e,s) => s; | 437 Error.prepareStackTrace = (e,s) => s; |
436 var constructor = new Error().stack[0].constructor; | 438 var constructor = new Error().stack[0].constructor; |
437 | 439 |
438 assertThrows(() => constructor.call()); | 440 assertThrows(() => constructor.call()); |
439 assertThrows(() => constructor.call( | 441 assertThrows(() => constructor.call( |
440 null, {}, () => undefined, {valueOf() { return 0 }}, false)); | 442 null, {}, () => undefined, {valueOf() { return 0 }}, false)); |
OLD | NEW |