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

Unified Diff: test/mjsunit/mirror-script.js

Issue 21074: Updated handling of the script mirror.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/mirror-delay.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/mirror-script.js
===================================================================
--- test/mjsunit/mirror-script.js (revision 1220)
+++ test/mjsunit/mirror-script.js (working copy)
@@ -28,7 +28,7 @@
// Flags: --expose-debug-as debug
// Test the mirror object for scripts.
-function testScriptMirror(f, file_name, file_lines, script_type) {
+function testScriptMirror(f, file_name, file_lines, script_type, script_source) {
// Create mirror and JSON representation.
var mirror = debug.MakeMirror(f).script();
var serializer = debug.MakeMirrorSerializer();
@@ -43,19 +43,30 @@
assertTrue(mirror.isScript());
assertEquals('script', mirror.type());
var name = mirror.name();
- assertEquals(file_name, name.substring(name.length - file_name.length));
+ if (name) {
+ assertEquals(file_name, name.substring(name.length - file_name.length));
+ } else {
+ assertTrue(file_name === null);
+ }
assertEquals(0, mirror.lineOffset());
assertEquals(0, mirror.columnOffset());
if (file_lines > 0) {
assertEquals(file_lines, mirror.lineCount());
}
assertEquals(script_type, mirror.scriptType());
+ if (script_source) {
+ assertEquals(script_source, mirror.source());
+ }
// Parse JSON representation and check.
var fromJSON = eval('(' + json + ')');
assertEquals('script', fromJSON.type);
name = fromJSON.name;
- assertEquals(file_name, name.substring(name.length - file_name.length));
+ if (name) {
+ assertEquals(file_name, name.substring(name.length - file_name.length));
+ } else {
+ assertTrue(file_name === null);
+ }
assertEquals(0, fromJSON.lineOffset);
assertEquals(0, fromJSON.columnOffset);
if (file_lines > 0) {
@@ -66,5 +77,16 @@
// Test the script mirror for different functions.
-testScriptMirror(function(){}, 'mirror-script.js', 70, 2);
+testScriptMirror(function(){}, 'mirror-script.js', 92, 2);
testScriptMirror(Math.sin, 'native math.js', -1, 0);
+testScriptMirror(eval('function(){}'), null, 1, 2, 'function(){}');
+testScriptMirror(eval('function(){\n }'), null, 2, 2, 'function(){\n }');
+
+// Test taking slices of source.
+var mirror = debug.MakeMirror(eval('function(){\n 1;\n}')).script();
+assertEquals('function(){\n', mirror.sourceSlice(0, 1).sourceText());
+assertEquals(' 1;\n', mirror.sourceSlice(1, 2).sourceText());
+assertEquals('}', mirror.sourceSlice(2, 3).sourceText());
+assertEquals('function(){\n 1;\n', mirror.sourceSlice(0, 2).sourceText());
+assertEquals(' 1;\n}', mirror.sourceSlice(1, 3).sourceText());
+assertEquals('function(){\n 1;\n}', mirror.sourceSlice(0, 3).sourceText());
« no previous file with comments | « src/mirror-delay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698