summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-matched.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-matched.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-matched.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-matched.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-matched.js
new file mode 100644
index 0000000000..7d0ba81931
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-matched.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-regexp.prototype-@@replace
+description: >
+ String coercion of "0" property of the value returned by RegExpExec.
+info: |
+ RegExp.prototype [ @@replace ] ( string, replaceValue )
+
+ [...]
+ 11. Repeat, while done is false
+ a. Let result be ? RegExpExec(rx, S).
+ [...]
+ 14. For each result in results, do
+ [...]
+ c. Let matched be ? ToString(? Get(result, "0")).
+features: [Symbol.replace]
+---*/
+
+var r = /./;
+var coercibleValue = {
+ length: 1,
+ 0: {
+ toString: function() {
+ return 'toString value';
+ },
+ valueOf: function() {
+ throw new Test262Error('This method should not be invoked.');
+ },
+ },
+ index: 0,
+};
+r.exec = function() {
+ return coercibleValue;
+};
+
+assert.sameValue(
+ r[Symbol.replace]('', 'foo[$&]bar'), 'foo[toString value]bar'
+);
+
+reportCompare(0, 0);