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