Tests for RegExp capture substitution out of bounds (#925)

In https://github.com/tc39/ecma262/pull/853 , standard semantics
for this case are proposed. This patch tests the case.
This commit is contained in:
littledan 2017-03-27 19:53:33 +02:00 committed by Leo Balter
parent 32e129676e
commit 184275fb25
2 changed files with 8 additions and 3 deletions

View File

@ -28,8 +28,10 @@ info: >
Replacement text:
The nth element of captures, where n is a single digit in the range 1 to 9.
If nm and the nth element of captures is undefined, use the empty String
instead. If n>m, the result is implementation-defined.
instead. If n>m, no replacement is done.
features: [Symbol.replace]
---*/
assert.sameValue(/b(c)(z)?(.)/[Symbol.replace]('abcde', '[$1$2$3]'), 'a[cd]e');
assert.sameValue(/b(c)(z)?(.)/[Symbol.replace]('abcde', '[$1$2$3$4$0]'), 'a[cd$4$0]e');

View File

@ -28,11 +28,14 @@ info: >
Replacement text:
The nnth element of captures, where nn is a two-digit decimal number in the
range 01 to 99. If nnm and the nnth element of captures is undefined, use
the empty String instead. If nn is 00 or nn>m, the result is
implementation-defined.
the empty String instead. If nn is 00 or nn>m, no replacement is done.
features: [Symbol.replace]
---*/
assert.sameValue(
/b(c)(z)?(.)/[Symbol.replace]('abcde', '[$01$02$03]'), 'a[cd]e'
);
assert.sameValue(
/b(c)(z)?(.)/[Symbol.replace]('abcde', '[$01$02$03$04$00]'), 'a[cd$04$00]e'
);