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

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

Issue 16539: Factored the generation of JSON serialization from beeing part of the mirror ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 11 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 | « test/mjsunit/mirror-script.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-string.js
===================================================================
--- test/mjsunit/mirror-string.js (revision 1024)
+++ test/mjsunit/mirror-string.js (working copy)
@@ -28,6 +28,8 @@
// Flags: --expose-debug-as debug
// Test the mirror object for string values
+const kMaxProtocolStringLength = 80; // Constant from mirror-delay.js
+
function testStringMirror(s) {
// Create mirror and JSON representation.
var mirror = debug.MakeMirror(s);
@@ -44,16 +46,26 @@
assertTrue(mirror.isPrimitive());
// Test text representation
- assertEquals(s, mirror.toText());
+ if (s.length <= kMaxProtocolStringLength) {
+ assertEquals(s, mirror.toText());
+ } else {
+ assertEquals(s.substring(0, kMaxProtocolStringLength),
+ mirror.toText().substring(0, kMaxProtocolStringLength));
+ }
// Parse JSON representation and check.
var fromJSON = eval('(' + json + ')');
assertEquals('string', fromJSON.type);
- assertEquals(s, fromJSON.value);
+ if (s.length <= kMaxProtocolStringLength) {
+ assertEquals(s, fromJSON.value);
+ } else {
+ assertEquals(s.substring(0, kMaxProtocolStringLength),
+ fromJSON.value.substring(0, kMaxProtocolStringLength));
+ assertEquals(fromJSON.fromIndex, 0);
+ assertEquals(fromJSON.toIndex, kMaxProtocolStringLength);
+ }
}
-Number =2;
-
// Test a number of different strings.
testStringMirror('');
testStringMirror('abcdABCD');
@@ -67,3 +79,10 @@
testStringMirror('\b\t\n\f\r');
testStringMirror('\u0001\u0002\u001E\u001F');
testStringMirror('"a":1,"b":2');
+
+var s = "1234567890"
+s = s + s + s + s + s + s + s + s;
+assertEquals(kMaxProtocolStringLength, s.length);
+testStringMirror(s);
+s = s + 'X';
+testStringMirror(s);
« no previous file with comments | « test/mjsunit/mirror-script.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698