Skip to content

Commit d444147

Browse files
committed
Update ES6 Regexp accessors descriptors
In ES6 accessors of built in object are by default configurable. Also lastIndex property of RegExp object is created when only used. JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
1 parent 8d08cec commit d444147

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_FLAGS,
3333

3434
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_SOURCE,
3535
ecma_builtin_regexp_prototype_get_source,
36-
ECMA_PROPERTY_FIXED)
36+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
3737

3838
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_GLOBAL,
3939
ecma_builtin_regexp_prototype_get_global,
40-
ECMA_PROPERTY_FIXED)
40+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
4141

4242
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_IGNORECASE_UL,
4343
ecma_builtin_regexp_prototype_get_ignorecase,
44-
ECMA_PROPERTY_FIXED)
44+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
4545

4646
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_MULTILINE,
4747
ecma_builtin_regexp_prototype_get_multiline,
48-
ECMA_PROPERTY_FIXED)
48+
ECMA_PROPERTY_FLAG_CONFIGURABLE)
4949

5050
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_UNICODE,
5151
ecma_builtin_regexp_prototype_get_unicode,
@@ -79,12 +79,12 @@ SIMPLE_VALUE (LIT_MAGIC_STRING_IGNORECASE_UL,
7979
SIMPLE_VALUE (LIT_MAGIC_STRING_MULTILINE,
8080
ECMA_VALUE_FALSE,
8181
ECMA_PROPERTY_FIXED)
82-
#endif /* ENABLED (JERRY_ES2015) */
8382

8483
/* ECMA-262 v5, 15.10.7.5 */
8584
NUMBER_VALUE (LIT_MAGIC_STRING_LASTINDEX_UL,
8685
0,
8786
ECMA_PROPERTY_FLAG_WRITABLE)
87+
#endif /* ENABLED (JERRY_ES2015) */
8888

8989
#if ENABLED (JERRY_BUILTIN_ANNEXB)
9090
ROUTINE (LIT_MAGIC_STRING_COMPILE, ecma_builtin_regexp_prototype_compile, 2, 1)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var accessors = [ 'global', 'ignoreCase', 'multiline', 'source' ]
16+
17+
accessors.forEach(function(attr) {
18+
var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, attr);
19+
assert(typeof desc.get === 'function')
20+
assert(desc.set === undefined)
21+
assert(desc.enumerable === false)
22+
assert(desc.configurable === true)
23+
});

tests/jerry/es2015/regexp-lastindex.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ result = t.exec("abc abc");
1818
assert(result[0] === "abc");
1919
assert(result.index === 0);
2020
assert(t.lastIndex === 3);
21+
22+
assert(RegExp.prototype.lastIndex === undefined)

0 commit comments

Comments
 (0)