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

Unified Diff: test/mjsunit/string-external-cached.js

Issue 8931025: Handle external strings in generated code when concatenating short strings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years 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/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698