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 var r1 = /abc/gi; | 5 var r1 = /abc/gi; |
6 assertEquals("abc", r1.source); | 6 assertEquals("abc", r1.source); |
7 assertTrue(r1.global); | 7 assertTrue(r1.global); |
8 assertTrue(r1.ignoreCase); | 8 assertTrue(r1.ignoreCase); |
9 assertFalse(r1.multiline); | 9 assertFalse(r1.multiline); |
10 assertFalse(r1.sticky); | 10 assertFalse(r1.sticky); |
(...skipping 27 matching lines...) Expand all Loading... |
38 assertTrue(r3.global); | 38 assertTrue(r3.global); |
39 assertEquals(1, get_count); | 39 assertEquals(1, get_count); |
40 assertTrue(r3.ignoreCase); | 40 assertTrue(r3.ignoreCase); |
41 assertEquals(2, get_count); | 41 assertEquals(2, get_count); |
42 // Overridden flag getters affects the flags getter. | 42 // Overridden flag getters affects the flags getter. |
43 assertEquals("gi", r3.flags); | 43 assertEquals("gi", r3.flags); |
44 assertEquals(4, get_count); | 44 assertEquals(4, get_count); |
45 // Overridden flag getters affect string.replace | 45 // Overridden flag getters affect string.replace |
46 // TODO(adamk): Add more tests here once we've switched | 46 // TODO(adamk): Add more tests here once we've switched |
47 // to use [[OriginalFlags]] in more cases. | 47 // to use [[OriginalFlags]] in more cases. |
48 assertEquals(expected, string.replace(r3, "X")); | 48 // TODO(jgruber): This exact case actually causes an infinite loop in the spec |
49 assertEquals(5, get_count); | 49 // (@@replace sees global = true while BuiltinExec sees global = false). |
| 50 // Comment the test for now and remove / fix once this has been resolved on |
| 51 // the spec side. |
| 52 //assertEquals(expected, string.replace(r3, "X")); |
| 53 //assertEquals(5, get_count); |
50 | 54 |
51 | 55 |
52 function testName(name) { | 56 function testName(name) { |
53 // Test for ES2017 RegExp web compatibility semantics | 57 // Test for ES2017 RegExp web compatibility semantics |
54 // https://github.com/tc39/ecma262/pull/511 | 58 // https://github.com/tc39/ecma262/pull/511 |
55 assertEquals(name === "source" ? "(?:)" : undefined, | 59 assertEquals(name === "source" ? "(?:)" : undefined, |
56 RegExp.prototype[name]); | 60 RegExp.prototype[name]); |
57 assertEquals( | 61 assertEquals( |
58 "get " + name, | 62 "get " + name, |
59 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); | 63 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 }, | 114 }, |
111 get unicode() { | 115 get unicode() { |
112 map.u = counter++; | 116 map.u = counter++; |
113 }, | 117 }, |
114 get sticky() { | 118 get sticky() { |
115 map.y = counter++; | 119 map.y = counter++; |
116 } | 120 } |
117 }; | 121 }; |
118 testGenericFlags(object); | 122 testGenericFlags(object); |
119 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); | 123 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); |
OLD | NEW |