summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExpStringIteratorPrototype/next/custom-regexpexec-match-get-0-throws.js
blob: 1db7bb3da988e51bb1f0bcb50422a5b42f77a64f (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
// Copyright (C) 2018 Peter Wong. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: Re-throws errors thrown while accessing the first match
info: |
  %RegExpStringIteratorPrototype%.next ( )
    [...]
    9. Let match be ? RegExpExec(R, S).
    10. If match is null, then
      [...]
    11. Else,
      a. If global is true,
        i. Let matchStr be ? ToString(? Get(match, "0")).
features: [Symbol.matchAll]
---*/

var iter = /./g[Symbol.matchAll]('');

RegExp.prototype.exec = function() {
  return {
    get '0'() {
      throw new Test262Error();
    }
  };
};

assert.throws(Test262Error, function() {
  iter.next();
});

reportCompare(0, 0);