| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 affect string.replace |
| 48 // TODO(adamk): Add more tests here once we've switched | 48 // TODO(adamk): Add more tests here once we've switched |
| 49 // to use [[OriginalFlags]] in more cases. | 49 // to use [[OriginalFlags]] in more cases. |
| 50 assertEquals(expected, string.replace(r3, "X")); | 50 assertEquals(expected, string.replace(r3, "X")); |
| 51 assertEquals(5, get_count); | 51 assertEquals(5, get_count); |
| 52 | 52 |
| 53 | 53 |
| 54 function testName(name) { | 54 function testName(name) { |
| 55 // TODO(littledan): For web compatibility, we don't throw an exception, | 55 // Test for ES2017 RegExp web compatibility semantics |
| 56 // but ES2015 expects an exception to be thrown from this getter. | 56 // https://github.com/tc39/ecma262/pull/511 |
| 57 assertEquals(undefined, RegExp.prototype[name]); | 57 assertEquals(name === "source" ? "(?:)" : undefined, |
| 58 RegExp.prototype[name]); |
| 58 assertEquals( | 59 assertEquals( |
| 59 "get " + name, | 60 "get " + name, |
| 60 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); | 61 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); |
| 61 } | 62 } |
| 62 | 63 |
| 63 testName("global"); | 64 testName("global"); |
| 64 testName("ignoreCase"); | 65 testName("ignoreCase"); |
| 65 testName("multiline"); | 66 testName("multiline"); |
| 66 testName("source"); | 67 testName("source"); |
| 67 testName("sticky"); | 68 testName("sticky"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 }, | 112 }, |
| 112 get unicode() { | 113 get unicode() { |
| 113 map.u = counter++; | 114 map.u = counter++; |
| 114 }, | 115 }, |
| 115 get sticky() { | 116 get sticky() { |
| 116 map.y = counter++; | 117 map.y = counter++; |
| 117 } | 118 } |
| 118 }; | 119 }; |
| 119 testGenericFlags(object); | 120 testGenericFlags(object); |
| 120 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); | 121 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); |
| OLD | NEW |