Lines Matching full:lastindex
25 "This page tests that a RegExp object's lastIndex behaves like a regular property."
28 // lastIndex is not configurable
29 shouldBeFalse("delete /x/.lastIndex");
30 shouldThrow("'use strict'; delete /x/.lastIndex");
32 // lastIndex is not enumerable
33 shouldBeTrue("'lastIndex' in /x/");
34 shouldBeTrue("for (property in /x/) if (property === 'lastIndex') throw false; true");
36 // lastIndex is writable
37 shouldBeTrue("var re = /x/; re.lastIndex = re; re.lastIndex === re");
39 // Cannot redefine lastIndex as an accessor
42 // Cannot redefine lastIndex as enumerable
43 shouldThrow("Object.defineProperty(/x/, 'lastIndex', {enumerable:true}); true");
44 shouldBeTrue("Object.defineProperty(/x/, 'lastIndex', {enumerable:false}); true");
46 // Cannot redefine lastIndex as configurable
47 shouldThrow("Object.defineProperty(/x/, 'lastIndex', {configurable:true}); true");
48 shouldBeTrue("Object.defineProperty(/x/, 'lastIndex', {configurable:false}); true");
50 // Can redefine lastIndex as read-only
51 shouldBe("var re = Object.defineProperty(/x/, 'lastIndex', {writable:true}); re.lastIndex = 42; re.lastIndex", '42');
52 shouldBe("var re = Object.defineProperty(/x/, 'lastIndex', {writable:false}); re.lastIndex = 42; re.lastIndex", '0');
55 shouldBe("var re = Object.defineProperty(/x/, 'lastIndex', {value:42}); re.lastIndex", '42');
57 // Cannot redefine read-only lastIndex as writable
58 shouldThrow("Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {writable:true}); true");
60 // Can only redefine the value of a read-only lastIndex as the current value
61 shouldThrow("Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {value:42}); true");
62 shouldBeTrue("Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {value:0}); true");
64 // Trying to run a global regular expression should throw, if lastIndex is read-only
65 shouldBe("Object.defineProperty(/x/, 'lastIndex', {writable:false}).exec('')", 'null');
66 shouldBe("Object.defineProperty(/x/, 'lastIndex', {writable:false}).exec('x')", '["x"]');
67 shouldThrow("Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('')");
68 shouldThrow("Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('x')");