summaryrefslogtreecommitdiff
path: root/js/src/jit-test/tests/optional-chain/call-ignore-rval.js
blob: c5fd2fe9758e7f89679fdcc25928d4537143db47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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(); }