blob: bc8710300a7adb319b381be3c33bb174e80f03c9 [file] [log] [blame]
This page tests that a RegExp object's lastIndex behaves like a regular property.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS delete /x/.lastIndex is false
PASS 'use strict'; delete /x/.lastIndex threw exception TypeError: Cannot delete property 'lastIndex' of [object RegExp].
PASS 'lastIndex' in /x/ is true
PASS for (property in /x/) if (property === 'lastIndex') throw false; true is true
PASS var re = /x/; re.lastIndex = re; re.lastIndex === re is true
PASS Object.defineProperty(/x/, {get:function(){}}) threw exception TypeError: Property description must be an object: undefined.
PASS Object.defineProperty(/x/, 'lastIndex', {enumerable:true}); true threw exception TypeError: Cannot redefine property: lastIndex.
PASS Object.defineProperty(/x/, 'lastIndex', {enumerable:false}); true is true
PASS Object.defineProperty(/x/, 'lastIndex', {configurable:true}); true threw exception TypeError: Cannot redefine property: lastIndex.
PASS Object.defineProperty(/x/, 'lastIndex', {configurable:false}); true is true
PASS var re = Object.defineProperty(/x/, 'lastIndex', {writable:true}); re.lastIndex = 42; re.lastIndex is 42
PASS var re = Object.defineProperty(/x/, 'lastIndex', {writable:false}); re.lastIndex = 42; re.lastIndex is 0
PASS var re = Object.defineProperty(/x/, 'lastIndex', {value:42}); re.lastIndex is 42
PASS Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {writable:true}); true threw exception TypeError: Cannot redefine property: lastIndex.
PASS Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {value:42}); true threw exception TypeError: Cannot redefine property: lastIndex.
PASS Object.defineProperty(Object.defineProperty(/x/, 'lastIndex', {writable:false}), 'lastIndex', {value:0}); true is true
PASS Object.defineProperty(/x/, 'lastIndex', {writable:false}).exec('') is null
PASS Object.defineProperty(/x/, 'lastIndex', {writable:false}).exec('x') is ["x"]
FAIL Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('') should throw an exception. Was null.
FAIL Object.defineProperty(/x/g, 'lastIndex', {writable:false}).exec('x') should throw an exception. Was x.
PASS var re = /x/; Object.freeze(re); Object.isFrozen(re); is true
PASS successfullyParsed is true
TEST COMPLETE