summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/fn-coerce-replacement.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/fn-coerce-replacement.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/fn-coerce-replacement.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/fn-coerce-replacement.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/fn-coerce-replacement.js
new file mode 100644
index 0000000000..6b09118351
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/fn-coerce-replacement.js
@@ -0,0 +1,34 @@
+// 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 the value returned by functional replaceValue.
+info: |
+ RegExp.prototype [ @@replace ] ( string, replaceValue )
+
+ [...]
+ 14. For each result in results, do
+ [...]
+ k. If functionalReplace is true, then
+ [...]
+ v. Let replValue be ? Call(replaceValue, undefined, replacerArgs).
+ vi. Let replacement be ? ToString(replValue).
+features: [Symbol.replace]
+---*/
+
+var replacer = function() {
+ return {
+ toString: function() {
+ return 'toString value';
+ },
+ valueOf: function() {
+ throw new Test262Error('This method should not be invoked.');
+ },
+ };
+};
+
+assert.sameValue(/x/[Symbol.replace]('[x]', replacer), '[toString value]');
+
+reportCompare(0, 0);