Add String.prototype.replace test

This commit is contained in:
Alexey Shvayka 2020-05-08 18:33:11 +03:00 committed by Rick Waldron
parent a66fe41259
commit 6cce955d6d
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.replace
description: >
[[IsHTMLDDA]] object as @@replace method gets called.
info: |
String.prototype.replace ( searchValue, replaceValue )
[...]
2. If searchValue is neither undefined nor null, then
a. Let replacer be ? GetMethod(searchValue, @@replace).
b. If replacer is not undefined, then
i. Return ? Call(replacer, searchValue, « O, replaceValue »).
features: [Symbol.replace, IsHTMLDDA]
---*/
var searchValue = $262.IsHTMLDDA;
var replacerGets = 0;
Object.defineProperty(searchValue, Symbol.replace, {
get: function() {
replacerGets += 1;
return searchValue;
},
configurable: true,
});
assert.sameValue("".replace(searchValue), null);
assert.sameValue(replacerGets, 1);