blob: 208c483fd07628a309a7098db682710611be81ea [file] [log] [blame]
Ben Murdoch109988c2016-05-18 11:27:45 +01001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --harmony-regexp-subclass
6
7var pattern = {
8 [Symbol.replace]: (string, newValue) => string + newValue
9};
10// Check object coercible fails.
11assertThrows(() => String.prototype.replace.call(null, pattern, "x"),
12 TypeError);
13// Override is called.
14assertEquals("abcdex", "abcde".replace(pattern, "x"));
15// Non-callable override.
16pattern[Symbol.replace] = "dumdidum";
17assertThrows(() => "abcde".replace(pattern, "x"), TypeError);
18
19assertEquals("[Symbol.replace]", RegExp.prototype[Symbol.replace].name);