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 assertEquals('', RegExp.prototype.flags); |
| 8 RegExp.prototype.flags = 'foo'; |
| 9 assertEquals('', RegExp.prototype.flags); |
| 10 delete RegExp.prototype.flags; |
| 11 assertEquals('', RegExp.prototype.flags); |
| 12 |
| 13 assertEquals('', RegExp('').flags); |
| 14 assertEquals('', /./.flags); |
| 15 assertEquals('gimy', RegExp('', 'ygmi').flags); |
| 16 assertEquals('gimy', /foo/ymig.flags); |
| 17 |
| 18 // When support for the `u` flag is added, uncomment the first line below and |
| 19 // remove the second line. |
| 20 //assertEquals(RegExp('', 'yumig').flags, 'gimuy'); |
| 21 assertThrows(function() { RegExp('', 'yumig').flags; }, SyntaxError); |
| 22 |
| 23 // https://bugzilla.mozilla.org/show_bug.cgi?id=1108467#c0 |
| 24 function testGenericFlags(object) { |
| 25 return Object |
| 26 .getOwnPropertyDescriptor(RegExp.prototype, 'flags') |
| 27 .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 |