OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-regexp-subclass | |
6 | |
7 function createNonRegExp(calls) { | 5 function createNonRegExp(calls) { |
8 return { | 6 return { |
9 get [Symbol.match]() { | 7 get [Symbol.match]() { |
10 calls.push("@@match"); | 8 calls.push("@@match"); |
11 return undefined; | 9 return undefined; |
12 }, | 10 }, |
13 get [Symbol.replace]() { | 11 get [Symbol.replace]() { |
14 calls.push("@@replace"); | 12 calls.push("@@replace"); |
15 return undefined; | 13 return undefined; |
16 }, | 14 }, |
(...skipping 28 matching lines...) Expand all Loading... |
45 var calls = []; | 43 var calls = []; |
46 "".split(createNonRegExp(calls)); | 44 "".split(createNonRegExp(calls)); |
47 assertEquals(["@@split", "@@toPrimitive"], calls); | 45 assertEquals(["@@split", "@@toPrimitive"], calls); |
48 })(); | 46 })(); |
49 | 47 |
50 (function testStringReplaceBrandCheck() { | 48 (function testStringReplaceBrandCheck() { |
51 var calls = []; | 49 var calls = []; |
52 "".replace(createNonRegExp(calls), ""); | 50 "".replace(createNonRegExp(calls), ""); |
53 assertEquals(["@@replace", "@@toPrimitive"], calls); | 51 assertEquals(["@@replace", "@@toPrimitive"], calls); |
54 })(); | 52 })(); |
OLD | NEW |