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 | |
|
Dmitry Lomov (no reviews)
2014/12/09 23:39:13
Also add test that validates properties of Regexp.
| |
| 6 | |
| 7 assertEquals('', RegExp.prototype.flags); | |
|
arv (Not doing code reviews)
2014/12/10 02:54:50
Shouldn't this throw since the prototype object do
| |
| 8 RegExp.prototype.flags = 'foo'; | |
|
arv (Not doing code reviews)
2014/12/10 02:54:50
A better test is to get the descriptor and validat
| |
| 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); | |
|
mathias
2014/12/09 23:26:22
Nit: +2 indent
Will fix in the next patch, along
| |
| 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 |