summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/RegExp/RegExpExec-return.js
blob: 1148aac07f63df41ead5e308a4e21103c31fa512 (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
var BUGNUMBER = 887016;
var summary = "RegExpExec should throw if returned value is not an object nor null.";

print(BUGNUMBER + ": " + summary);

for (var ret of [null, {}, [], /a/]) {
  assertEq(RegExp.prototype[Symbol.match].call({
    get global() {
      return false;
    },
    exec(S) {
      return ret;
    }
  }, "foo"), ret);
}

for (ret of [undefined, 1, true, false, Symbol.iterator]) {
  assertThrowsInstanceOf(() => {
    RegExp.prototype[Symbol.match].call({
      get global() {
        return false;
      },
      exec(S) {
        return ret;
      }
    }, "foo");
  }, TypeError);
}

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