summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/subst-capture-idx-2.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/subst-capture-idx-2.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/subst-capture-idx-2.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/subst-capture-idx-2.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/subst-capture-idx-2.js
new file mode 100644
index 0000000000..b9138d009d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/subst-capture-idx-2.js
@@ -0,0 +1,43 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Substitution pattern: two-digit capturing group reference
+es6id: 21.2.5.8
+info: |
+ 16. Repeat, for each result in results,
+ [...]
+ m. If functionalReplace is true, then
+ [...]
+ n. Else,
+ i. Let replacement be GetSubstitution(matched, S, position,
+ captures, replaceValue).
+ [...]
+
+ 21.1.3.14.1 Runtime Semantics: GetSubstitution
+
+ Code units:
+ 0x0024, N, N
+ Where 0x0030 ≤ N ≤ 0x0039
+
+ Unicode Characters:
+ $nn where
+ n is one of 0 1 2 3 4 5 6 7 8 9
+
+ Replacement text:
+ The nnth element of captures, where nn is a two-digit decimal number in the
+ range 01 to 99. If nn≤m and the nnth element of captures is undefined, use
+ 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'
+);
+
+reportCompare(0, 0);