Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(655)

Unified Diff: test/mjsunit/stack-traces.js

Issue 919653002: [V8] Use Function.name in Error.stack (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/stack-traces.js
diff --git a/test/mjsunit/stack-traces.js b/test/mjsunit/stack-traces.js
index f80a627b24a87eae9fe00e5bd0a24c5b7f5af903..b256033b537233752dae87bdb71fadd153322a23 100644
--- a/test/mjsunit/stack-traces.js
+++ b/test/mjsunit/stack-traces.js
@@ -94,6 +94,37 @@ function testAnonymousMethod() {
(function () { FAIL }).call([1, 2, 3]);
}
+function testFunctionName() {
+ function gen(name, counter) {
+ var f = function foo() {
+ if (counter === 0) {
+ FAIL;
+ }
+ gen(name, counter - 1)();
+ }
+ if (counter === 4) {
+ Object.defineProperty(f, 'name', {get: function(){ throw 239; }});
+ } else if (counter == 3) {
+ Object.defineProperty(f, 'name', {value: 'boo' + '_' + counter});
+ } else {
+ Object.defineProperty(f, 'name', {writable: true});
+ if (counter === 2)
+ f.name = 42;
+ else
+ f.name = name + '_' + counter;
+ }
+ return f;
+ }
+ gen('foo', 4)();
+}
+
+function testFunctionInferredName() {
+ var f = function() {
+ FAIL;
+ }
+ f();
+}
+
function CustomError(message, stripPoint) {
this.message = message;
Error.captureStackTrace(this, stripPoint);
@@ -261,6 +292,9 @@ testTrace("testValue", testValue, ["at Number.causeError"]);
testTrace("testConstructor", testConstructor, ["new Plonk"]);
testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]);
testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]);
+testTrace("testFunctionName", testFunctionName,
+ [" at foo_0 ", " at foo_1", " at foo ", " at boo_3 ", " at foo "]);
+testTrace("testFunctionInferredName", testFunctionInferredName, [" at f "]);
testTrace("testDefaultCustomError", testDefaultCustomError,
["hep-hey", "new CustomError"],
["collectStackTrace"]);
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698