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

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

Issue 2497973002: [debug-wrapper] Further extend the debug wrapper (Closed)
Patch Set: Address comments Created 4 years, 1 month 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
« no previous file with comments | « test/mjsunit/compiler/osr-typing-debug-change.js ('k') | test/mjsunit/debug-break-native.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 // Flags: --expose-debug-as debug
29
30 // The functions used for testing backtraces.
31 function Point(x, y) {
32 this.x = x;
33 this.y = y;
34 };
35
36 Point.prototype.distanceTo = function(p) {
37 debugger;
38 return Math.sqrt(Math.pow(Math.abs(this.x - p.x), 2) +
39 Math.pow(Math.abs(this.y - p.y), 2))
40 }
41
42 p1 = new Point(1,1);
43 p2 = new Point(2,2);
44
45 p1.distanceTo = function(p) {
46 return p.distanceTo(this);
47 }
48
49 function distance(p, q) {
50 return p.distanceTo(q);
51 }
52
53 function createPoint(x, y) {
54 return new Point(x, y);
55 }
56
57 a=[1,2,distance];
58
59 // Get the Debug object exposed from the debug context global object.
60 Debug = debug.Debug
61
62 what = 'constructor'; // Flag to control which part of the test is run.
63 listenerCalled = false;
64 exception = false;
65
66 function safeEval(code) {
67 try {
68 return eval('(' + code + ')');
69 } catch (e) {
70 return undefined;
71 }
72 }
73
74 function listener(event, exec_state, event_data, data) {
75 try {
76 if (event == Debug.DebugEvent.Break) {
77 if (what == 'constructor') {
78 // The expected backtrace is
79 // 0: Call distance on Point where distance is a prototype property
80 // 1: Call distance on Point where distance is a direct property
81 // 2: Call on function an array element 2
82 // 3: [anonymous]
83 assertEquals("#<Point>.distanceTo(p=#<Point>)",
84 exec_state.frame(0).invocationText());
85 assertEquals("#<Point>.distanceTo(p=#<Point>)",
86 exec_state.frame(1).invocationText());
87 assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)",
88 exec_state.frame(2).invocationText());
89 assertEquals("[anonymous]()", exec_state.frame(3).invocationText());
90 listenerCalled = true;
91 } else if (what == 'breakpoint') {
92 // The expected backtrace is
93 // 0: Call Point constructor
94 // 1: Call on global function createPoint
95 // 2: [anonymous]
96 assertEquals("new Point(x=0, y=0)",
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 } else if (what == 'symbol') {
103 // The expected backtrace is
104 // 0: Call Point constructor
105 // 1: Call on symbol method
106 // 2: [anonymous]
107 assertEquals("new Point(x=0, y=0)",
108 exec_state.frame(0).invocationText());
109 assertEquals("#<Object>[Symbol(Das Symbol)](x=0, y=0)",
110 exec_state.frame(1).invocationText());
111 assertEquals("[anonymous]()", exec_state.frame(2).invocationText());
112 listenerCalled = true;
113 } else {
114 assertUnreachable();
115 }
116 }
117 } catch (e) {
118 exception = e
119 };
120 };
121
122 // Add the debug event listener.
123 Debug.setListener(listener);
124
125 // Set a break point and call to invoke the debug event listener.
126 a[2](p1, p2)
127
128 // Make sure that the debug event listener vas invoked.
129 assertTrue(listenerCalled);
130 assertFalse(exception, "exception in listener")
131
132 // Set a break point and call to invoke the debug event listener.
133 what = 'breakpoint';
134 listenerCalled = false;
135 Debug.setBreakPoint(Point, 0, 0);
136 createPoint(0, 0);
137
138 // Make sure that the debug event listener vas invoked (again).
139 assertTrue(listenerCalled);
140 assertFalse(exception, "exception in listener")
141
142 what = 'symbol';
143 listenerCalled = false;
144 var S = Symbol('Das Symbol');
145 var o = { [S](x, y) { return new Point(x, y); } };
146 Debug.setBreakPoint(Point, 0, 0);
147 o[S](0, 0);
148
149 assertTrue(listenerCalled);
150 assertFalse(exception, "exception in listener")
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/osr-typing-debug-change.js ('k') | test/mjsunit/debug-break-native.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698