| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // 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 | 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-unicode-regexps | 5 // Flags: --harmony-unicode-regexps |
| 6 | 6 |
| 7 var r1 = /abc/gi; | 7 var r1 = /abc/gi; |
| 8 assertEquals("abc", r1.source); | 8 assertEquals("abc", r1.source); |
| 9 assertTrue(r1.global); | 9 assertTrue(r1.global); |
| 10 assertTrue(r1.ignoreCase); | 10 assertTrue(r1.ignoreCase); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 get: function() { get_count++; return true; } | 37 get: function() { get_count++; return true; } |
| 38 }); | 38 }); |
| 39 | 39 |
| 40 assertTrue(r3.global); | 40 assertTrue(r3.global); |
| 41 assertEquals(1, get_count); | 41 assertEquals(1, get_count); |
| 42 assertTrue(r3.ignoreCase); | 42 assertTrue(r3.ignoreCase); |
| 43 assertEquals(2, get_count); | 43 assertEquals(2, get_count); |
| 44 // Overridden flag getters affects the flags getter. | 44 // Overridden flag getters affects the flags getter. |
| 45 assertEquals("gi", r3.flags); | 45 assertEquals("gi", r3.flags); |
| 46 assertEquals(4, get_count); | 46 assertEquals(4, get_count); |
| 47 // Overridden flag getters affect string.replace | 47 // Overridden flag getters do not affect the internal flags. |
| 48 // TODO(adamk): Add more tests here once we've switched | |
| 49 // to use [[OriginalFlags]] in more cases. | |
| 50 assertEquals(expected, string.replace(r3, "X")); | 48 assertEquals(expected, string.replace(r3, "X")); |
| 51 assertEquals(5, get_count); | 49 assertEquals(4, get_count); |
| 52 | 50 |
| 53 | 51 |
| 54 function testName(name) { | 52 function testName(name) { |
| 55 // TODO(littledan): For web compatibility, we don't throw an exception, | 53 // TODO(littledan): For web compatibility, we don't throw an exception, |
| 56 // but ES2015 expects an exception to be thrown from this getter. | 54 // but ES2015 expects an exception to be thrown from this getter. |
| 57 if (name === "source") { | 55 if (name === "source") { |
| 58 assertThrows(() => RegExp.prototype[name], TypeError); | 56 assertThrows(() => RegExp.prototype[name], TypeError); |
| 59 } else { | 57 } else { |
| 60 assertEquals(undefined, RegExp.prototype[name]); | 58 assertEquals(undefined, RegExp.prototype[name]); |
| 61 } | 59 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 }, | 113 }, |
| 116 get unicode() { | 114 get unicode() { |
| 117 map.u = counter++; | 115 map.u = counter++; |
| 118 }, | 116 }, |
| 119 get sticky() { | 117 get sticky() { |
| 120 map.y = counter++; | 118 map.y = counter++; |
| 121 } | 119 } |
| 122 }; | 120 }; |
| 123 testGenericFlags(object); | 121 testGenericFlags(object); |
| 124 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); | 122 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); |
| OLD | NEW |