summaryrefslogtreecommitdiff
path: root/js/src/jit-test/tests/optional-chain/call-ignore-rval.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/optional-chain/call-ignore-rval.js')
-rw-r--r--js/src/jit-test/tests/optional-chain/call-ignore-rval.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/optional-chain/call-ignore-rval.js b/js/src/jit-test/tests/optional-chain/call-ignore-rval.js
new file mode 100644
index 000000000..c5fd2fe97
--- /dev/null
+++ b/js/src/jit-test/tests/optional-chain/call-ignore-rval.js
@@ -0,0 +1,34 @@
+// Tests for JSOp::CallIgnoresRv in optional chains.
+
+// Note:: IgnoresReturnValueNative is supported for Array.prototype.splice.
+
+// Test for optional call.
+function testOptionalCall() {
+ for (var i = 0; i < 100; ++i) {
+ var x = [1, 2, 3];
+ x.splice?.(0);
+ }
+}
+
+for (var i = 0; i < 5; ++i) { testOptionalCall(); }
+
+// Test for optional prop directly followed by call.
+function testOptionalProp() {
+ for (var i = 0; i < 100; ++i) {
+ var x = [1, 2, 3];
+ x?.splice(0);
+ }
+}
+
+for (var i = 0; i < 5; ++i) { testOptionalProp(); }
+
+// Test for call in optional chain expression.
+function testOptionalChain() {
+ for (var i = 0; i < 100; ++i) {
+ var x = [1, 2, 3];
+ var o = {x};
+ o?.x.splice(0);
+ }
+}
+
+for (var i = 0; i < 5; ++i) { testOptionalChain(); }