OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // lastIndex is set only for global or sticky RegExps. On failure to find |
| 6 // a match, it is set to 0. If a set fails, then it acts as if in strict mode |
| 7 // and throws. |
| 8 |
| 9 var re = /x/g; |
| 10 Object.defineProperty(re, 'lastIndex', {writable: false}); |
| 11 assertThrows(() => re.exec(""), TypeError); |
| 12 assertThrows(() => re.exec("x"), TypeError); |
| 13 |
| 14 var re = /x/y; |
| 15 Object.defineProperty(re, 'lastIndex', {writable: false}); |
| 16 assertThrows(() => re.exec(""), TypeError); |
| 17 assertThrows(() => re.exec("x"), TypeError); |
| 18 |
| 19 var re = /x/; |
| 20 Object.defineProperty(re, 'lastIndex', {writable: false}); |
| 21 assertEquals(null, re.exec("")); |
| 22 assertEquals(["x"], re.exec("x")); |
OLD | NEW |