OLD | NEW |
---|---|
(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 // Get the Debug object exposed from the debug context global object. | |
30 Debug = debug.Debug | |
Yang
2016/11/15 09:24:16
From experience this test has uncovered a bunch of
jgruber
2016/11/15 10:59:10
Done. I've removed the parts using Debug.setBreakP
| |
31 | |
32 Debug.setListener(function() {}); | |
33 | |
34 function f() {a=1;b=2} | |
35 function g() { | |
36 a=1; | |
37 b=2; | |
38 } | |
39 | |
40 bp = Debug.setBreakPoint(f, 0, 0); | |
41 assertEquals("() {[B0]a=1;b=2}", Debug.showBreakPoints(f)); | |
42 Debug.clearBreakPoint(bp); | |
43 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | |
44 bp1 = Debug.setBreakPoint(f, 0, 8); | |
45 assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f)); | |
46 bp2 = Debug.setBreakPoint(f, 0, 4); | |
47 assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f)); | |
48 bp3 = Debug.setBreakPoint(f, 0, 11); | |
49 assertEquals("() {[B0]a=1;[B1]b=2[B2]}", Debug.showBreakPoints(f)); | |
50 Debug.clearBreakPoint(bp1); | |
51 assertEquals("() {[B0]a=1;b=2[B1]}", Debug.showBreakPoints(f)); | |
52 Debug.clearBreakPoint(bp2); | |
53 assertEquals("() {a=1;b=2[B0]}", Debug.showBreakPoints(f)); | |
54 Debug.clearBreakPoint(bp3); | |
55 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | |
56 | |
57 // The following test checks that the Debug.showBreakPoints(g) produces output | |
58 // like follows when changein breakpoints. | |
59 // | |
60 // function g() { | |
61 // [BX]a=1; | |
62 // [BX]b=2; | |
63 // }[BX] | |
64 | |
65 // Test set and clear breakpoint at the first possible location (line 0, | |
66 // position 0). | |
67 bp = Debug.setBreakPoint(g, 0, 0); | |
68 // function g() { | |
69 // [B0]a=1; | |
70 // b=2; | |
71 // } | |
72 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
73 Debug.clearBreakPoint(bp); | |
74 // function g() { | |
75 // a=1; | |
76 // b=2; | |
77 // } | |
78 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); | |
79 | |
80 // Second test set and clear breakpoints on lines 1, 2 and 3 (position = 0). | |
81 bp1 = Debug.setBreakPoint(g, 2, 0); | |
82 // function g() { | |
83 // a=1; | |
84 // [B0]b=2; | |
85 // } | |
86 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]b=2;") > 0); | |
87 bp2 = Debug.setBreakPoint(g, 1, 0); | |
88 // function g() { | |
89 // [B0]a=1; | |
90 // [B1]b=2; | |
91 // } | |
92 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
93 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0); | |
94 bp3 = Debug.setBreakPoint(g, 3, 0); | |
95 // function g() { | |
96 // [B0]a=1; | |
97 // [B1]b=2; | |
98 // }[B2] | |
99 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
100 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0); | |
101 assertTrue(Debug.showBreakPoints(g).indexOf("[B2]}") > 0); | |
102 Debug.clearBreakPoint(bp1); | |
103 // function g() { | |
104 // [B0]a=1; | |
105 // b=2; | |
106 // }[B1] | |
107 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
108 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]}") > 0); | |
109 assertTrue(Debug.showBreakPoints(g).indexOf("[B2]") < 0); | |
110 Debug.clearBreakPoint(bp2); | |
111 // function g() { | |
112 // a=1; | |
113 // b=2; | |
114 // }[B0] | |
115 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]}") > 0); | |
116 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0); | |
117 Debug.clearBreakPoint(bp3); | |
118 // function g() { | |
119 // a=1; | |
120 // b=2; | |
121 // } | |
122 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); | |
123 | |
124 | |
125 // Tests for setting break points by script id and position. | |
126 function setBreakpointByPosition(f, position, opt_position_alignment) | |
127 { | |
128 var break_point = Debug.setBreakPointByScriptIdAndPosition( | |
129 Debug.findScript(f).id, | |
130 position + Debug.sourcePosition(f), | |
131 "", | |
132 true, opt_position_alignment); | |
133 return break_point.number(); | |
134 } | |
135 | |
136 bp = setBreakpointByPosition(f, 0); | |
137 assertEquals("() {[B0]a=1;b=2}", Debug.showBreakPoints(f)); | |
138 Debug.clearBreakPoint(bp); | |
139 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | |
140 bp1 = setBreakpointByPosition(f, 8); | |
141 assertEquals("() {a=1;[B0]b=2}", Debug.showBreakPoints(f)); | |
142 bp2 = setBreakpointByPosition(f, 4); | |
143 assertEquals("() {[B0]a=1;[B1]b=2}", Debug.showBreakPoints(f)); | |
144 bp3 = setBreakpointByPosition(f, 11); | |
145 assertEquals("() {[B0]a=1;[B1]b=2[B2]}", Debug.showBreakPoints(f)); | |
146 Debug.clearBreakPoint(bp1); | |
147 assertEquals("() {[B0]a=1;b=2[B1]}", Debug.showBreakPoints(f)); | |
148 Debug.clearBreakPoint(bp2); | |
149 assertEquals("() {a=1;b=2[B0]}", Debug.showBreakPoints(f)); | |
150 Debug.clearBreakPoint(bp3); | |
151 assertEquals("() {a=1;b=2}", Debug.showBreakPoints(f)); | |
152 | |
153 bp = setBreakpointByPosition(g, 0); | |
154 //function g() { | |
155 //[B0]a=1; | |
156 //b=2; | |
157 //} | |
158 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
159 Debug.clearBreakPoint(bp); | |
160 //function g() { | |
161 //a=1; | |
162 //b=2; | |
163 //} | |
164 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); | |
165 | |
166 //Second test set and clear breakpoints on lines 1, 2 and 3 (column = 0). | |
167 bp1 = setBreakpointByPosition(g, 12); | |
168 //function g() { | |
169 //a=1; | |
170 //[B0]b=2; | |
171 //} | |
172 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]b=2;") > 0); | |
173 bp2 = setBreakpointByPosition(g, 5); | |
174 //function g() { | |
175 //[B0]a=1; | |
176 //[B1]b=2; | |
177 //} | |
178 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
179 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0); | |
180 bp3 = setBreakpointByPosition(g, 19); | |
181 //function g() { | |
182 //[B0]a=1; | |
183 //[B1]b=2; | |
184 //}[B2] | |
185 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
186 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]b=2;") > 0); | |
187 assertTrue(Debug.showBreakPoints(g).indexOf("[B2]}") > 0); | |
188 Debug.clearBreakPoint(bp1); | |
189 //function g() { | |
190 //[B0]a=1; | |
191 //b=2; | |
192 //}[B1] | |
193 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]a=1;") > 0); | |
194 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]}") > 0); | |
195 assertTrue(Debug.showBreakPoints(g).indexOf("[B2]") < 0); | |
196 Debug.clearBreakPoint(bp2); | |
197 //function g() { | |
198 //a=1; | |
199 //b=2; | |
200 //}[B0] | |
201 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]}") > 0); | |
202 assertTrue(Debug.showBreakPoints(g).indexOf("[B1]") < 0); | |
203 Debug.clearBreakPoint(bp3); | |
204 //function g() { | |
205 //a=1; | |
206 //b=2; | |
207 //} | |
208 assertTrue(Debug.showBreakPoints(g).indexOf("[B0]") < 0); | |
209 | |
210 // Tests for setting break points without statement aligment. | |
211 // (This may be sensitive to compiler break position map generation). | |
212 function h() {a=f(f2(1,2),f3())+f3();b=f3();} | |
213 var scenario = [ | |
214 [6, "{a=[B0]f("], | |
215 [7, "{a=f([B0]f2("], | |
216 [16, "f2(1,2),[B0]f3()"], | |
217 [22, "+[B0]f3()"] | |
218 ]; | |
219 for(var i = 0; i < scenario.length; i++) { | |
220 bp1 = setBreakpointByPosition(h, scenario[i][0], | |
221 Debug.BreakPositionAlignment.BreakPosition); | |
222 assertTrue(Debug.showBreakPoints(h, undefined, | |
223 Debug.BreakPositionAlignment.BreakPosition).indexOf(scenario[i][1]) > 0); | |
224 Debug.clearBreakPoint(bp1); | |
225 } | |
OLD | NEW |