summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/RegExp/RegExpExec-exec.js
blob: e92792fcf49d13fea125e8082224afdf6f470c86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var BUGNUMBER = 887016;
var summary = "RegExpExec should throw if exec property of non-RegExp is not callable";

print(BUGNUMBER + ": " + summary);

for (var exec of [null, 0, false, undefined, ""]) {
  // RegExp with non-callable exec
  var re = /a/;
  re.exec = exec;
  RegExp.prototype[Symbol.match].call(re, "foo");

  // non-RegExp with non-callable exec
  assertThrowsInstanceOf(() => RegExp.prototype[Symbol.match].call({ exec }, "foo"),
                         TypeError);
}

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