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