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

Side by Side Diff: test/mjsunit/debug-sourceinfo.js

Issue 2003303002: Remove inessential functions from the JS Script class (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 7 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
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/mjsunit/debug-sourceslice.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 // Get the Debug object exposed from the debug context global object. 58 // Get the Debug object exposed from the debug context global object.
59 Debug = debug.Debug 59 Debug = debug.Debug
60 60
61 // This is the number of comment lines above the first test function. 61 // This is the number of comment lines above the first test function.
62 var comment_lines = 28; 62 var comment_lines = 28;
63 63
64 // This is the last position in the entire file (note: this equals 64 // This is the last position in the entire file (note: this equals
65 // file size of <debug-sourceinfo.js> - 1, since starting at 0). 65 // file size of <debug-sourceinfo.js> - 1, since starting at 0).
66 var last_position = 11519; 66 var last_position = 8126;
67 // This is the last line of entire file (note: starting at 0). 67 // This is the last line of entire file (note: starting at 0).
68 var last_line = 269; 68 var last_line = 200;
69 // This is the last column of last line (note: starting at 0 and +1, due 69 // This is the last column of last line (note: starting at 0).
70 // to trailing <LF>). 70 var last_column = 71;
71 var last_column = 1;
72 71
73 // This magic number is the length or the first line comment (actually number 72 // This magic number is the length or the first line comment (actually number
74 // of characters before 'function a(...'. 73 // of characters before 'function a(...'.
75 var comment_line_length = 1633; 74 var comment_line_length = 1633;
76 var start_a = 9 + comment_line_length; 75 var start_a = 9 + comment_line_length;
77 var start_b = 35 + comment_line_length; 76 var start_b = 35 + comment_line_length;
78 var start_c = 66 + comment_line_length; 77 var start_c = 66 + comment_line_length;
79 var start_d = 151 + comment_line_length; 78 var start_d = 151 + comment_line_length;
80 79
81 // The position of the first line of d(), i.e. "x = 1 ;". 80 // The position of the first line of d(), i.e. "x = 1 ;".
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Test first position in function c(). 160 // Test first position in function c().
162 assertEquals(start_c, script.locationFromPosition(start_c).position); 161 assertEquals(start_c, script.locationFromPosition(start_c).position);
163 assertEquals(4, script.locationFromPosition(start_c).line - comment_lines); 162 assertEquals(4, script.locationFromPosition(start_c).line - comment_lines);
164 assertEquals(12, script.locationFromPosition(start_c).column); 163 assertEquals(12, script.locationFromPosition(start_c).column);
165 164
166 // Test first position in function d(). 165 // Test first position in function d().
167 assertEquals(start_d, script.locationFromPosition(start_d).position); 166 assertEquals(start_d, script.locationFromPosition(start_d).position);
168 assertEquals(11, script.locationFromPosition(start_d).line - comment_lines); 167 assertEquals(11, script.locationFromPosition(start_d).line - comment_lines);
169 assertEquals(10, script.locationFromPosition(start_d).column); 168 assertEquals(10, script.locationFromPosition(start_d).column);
170 169
171 // Test first line.
172 assertEquals(0, script.locationFromLine().position);
173 assertEquals(0, script.locationFromLine().line);
174 assertEquals(0, script.locationFromLine().column);
175 assertEquals(0, script.locationFromLine(0).position);
176 assertEquals(0, script.locationFromLine(0).line);
177 assertEquals(0, script.locationFromLine(0).column);
178
179 // Test first line column 1.
180 assertEquals(1, script.locationFromLine(0, 1).position);
181 assertEquals(0, script.locationFromLine(0, 1).line);
182 assertEquals(1, script.locationFromLine(0, 1).column);
183
184 // Test first line offset 1.
185 assertEquals(1, script.locationFromLine(0, 0, 1).position);
186 assertEquals(0, script.locationFromLine(0, 0, 1).line);
187 assertEquals(1, script.locationFromLine(0, 0, 1).column);
188
189 // Test offset function a().
190 assertEquals(start_a, script.locationFromLine(void 0, void 0, start_a).position) ;
191 assertEquals(0, script.locationFromLine(void 0, void 0, start_a).line - comment_ lines);
192 assertEquals(10, script.locationFromLine(void 0, void 0, start_a).column);
193 assertEquals(start_a, script.locationFromLine(0, void 0, start_a).position);
194 assertEquals(0, script.locationFromLine(0, void 0, start_a).line - comment_lines );
195 assertEquals(10, script.locationFromLine(0, void 0, start_a).column);
196 assertEquals(start_a, script.locationFromLine(0, 0, start_a).position);
197 assertEquals(0, script.locationFromLine(0, 0, start_a).line - comment_lines);
198 assertEquals(10, script.locationFromLine(0, 0, start_a).column);
199
200 // Test second line offset function a().
201 assertEquals(start_a + 13, script.locationFromLine(1, 0, start_a).position);
202 assertEquals(1, script.locationFromLine(1, 0, start_a).line - comment_lines);
203 assertEquals(0, script.locationFromLine(1, 0, start_a).column);
204
205 // Test second line column 2 offset function a().
206 assertEquals(start_a + 13 + 1, script.locationFromLine(1, 1, start_a).position);
207 assertEquals(1, script.locationFromLine(1, 2, start_a).line - comment_lines);
208 assertEquals(2, script.locationFromLine(1, 2, start_a).column);
209
210 // Test offset function b().
211 assertEquals(start_b, script.locationFromLine(0, 0, start_b).position);
212 assertEquals(1, script.locationFromLine(0, 0, start_b).line - comment_lines);
213 assertEquals(13, script.locationFromLine(0, 0, start_b).column);
214
215 // Test second line offset function b().
216 assertEquals(start_b + 5, script.locationFromLine(1, 0, start_b).position);
217 assertEquals(2, script.locationFromLine(1, 0, start_b).line - comment_lines);
218 assertEquals(0, script.locationFromLine(1, 0, start_b).column);
219
220 // Test second line column 10 offset function b().
221 assertEquals(start_b + 5 + 10, script.locationFromLine(1, 10, start_b).position) ;
222 assertEquals(2, script.locationFromLine(1, 10, start_b).line - comment_lines);
223 assertEquals(10, script.locationFromLine(1, 10, start_b).column);
224
225 // Test second line column 11 offset function b. Second line in b is 10 long
226 // using column 11 wraps to next line.
227 assertEquals(start_b + 5 + 11, script.locationFromLine(1, 11, start_b).position) ;
228 assertEquals(3, script.locationFromLine(1, 11, start_b).line - comment_lines);
229 assertEquals(0, script.locationFromLine(1, 11, start_b).column);
230
231 // Test the Debug.findSourcePosition which wraps SourceManager. 170 // Test the Debug.findSourcePosition which wraps SourceManager.
232 assertEquals(0 + start_a, Debug.findFunctionSourceLocation(a, 0, 0).position); 171 assertEquals(0 + start_a, Debug.findFunctionSourceLocation(a, 0, 0).position);
233 assertEquals(0 + start_b, Debug.findFunctionSourceLocation(b, 0, 0).position); 172 assertEquals(0 + start_b, Debug.findFunctionSourceLocation(b, 0, 0).position);
234 assertEquals(5 + start_b, Debug.findFunctionSourceLocation(b, 1, 0).position); 173 assertEquals(5 + start_b, Debug.findFunctionSourceLocation(b, 1, 0).position);
235 assertEquals(7 + start_b, Debug.findFunctionSourceLocation(b, 1, 2).position); 174 assertEquals(7 + start_b, Debug.findFunctionSourceLocation(b, 1, 2).position);
236 assertEquals(16 + start_b, Debug.findFunctionSourceLocation(b, 2, 0).position); 175 assertEquals(16 + start_b, Debug.findFunctionSourceLocation(b, 2, 0).position);
237 assertEquals(0 + start_c, Debug.findFunctionSourceLocation(c, 0, 0).position); 176 assertEquals(0 + start_c, Debug.findFunctionSourceLocation(c, 0, 0).position);
238 assertEquals(6 + start_c, Debug.findFunctionSourceLocation(c, 1, 0).position); 177 assertEquals(6 + start_c, Debug.findFunctionSourceLocation(c, 1, 0).position);
239 assertEquals(19 + start_c, Debug.findFunctionSourceLocation(c, 2, 0).position); 178 assertEquals(19 + start_c, Debug.findFunctionSourceLocation(c, 2, 0).position);
240 assertEquals(35 + start_c, Debug.findFunctionSourceLocation(c, 3, 0).position); 179 assertEquals(35 + start_c, Debug.findFunctionSourceLocation(c, 3, 0).position);
(...skipping 12 matching lines...) Expand all
253 assertEquals(0, script.locationFromPosition(-1).line); 192 assertEquals(0, script.locationFromPosition(-1).line);
254 assertEquals(null, script.locationFromPosition(last_position + 2)); 193 assertEquals(null, script.locationFromPosition(last_position + 2));
255 194
256 // Test last position. 195 // Test last position.
257 assertEquals(last_position, script.locationFromPosition(last_position).position) ; 196 assertEquals(last_position, script.locationFromPosition(last_position).position) ;
258 assertEquals(last_line, script.locationFromPosition(last_position).line); 197 assertEquals(last_line, script.locationFromPosition(last_position).line);
259 assertEquals(last_column, script.locationFromPosition(last_position).column); 198 assertEquals(last_column, script.locationFromPosition(last_position).column);
260 assertEquals(last_line + 1, 199 assertEquals(last_line + 1,
261 script.locationFromPosition(last_position + 1).line); 200 script.locationFromPosition(last_position + 1).line);
262 assertEquals(0, script.locationFromPosition(last_position + 1).column); 201 assertEquals(0, script.locationFromPosition(last_position + 1).column);
263
264 // Test that script.sourceLine(line) works.
265 var location;
266
267 for (line = 0; line < num_lines_d; line++) {
268 var line_content_regexp = new RegExp(" x = " + (line + 1));
269 assertTrue(line_content_regexp.test(script.sourceLine(start_line_d + line)));
270 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/mjsunit/debug-sourceslice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698