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