blob: cbdf33d6922fe31a77e9c8851fc7de324b783085 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00005var 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);