OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 |
| 5 // Flags: --harmony-regexp-subclass |
| 6 |
| 7 function createNonRegExp(calls) { |
| 8 return { |
| 9 get [Symbol.match]() { |
| 10 calls.push("@@match"); |
| 11 return undefined; |
| 12 }, |
| 13 get [Symbol.replace]() { |
| 14 calls.push("@@replace"); |
| 15 return undefined; |
| 16 }, |
| 17 get [Symbol.search]() { |
| 18 calls.push("@@search"); |
| 19 return undefined; |
| 20 }, |
| 21 get [Symbol.split]() { |
| 22 calls.push("@@split"); |
| 23 return undefined; |
| 24 }, |
| 25 [Symbol.toPrimitive]() { |
| 26 calls.push("@@toPrimitive"); |
| 27 return ""; |
| 28 } |
| 29 }; |
| 30 } |
| 31 |
| 32 (function testStringMatchBrandCheck() { |
| 33 var calls = []; |
| 34 "".match(createNonRegExp(calls)); |
| 35 assertEquals(["@@match", "@@toPrimitive"], calls); |
| 36 })(); |
| 37 |
| 38 (function testStringSearchBrandCheck() { |
| 39 var calls = []; |
| 40 "".search(createNonRegExp(calls)); |
| 41 assertEquals(["@@search", "@@toPrimitive"], calls); |
| 42 })(); |
| 43 |
| 44 (function testStringSplitBrandCheck() { |
| 45 var calls = []; |
| 46 "".split(createNonRegExp(calls)); |
| 47 assertEquals(["@@split", "@@toPrimitive"], calls); |
| 48 })(); |
| 49 |
| 50 (function testStringReplaceBrandCheck() { |
| 51 var calls = []; |
| 52 "".replace(createNonRegExp(calls), ""); |
| 53 assertEquals(["@@replace", "@@toPrimitive"], calls); |
| 54 })(); |
OLD | NEW |