diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js')
-rw-r--r-- | js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js b/js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js new file mode 100644 index 0000000000..d1855dc3d7 --- /dev/null +++ b/js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js @@ -0,0 +1,57 @@ +function testToLowerCase() { + var s1 = "abcdefgABCDEFGH 123456"; + assertEq(isLatin1(s1), true); + + // Latin1 + var s2 = s1.toLowerCase(); + assertEq(isLatin1(s2), true); + assertEq(s2, "abcdefgabcdefgh 123456"); + + s2 = s1.toLocaleLowerCase(); + assertEq(isLatin1(s2), true); + assertEq(s2, "abcdefgabcdefgh 123456"); + + // TwoByte + s2 = "abcdefg\u1200ABCDEFGH 123456\u04AC".toLowerCase(); + assertEq(s2, "abcdefg\u1200abcdefgh 123456\u04AD"); + + s2 = "abcdefg\u1200ABCDEFGH 123456\u04AC".toLocaleLowerCase(); + assertEq(s2, "abcdefg\u1200abcdefgh 123456\u04AD"); + + // For toLowerCase, every Latin1 character maps to a Latin1 character. + for (var i=0; i <= 0xff; i++) { + var s = "\u1200\u11AA" + String.fromCharCode(i); + assertEq(s.toLowerCase().charCodeAt(2) <= 0xff, true); + } +} +testToLowerCase(); + +function testToUpperCase() { + var s1 = "abcdefgABCDEFGH 12345"; + assertEq(isLatin1(s1), true); + + // Latin1 + var s2 = s1.toUpperCase(); + assertEq(isLatin1(s2), true); + assertEq(s2, "ABCDEFGABCDEFGH 12345"); + + s2 = s1.toLocaleUpperCase(); + assertEq(isLatin1(s2), true); + assertEq(s2, "ABCDEFGABCDEFGH 12345"); + + // TwoByte + s2 = "abcdefg\u1200ABCDEFGH 12345\u1E0F".toUpperCase(); + assertEq(s2, "ABCDEFG\u1200ABCDEFGH 12345\u1E0E"); + + s2 = "abcdefg\u1200ABCDEFGH 12345\u1E0F".toLocaleUpperCase(); + assertEq(s2, "ABCDEFG\u1200ABCDEFGH 12345\u1E0E"); + + // Tricky case: Latin1 character \u00FF maps to \u0178, a + // non-Latin1 character. + s1 = "ABC\u00FF"; + assertEq(isLatin1(s1), true); + s2 = s1.toUpperCase(); + assertEq(isLatin1(s2), false); + assertEq(s2, "ABC\u0178"); +} +testToUpperCase(); |