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

Side by Side Diff: test/mjsunit/debug-backtrace-text.js

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 years 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 | « test/mjsunit/debug-backtrace.js ('k') | test/mjsunit/debug-breakpoints.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --expose-debug-as debug 28 // Flags: --expose-debug-as debug
29 29
30 // The functions used for testing backtraces. 30 // The functions used for testing backtraces.
31 function Point(x, y) { 31 function Point(x, y) {
32 this.x = x; 32 this.x = x;
33 this.y = y; 33 this.y = y;
34 }; 34 }
35 35
36 Point.prototype.distanceTo = function(p) { 36 Point.prototype.distanceTo = function(p) {
37 debugger; 37 debugger;
38 return Math.sqrt(Math.pow(Math.abs(this.x - p.x), 2) + Math.pow(Math.abs(this. y - p.y), 2)) 38 return Math.sqrt(Math.pow(Math.abs(this.x - p.x), 2) +
39 } 39 Math.pow(Math.abs(this.y - p.y), 2));
40 };
40 41
41 p1 = new Point(1,1); 42 p1 = new Point(1,1);
42 p2 = new Point(2,2); 43 p2 = new Point(2,2);
43 44
44 p1.distanceTo = function(p) { 45 p1.distanceTo = function(p) {
45 return p.distanceTo(this); 46 return p.distanceTo(this);
46 } 47 };
47 48
48 function distance(p, q) { 49 function distance(p, q) {
49 return p.distanceTo(q); 50 return p.distanceTo(q);
50 } 51 }
51 52
52 function createPoint(x, y) { 53 function createPoint(x, y) {
53 return new Point(x, y); 54 return new Point(x, y);
54 } 55 }
55 56
56 a=[1,2,distance]; 57 a=[1,2,distance];
57 58
58 // Get the Debug object exposed from the debug context global object. 59 // Get the Debug object exposed from the debug context global object.
59 Debug = debug.Debug 60 Debug = debug.Debug;
60 61
61 testConstructor = false; // Flag to control which part of the test is run. 62 testConstructor = false; // Flag to control which part of the test is run.
62 listenerCalled = false; 63 listenerCalled = false;
63 exception = false; 64 exception = false;
64 65
65 function safeEval(code) { 66 function safeEval(code) {
66 try { 67 try {
67 return eval('(' + code + ')'); 68 return eval('(' + code + ')');
68 } catch (e) { 69 } catch (e) {
69 return undefined; 70 return undefined;
70 } 71 }
71 } 72 }
72 73
73 function listener(event, exec_state, event_data, data) { 74 function listener(event, exec_state, event_data, data) {
74 try { 75 try {
75 if (event == Debug.DebugEvent.Break) 76 if (event == Debug.DebugEvent.Break) {
76 { 77 if (!testConstructor) {
77 if (!testConstructor) { 78 // The expected backtrace is
78 // The expected backtrace is 79 // 0: Call distance on Point where distance is a property on the prototy pe
79 // 0: Call distance on Point where distance is a property on the prototype 80 // 1: Call distance on Point where distance is a direct property
80 // 1: Call distance on Point where distance is a direct property 81 // 2: Call on function an array element 2
81 // 2: Call on function an array element 2 82 // 3: [anonymous]
82 // 3: [anonymous] 83 assertEquals("#<Point>.distanceTo(p=#<Point>)",
83 assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(0).invoca tionText()); 84 exec_state.frame(0).invocationText());
84 assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(1).invoca tionText()); 85 assertEquals("#<Point>.distanceTo(p=#<Point>)",
85 assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)", exec_sta te.frame(2).invocationText()); 86 exec_state.frame(1).invocationText());
86 assertEquals("[anonymous]()", exec_state.frame(3).invocationText()); 87 assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)",
87 listenerCalled = true; 88 exec_state.frame(2).invocationText());
88 } else { 89 assertEquals("[anonymous]()", exec_state.frame(3).invocationText());
89 // The expected backtrace is 90 listenerCalled = true;
90 // 0: Call Point constructor 91 } else {
91 // 1: Call on global function createPoint 92 // The expected backtrace is
92 // 2: [anonymous] 93 // 0: Call Point constructor
93 assertEquals("new Point(x=0, y=0)", exec_state.frame(0).invocationText()); 94 // 1: Call on global function createPoint
94 assertEquals("createPoint(x=0, y=0)", exec_state.frame(1).invocationText() ); 95 // 2: [anonymous]
95 assertEquals("[anonymous]()", exec_state.frame(2).invocationText()); 96 assertEquals("new Point(x=0, y=0)",
96 listenerCalled = true; 97 exec_state.frame(0).invocationText());
98 assertEquals("createPoint(x=0, y=0)",
99 exec_state.frame(1).invocationText());
100 assertEquals("[anonymous]()", exec_state.frame(2).invocationText());
101 listenerCalled = true;
102 }
97 } 103 }
104 } catch (e) {
105 exception = e;
98 } 106 }
99 } catch (e) { 107 }
100 exception = e
101 };
102 };
103 108
104 // Add the debug event listener. 109 // Add the debug event listener.
105 Debug.setListener(listener); 110 Debug.setListener(listener);
106 111
107 // Set a break point and call to invoke the debug event listener. 112 // Set a break point and call to invoke the debug event listener.
108 a[2](p1, p2) 113 a[2](p1, p2);
109 114
110 // Make sure that the debug event listener vas invoked. 115 // Make sure that the debug event listener vas invoked.
111 assertTrue(listenerCalled); 116 assertTrue(listenerCalled);
112 assertFalse(exception, "exception in listener") 117 assertFalse(exception, "exception in listener");
113 118
114 // Set a break point and call to invoke the debug event listener. 119 // Set a break point and call to invoke the debug event listener.
115 listenerCalled = false; 120 listenerCalled = false;
116 testConstructor = true; 121 testConstructor = true;
117 Debug.setBreakPoint(Point, 0, 0); 122 Debug.setBreakPoint(Point, 0, 0);
118 createPoint(0, 0); 123 createPoint(0, 0);
119 124
120 // Make sure that the debug event listener vas invoked (again). 125 // Make sure that the debug event listener vas invoked (again).
121 assertTrue(listenerCalled); 126 assertTrue(listenerCalled);
122 assertFalse(exception, "exception in listener") 127 assertFalse(exception, "exception in listener");
OLDNEW
« no previous file with comments | « test/mjsunit/debug-backtrace.js ('k') | test/mjsunit/debug-breakpoints.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698