summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/substring-inline-strings.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/basic/substring-inline-strings.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/basic/substring-inline-strings.js')
-rw-r--r--js/src/jit-test/tests/basic/substring-inline-strings.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/substring-inline-strings.js b/js/src/jit-test/tests/basic/substring-inline-strings.js
new file mode 100644
index 0000000000..3f9381bb50
--- /dev/null
+++ b/js/src/jit-test/tests/basic/substring-inline-strings.js
@@ -0,0 +1,49 @@
+let hasStringRepresentation = typeof stringRepresentation === "function";
+
+function testLatin1() {
+ var s = "abcdefghijklmnopqrstuvwxyz";
+ for (var i = 0; i < 100; i++) {
+ var sub8 = s.substring(0, 8);
+ assertEq(sub8, "abcdefgh");
+ if (hasStringRepresentation) {
+ assertEq(stringRepresentation(sub8).includes("(JSThinInlineString*)"), true);
+ }
+
+ var sub24 = s.substring(0, 24);
+ assertEq(sub24, "abcdefghijklmnopqrstuvwx");
+ if (hasStringRepresentation) {
+ assertEq(stringRepresentation(sub24).includes("(JSFatInlineString*)"), true);
+ }
+
+ var sub25 = s.substring(0, 25);
+ assertEq(sub25, "abcdefghijklmnopqrstuvwxy");
+ if (hasStringRepresentation) {
+ assertEq(stringRepresentation(sub25).includes("(JSDependentString*)"), true);
+ }
+ }
+}
+testLatin1();
+
+function testTwoByte() {
+ var s = "\u1000bcdefghijklmnopqrstuvwxyz";
+ for (var i = 0; i < 100; i++) {
+ var sub4 = s.substring(0, 4);
+ assertEq(sub4, "\u1000bcd");
+ if (hasStringRepresentation) {
+ assertEq(stringRepresentation(sub4).includes("(JSThinInlineString*)"), true);
+ }
+
+ var sub12 = s.substring(0, 12);
+ assertEq(sub12, "\u1000bcdefghijkl");
+ if (hasStringRepresentation) {
+ assertEq(stringRepresentation(sub12).includes("(JSFatInlineString*)"), true);
+ }
+
+ var sub13 = s.substring(0, 13);
+ assertEq(sub13, "\u1000bcdefghijklm");
+ if (hasStringRepresentation) {
+ assertEq(stringRepresentation(sub13).includes("(JSDependentString*)"), true);
+ }
+ }
+}
+testTwoByte();