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 // TODO(jgruber): This exact case actually causes an infinite loop in the spec | 48 assertEquals(expected, string.replace(r3, "X")); |
49 // (@@replace sees global = true while BuiltinExec sees global = false). | 49 assertEquals(5, get_count); |
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); | |
54 | 50 |
55 | 51 |
56 function testName(name) { | 52 function testName(name) { |
57 // Test for ES2017 RegExp web compatibility semantics | 53 // Test for ES2017 RegExp web compatibility semantics |
58 // https://github.com/tc39/ecma262/pull/511 | 54 // https://github.com/tc39/ecma262/pull/511 |
59 assertEquals(name === "source" ? "(?:)" : undefined, | 55 assertEquals(name === "source" ? "(?:)" : undefined, |
60 RegExp.prototype[name]); | 56 RegExp.prototype[name]); |
61 assertEquals( | 57 assertEquals( |
62 "get " + name, | 58 "get " + name, |
63 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); | 59 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 }, | 110 }, |
115 get unicode() { | 111 get unicode() { |
116 map.u = counter++; | 112 map.u = counter++; |
117 }, | 113 }, |
118 get sticky() { | 114 get sticky() { |
119 map.y = counter++; | 115 map.y = counter++; |
120 } | 116 } |
121 }; | 117 }; |
122 testGenericFlags(object); | 118 testGenericFlags(object); |
123 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); | 119 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); |
OLD | NEW |