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

Side by Side Diff: test/mjsunit/stack-traces.js

Issue 3444011: Use //@ sourceURL when formatting stack trace (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 function testEval() { 57 function testEval() {
58 eval("function Doo() { FAIL; }; Doo();"); 58 eval("function Doo() { FAIL; }; Doo();");
59 } 59 }
60 60
61 function testNestedEval() { 61 function testNestedEval() {
62 var x = "FAIL"; 62 var x = "FAIL";
63 eval("function Outer() { eval('function Inner() { eval(x); }'); Inner(); }; Ou ter();"); 63 eval("function Outer() { eval('function Inner() { eval(x); }'); Inner(); }; Ou ter();");
64 } 64 }
65 65
66 function testEvalWithSourceURL() {
67 eval("function Doo() { FAIL; }; Doo();\n//@ sourceURL=res://name");
68 }
69
70 function testNestedEvalWithSourceURL() {
71 var x = "FAIL";
72 var innerEval = 'function Inner() { eval(x); }\n//@ sourceURL=res://inner-eval ';
73 eval("function Outer() { eval(innerEval); Inner(); }; Outer();\n//@ sourceURL= res://outer-eval");
74 }
75
66 function testValue() { 76 function testValue() {
67 Number.prototype.causeError = function () { FAIL; }; 77 Number.prototype.causeError = function () { FAIL; };
68 (1).causeError(); 78 (1).causeError();
69 } 79 }
70 80
71 function testConstructor() { 81 function testConstructor() {
72 function Plonk() { FAIL; } 82 function Plonk() { FAIL; }
73 new Plonk(); 83 new Plonk();
74 } 84 }
75 85
(...skipping 27 matching lines...) Expand all
103 113
104 // Utility function for testing that the expected strings occur 114 // Utility function for testing that the expected strings occur
105 // in the stack trace produced when running the given function. 115 // in the stack trace produced when running the given function.
106 function testTrace(name, fun, expected, unexpected) { 116 function testTrace(name, fun, expected, unexpected) {
107 var threw = false; 117 var threw = false;
108 try { 118 try {
109 fun(); 119 fun();
110 } catch (e) { 120 } catch (e) {
111 for (var i = 0; i < expected.length; i++) { 121 for (var i = 0; i < expected.length; i++) {
112 assertTrue(e.stack.indexOf(expected[i]) != -1, 122 assertTrue(e.stack.indexOf(expected[i]) != -1,
113 name + " doesn't contain expected[" + i + "]"); 123 name + " doesn't contain expected[" + i + "] stack = " + e.stac k);
114 } 124 }
115 if (unexpected) { 125 if (unexpected) {
116 for (var i = 0; i < unexpected.length; i++) { 126 for (var i = 0; i < unexpected.length; i++) {
117 assertEquals(e.stack.indexOf(unexpected[i]), -1, 127 assertEquals(e.stack.indexOf(unexpected[i]), -1,
118 name + " contains unexpected[" + i + "]"); 128 name + " contains unexpected[" + i + "]");
119 } 129 }
120 } 130 }
121 threw = true; 131 threw = true;
122 } 132 }
123 assertTrue(threw, name + " didn't throw"); 133 assertTrue(threw, name + " didn't throw");
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 assertTrue(threw, "ErrorsDuringFormatting didnt' throw (2)"); 193 assertTrue(threw, "ErrorsDuringFormatting didnt' throw (2)");
184 } 194 }
185 195
186 196
187 testTrace("testArrayNative", testArrayNative, ["Array.map (native)"]); 197 testTrace("testArrayNative", testArrayNative, ["Array.map (native)"]);
188 testTrace("testNested", testNested, ["at one", "at two", "at three"]); 198 testTrace("testNested", testNested, ["at one", "at two", "at three"]);
189 testTrace("testMethodNameInference", testMethodNameInference, ["at Foo.bar"]); 199 testTrace("testMethodNameInference", testMethodNameInference, ["at Foo.bar"]);
190 testTrace("testImplicitConversion", testImplicitConversion, ["at Nirk.valueOf"]) ; 200 testTrace("testImplicitConversion", testImplicitConversion, ["at Nirk.valueOf"]) ;
191 testTrace("testEval", testEval, ["at Doo (eval at testEval"]); 201 testTrace("testEval", testEval, ["at Doo (eval at testEval"]);
192 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]); 202 testTrace("testNestedEval", testNestedEval, ["eval at Inner (eval at Outer"]);
203 testTrace("testEvalWithSourceURL", testEvalWithSourceURL,
204 [ "at Doo (res://name:1:18)" ]);
205 testTrace("testNestedEvalWithSourceURL", testNestedEvalWithSourceURL,
206 [" at Inner (res://inner-eval:1:20)",
207 " at Outer (res://outer-eval:1:37)"]);
193 testTrace("testValue", testValue, ["at Number.causeError"]); 208 testTrace("testValue", testValue, ["at Number.causeError"]);
194 testTrace("testConstructor", testConstructor, ["new Plonk"]); 209 testTrace("testConstructor", testConstructor, ["new Plonk"]);
195 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]); 210 testTrace("testRenamedMethod", testRenamedMethod, ["Wookie.a$b$c$d [as d]"]);
196 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]); 211 testTrace("testAnonymousMethod", testAnonymousMethod, ["Array.<anonymous>"]);
197 testTrace("testDefaultCustomError", testDefaultCustomError, 212 testTrace("testDefaultCustomError", testDefaultCustomError,
198 ["hep-hey", "new CustomError"], 213 ["hep-hey", "new CustomError"],
199 ["collectStackTrace"]); 214 ["collectStackTrace"]);
200 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], 215 testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"],
201 ["new CustomError", "collectStackTrace"]); 216 ["new CustomError", "collectStackTrace"]);
202 testCallerCensorship(); 217 testCallerCensorship();
203 testUnintendedCallerCensorship(); 218 testUnintendedCallerCensorship();
204 testErrorsDuringFormatting(); 219 testErrorsDuringFormatting();
OLDNEW
« no previous file with comments | « src/messages.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698