summaryrefslogtreecommitdiff
path: root/test/built-ins/RegExp/prototype/Symbol.match/g-init-lastindex-err.js
blob: 1a6bd10309d8d9fb4ffcc0d6456cc40c88def134 (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
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Behavior when `lastIndex` cannot be set on "global" instances
es6id: 21.2.5.6
info: |
    7. If global is false, then
       [...]
    8. Else global is true,
       [...]
       c. Let setStatus be Set(rx, "lastIndex", 0, true).
       d. ReturnIfAbrupt(setStatus).
features: [Symbol.match]
---*/

var r = /./g;
Object.defineProperty(r, 'lastIndex', {
  writable: false
});

assert.throws(TypeError, function() {
  r[Symbol.match]('');
});