1// 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
5var pattern = {
6  [Symbol.replace]: (string, newValue) => string + newValue
7};
8// Check object coercible fails.
9assertThrows(() => String.prototype.replace.call(null, pattern, "x"),
10             TypeError);
11// Override is called.
12assertEquals("abcdex", "abcde".replace(pattern, "x"));
13// Non-callable override.
14pattern[Symbol.replace] = "dumdidum";
15assertThrows(() => "abcde".replace(pattern, "x"), TypeError);
16
17assertEquals("[Symbol.replace]", RegExp.prototype[Symbol.replace].name);
18