diff --git a/test/built-ins/RegExp/lastIndex.js b/test/built-ins/RegExp/lastIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..8d24936a863cf614e9fcac5308becdb7f07ca7aa --- /dev/null +++ b/test/built-ins/RegExp/lastIndex.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regexp-pattern-flags +es6id: 21.2.3.1 +description: Initial state of the `lastIndex` property +info: | + [...] + 7. Let O be ? RegExpAlloc(newTarget). + 8. Return ? RegExpInitialize(O, P, F). + + 21.2.3.2.2 Runtime Semantics: RegExpInitialize + + [...] + 12. Perform ? Set(obj, "lastIndex", 0, true). + [...] + + 21.2.3.2.1 Runtime Semantics: RegExpAlloc + + [...] + 2. Perform ! DefinePropertyOrThrow(obj, "lastIndex", PropertyDescriptor + {[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}). + [...] +includes: [propertyHelper.js] +---*/ + +var re = new RegExp(''); + +assert.sameValue(re.lastIndex, 0); + +verifyNotEnumerable(re, 'lastIndex'); +verifyWritable(re, 'lastIndex'); +verifyNotConfigurable(re, 'lastIndex'); diff --git a/test/built-ins/RegExp/prototype/lastIndex/S15.10.7.5_A8.js b/test/built-ins/RegExp/prototype/lastIndex/S15.10.7.5_A8.js deleted file mode 100644 index 70c252043c5d3e03ee915d6523dd0a0fbc817857..0000000000000000000000000000000000000000 --- a/test/built-ins/RegExp/prototype/lastIndex/S15.10.7.5_A8.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: The RegExp instance lastIndex property has the attribute DontEnum -es5id: 15.10.7.5_A8 -description: > - Checking if enumerating the lastIndex property of RegExp instance - fails ----*/ - -var __re = new RegExp("A?B"); - -//CHECK#0 -if (__re.hasOwnProperty('lastIndex') !== true) { - $ERROR('#0: __re = new RegExp("A?B"); __re.hasOwnProperty(\'lastIndex\') === true'); -} - - //CHECK#1 -if (__re.propertyIsEnumerable('lastIndex') !== false) { - $ERROR('#1: __re = new RegExp("A?B"); __re.propertyIsEnumerable(\'lastIndex\') === false'); -} - - //CHECK#2 -var count = 0 -for (var p in __re){ - if (p==="lastIndex") count++ -} - -if (count !== 0) { - $ERROR('#2: count = 0; __re = new RegExp("A?B"); for (p in __re){ if (p==="lastIndex") count++; } count === 0. Actual: ' + (count)); -} diff --git a/test/built-ins/RegExp/prototype/lastIndex/S15.10.7.5_A9.js b/test/built-ins/RegExp/prototype/lastIndex/S15.10.7.5_A9.js deleted file mode 100644 index 8b53970970b6826ad064f1b79d296239538b303e..0000000000000000000000000000000000000000 --- a/test/built-ins/RegExp/prototype/lastIndex/S15.10.7.5_A9.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: The RegExp instance lastIndex property has the attribute DontDelete -es5id: 15.10.7.5_A9 -description: Checking if deleting the lastIndex property fails -includes: [propertyHelper.js] ----*/ - -var __re = new RegExp; - -//CHECK#0 -if (__re.hasOwnProperty('lastIndex') !== true) { - $ERROR('#0: __re = new RegExp; __re.hasOwnProperty(\'lastIndex\') === true'); -} - -verifyNotConfigurable(__re, "lastIndex"); - -//CHECK#1 -try { - if ((delete __re.lastIndex) !== false) { - $ERROR('#1: __re = new RegExp; (delete __re.lastIndex) === false'); - } -} catch (e) { - if (e instanceof Test262Error) throw e; - assert(e instanceof TypeError); -} - -//CHECK#2 -if (__re.hasOwnProperty('lastIndex') !== true) { - $ERROR('#2: __re = new RegExp;delete __re.lastIndex === true; __re.hasOwnProperty(\'lastIndex\') === true'); -} diff --git a/test/language/literals/regexp/lastIndex.js b/test/language/literals/regexp/lastIndex.js new file mode 100644 index 0000000000000000000000000000000000000000..939438672fecbe46318ab562e59abecf7d3e8ee5 --- /dev/null +++ b/test/language/literals/regexp/lastIndex.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-regular-expression-literals-runtime-semantics-evaluation +es6id: 12.2.8.2 +description: Initial state of the `lastIndex` property +info: | + [...] + 3. Return RegExpCreate(pattern, flags). + + 21.2.3.2.3 Runtime Semantics: RegExpCreate + + 1. Let obj be ? RegExpAlloc(%RegExp%). + 2. Return ? RegExpInitialize(obj, P, F). + + 21.2.3.2.2 Runtime Semantics: RegExpInitialize + + [...] + 12. Perform ? Set(obj, "lastIndex", 0, true). + [...] + + 21.2.3.2.1 Runtime Semantics: RegExpAlloc + + [...] + 2. Perform ! DefinePropertyOrThrow(obj, "lastIndex", PropertyDescriptor + {[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}). + [...] +includes: [propertyHelper.js] +---*/ + +var re = /./; + +assert.sameValue(re.lastIndex, 0); + +verifyNotEnumerable(re, 'lastIndex'); +verifyWritable(re, 'lastIndex'); +verifyNotConfigurable(re, 'lastIndex');