summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/String/IsRegExp.js
blob: f8f4d3fb163d82d231e49c6033e94c2141c43a9b (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
var BUGNUMBER = 1054755;
var summary = 'String.prototype.{startsWith,endsWith,includes} should call IsRegExp.';

print(BUGNUMBER + ": " + summary);

for (var method of ["startsWith", "endsWith", "includes"]) {
  for (var re of [/foo/, new RegExp()]) {
    assertThrowsInstanceOf(() => "foo"[method](re), TypeError);

    re[Symbol.match] = false;
    "foo"[method](re);
  }

  for (var v1 of [true, 1, "bar", [], {}, Symbol.iterator]) {
    assertThrowsInstanceOf(() => "foo"[method]({ [Symbol.match]: v1 }), TypeError);
  }

  for (var v2 of [false, 0, undefined, ""]) {
    "foo"[method]({ [Symbol.match]: v2 });
  }
}

if (typeof reportCompare === "function")
  reportCompare(true, true);