Index: test/mjsunit/string-external-cached.js |
diff --git a/test/mjsunit/string-external-cached.js b/test/mjsunit/string-external-cached.js |
index 0a95830d0b7824b9cd6f1f046831d52f638749bb..6e24285331cca3c25a424d3d7d17666c3e643556 100644 |
--- a/test/mjsunit/string-external-cached.js |
+++ b/test/mjsunit/string-external-cached.js |
@@ -86,6 +86,29 @@ function test() { |
assertEquals("DEFG", ascii_cons.substr(3, 4)); |
assertEquals("DEFG", twobyte_cons.substr(4, 4)); |
} |
+ |
+ // Test adding external strings |
+ var short_ascii = "E="; |
+ var long_ascii = "MCsquared"; |
+ var short_twobyte = "E\u1234"; |
+ var long_twobyte = "MCsquare\u1234"; |
+ try { // String can only be externalized once |
+ externalizeString(short_ascii, false); |
+ externalizeString(long_ascii, false); |
+ externalizeString(short_twobyte, true); |
+ externalizeString(long_twobyte, true); |
+ assertTrue(isAsciiString(short_asii) && isAsciiString(long_ascii)); |
+ assertFalse(isAsciiString(short_twobyte) || isAsciiString(long_twobyte)); |
+ } catch (ex) { } |
+ assertEquals("E=MCsquared", short_ascii + long_ascii); |
+ assertTrue(isAsciiString(short_ascii + long_ascii)); |
+ assertEquals("MCsquaredE=", long_ascii + short_ascii); |
+ assertEquals("E\u1234MCsquare\u1234", short_twobyte + long_twobyte); |
+ assertFalse(isAsciiString(short_twobyte + long_twobyte)); |
+ assertEquals("E=MCsquared", "E=" + long_ascii); |
+ assertEquals("E\u1234MCsquared", short_twobyte + "MCsquared"); |
+ assertEquals("E\u1234MCsquared", short_twobyte + long_ascii); |
+ assertFalse(isAsciiString(short_twobyte + long_ascii)); |
} |
// Run the test many times to ensure IC-s don't break things. |