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

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

Issue 4100005: Version 2.5.2 (Closed)
Patch Set: Created 10 years, 2 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/math-min-max.js ('k') | tools/windows-tick-processor.bat » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/string-case.js
diff --git a/test/mjsunit/string-case.js b/test/mjsunit/string-case.js
index 13dcd3ea815615f6c2591eb9fcbbdf982147f4c9..283e703fc33d31df4a75944c7558c68eef7f2e64 100644
--- a/test/mjsunit/string-case.js
+++ b/test/mjsunit/string-case.js
@@ -25,4 +25,47 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --random-seed=17
+
assertEquals("ΚΟΣΜΟΣ ΚΟΣΜΟΣ".toLowerCase(), "κοσμος κοσμος");
+
+var A_CODE = "A".charCodeAt(0);
+var Z_CODE = "Z".charCodeAt(0);
+var a_CODE = "a".charCodeAt(0);
+var z_CODE = "z".charCodeAt(0);
+
+function charCodeToLower(charCode) {
+ if (A_CODE <= charCode && charCode <= Z_CODE) {
+ return charCode + a_CODE - A_CODE;
+ }
+ return charCode;
+}
+
+function charCodeToUpper(charCode) {
+ if (a_CODE <= charCode && charCode <= z_CODE) {
+ return charCode - (a_CODE - A_CODE);
+ }
+ return charCode;
+}
+
+function test(length) {
+ var str = "";
+ var strLower = "";
+ var strUpper = "";
+ for (var i = 0; i < length; i++) {
+ var c = Math.round(0x7f * Math.random());
+ str += String.fromCharCode(c);
+ strLower += String.fromCharCode(charCodeToLower(c));
+ strUpper += String.fromCharCode(charCodeToUpper(c));
+ }
+ assertEquals(strLower, str.toLowerCase());
+ assertEquals(strUpper, str.toUpperCase());
+}
+
+for (var i = 1; i <= 128; i <<= 1); {
+ for (var j = 0; j < 8; j++) {
+ for (var k = 0; k < 3; k++) {
+ test(i + j);
+ }
+ }
+}
« no previous file with comments | « test/mjsunit/math-min-max.js ('k') | tools/windows-tick-processor.bat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698