summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--js/src/jit-test/tests/latin1/toLowerCase-toUpperCase.js57
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();