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); |