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