| 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 according to funny rules. It is typically set only | |
| 6 // for global or sticky RegExps, but on a failure to find a match, it is | |
| 7 // set unconditionally. If a set fails, then it acts as if in strict mode | |
| 8 // and throws. | |
| 9 | |
| 10 var re = /x/; | |
| 11 Object.defineProperty(re, 'lastIndex', {writable: false}); | |
| 12 assertThrows(() => re.exec(""), TypeError); | |
| 13 assertEquals(["x"], re.exec("x")); | |
| 14 | |
| 15 var re = /x/y; | |
| 16 Object.defineProperty(re, 'lastIndex', {writable: false}); | |
| 17 assertThrows(() => re.exec(""), TypeError); | |
| 18 assertThrows(() => re.exec("x"), TypeError); | |
| OLD | NEW |