OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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-regexps | 5 // Flags: --harmony-regexps --harmony-unicode |
6 | 6 |
7 RegExp.prototype.flags = 'setter should be undefined'; | 7 RegExp.prototype.flags = 'setter should be undefined'; |
8 | 8 |
9 assertEquals('', RegExp('').flags); | 9 assertEquals('', RegExp('').flags); |
10 assertEquals('', /./.flags); | 10 assertEquals('', /./.flags); |
11 assertEquals('gimy', RegExp('', 'ygmi').flags); | 11 assertEquals('gimuy', RegExp('', 'yugmi').flags); |
12 assertEquals('gimy', /foo/ymig.flags); | 12 assertEquals('gimuy', /foo/yumig.flags); |
13 | |
14 // TODO(dslomov): When support for the `u` flag is added, uncomment the first | |
15 // line below and remove the second line. | |
16 //assertEquals(RegExp('', 'yumig').flags, 'gimuy'); | |
17 assertThrows(function() { RegExp('', 'yumig').flags; }, SyntaxError); | |
18 | 13 |
19 var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags'); | 14 var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags'); |
20 assertTrue(descriptor.configurable); | 15 assertTrue(descriptor.configurable); |
21 assertFalse(descriptor.enumerable); | 16 assertFalse(descriptor.enumerable); |
22 assertInstanceof(descriptor.get, Function); | 17 assertInstanceof(descriptor.get, Function); |
23 assertEquals(undefined, descriptor.set); | 18 assertEquals(undefined, descriptor.set); |
24 | 19 |
25 function testGenericFlags(object) { | 20 function testGenericFlags(object) { |
26 return descriptor.get.call(object); | 21 return descriptor.get.call(object); |
27 } | 22 } |
(...skipping 24 matching lines...) Expand all Loading... |
52 }, | 47 }, |
53 get unicode() { | 48 get unicode() { |
54 map.u = counter++; | 49 map.u = counter++; |
55 }, | 50 }, |
56 get sticky() { | 51 get sticky() { |
57 map.y = counter++; | 52 map.y = counter++; |
58 } | 53 } |
59 }; | 54 }; |
60 testGenericFlags(object); | 55 testGenericFlags(object); |
61 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); | 56 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map); |
OLD | NEW |