summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-length.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-length.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-length.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-length.js
new file mode 100644
index 0000000000..ce35f50bc8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-length.js
@@ -0,0 +1,37 @@
+// 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: >
+ Type coercion of "length" property of the value returned by RegExpExec.
+info: |
+ RegExp.prototype [ @@replace ] ( string, replaceValue )
+
+ [...]
+ 14. For each result in results, do
+ a. Let nCaptures be ? LengthOfArrayLike(result).
+ [...]
+features: [Symbol.replace]
+---*/
+
+var r = /./;
+var coercibleIndex = {
+ length: {
+ valueOf: function() {
+ return 3.9;
+ },
+ },
+ 0: '',
+ 1: 'foo',
+ 2: 'bar',
+ 3: 'baz',
+ index: 0,
+};
+r.exec = function() {
+ return coercibleIndex;
+};
+
+assert.sameValue(r[Symbol.replace]('', '$1$2$3'), 'foobar$3');
+
+reportCompare(0, 0);