1 // Copyright (C) 2018 Peter Wong. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
6 Verify ToString is called when regexp[@@matchAll] is undefined or null
8 String.prototype.matchAll ( regexp )
9 1. Let O be ? RequireObjectCoercible(this value).
10 2. If regexp is neither undefined nor null, then
11 a. Let matcher be ? GetMethod(regexp, @@matchAll).
12 b. If matcher is not undefined, then
14 3. Let S be ? ToString(O).
15 4. Let rx be ? RegExpCreate(R, "g").
16 5. Return ? Invoke(rx, @@matchAll, « S »).
17 features: [Symbol.matchAll, String.prototype.matchAll]
24 var toStringResult = 'abc';
26 [Symbol.toPrimitive]: function() {
28 return toStringResult;
31 RegExp.prototype[Symbol.matchAll] = function(string) {
35 String.prototype.matchAll.call(receiver, null);
36 assert.sameValue(callCount, 1);
37 assert.sameValue(arg, toStringResult);
39 String.prototype.matchAll.call(receiver, undefined);
40 assert.sameValue(callCount, 2);
41 assert.sameValue(arg, toStringResult);