Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --harmony-regexps | |
| 6 | |
| 7 delete RegExp.prototype.flags; | |
| 8 RegExp.prototype.flags = 'setter should be undefined'; | |
| 9 | |
| 10 assertEquals('', RegExp('').flags); | |
| 11 assertEquals('', /./.flags); | |
| 12 assertEquals('gimy', RegExp('', 'ygmi').flags); | |
| 13 assertEquals('gimy', /foo/ymig.flags); | |
| 14 | |
| 15 // When support for the `u` flag is added, uncomment the first line below and | |
|
Dmitry Lomov (no reviews)
2014/12/10 16:04:44
Please add a TODO here. Feel free to put me as an
| |
| 16 // remove the second line. | |
| 17 //assertEquals(RegExp('', 'yumig').flags, 'gimuy'); | |
| 18 assertThrows(function() { RegExp('', 'yumig').flags; }, SyntaxError); | |
| 19 | |
| 20 var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags'); | |
| 21 assertFalse(descriptor.configurable); | |
| 22 assertFalse(descriptor.enumerable); | |
| 23 assertInstanceof(descriptor.get, Function); | |
| 24 assertEquals(undefined, descriptor.set); | |
| 25 | |
| 26 function testGenericFlags(object) { | |
| 27 return descriptor.get.call(object); | |
| 28 } | |
| 29 | |
| 30 assertEquals('', testGenericFlags({})); | |
| 31 assertEquals('i', testGenericFlags({ ignoreCase: true })); | |
| 32 assertEquals('uy', testGenericFlags({ global: 0, sticky: 1, unicode: 1 })); | |
| 33 assertEquals('m', testGenericFlags({ __proto__: { multiline: true } })); | |
| 34 assertThrows(function() { testGenericFlags(); }, TypeError); | |
| 35 assertThrows(function() { testGenericFlags(undefined); }, TypeError); | |
| 36 assertThrows(function() { testGenericFlags(null); }, TypeError); | |
| 37 assertThrows(function() { testGenericFlags(true); }, TypeError); | |
| 38 assertThrows(function() { testGenericFlags(false); }, TypeError); | |
| 39 assertThrows(function() { testGenericFlags(''); }, TypeError); | |
| 40 assertThrows(function() { testGenericFlags(42); }, TypeError); | |
| OLD | NEW |