Index: test/mjsunit/harmony/regexp-flags.js |
diff --git a/test/mjsunit/harmony/regexp-flags.js b/test/mjsunit/harmony/regexp-flags.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dcfaa67a0c8996fbb9b0e14b02886601c3126fa7 |
--- /dev/null |
+++ b/test/mjsunit/harmony/regexp-flags.js |
@@ -0,0 +1,40 @@ |
+// Copyright 2014 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --harmony-regexps |
Dmitry Lomov (no reviews)
2014/12/09 23:39:13
Also add test that validates properties of Regexp.
|
+ |
+assertEquals('', RegExp.prototype.flags); |
arv (Not doing code reviews)
2014/12/10 02:54:50
Shouldn't this throw since the prototype object do
|
+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
|
+assertEquals('', RegExp.prototype.flags); |
+delete RegExp.prototype.flags; |
+assertEquals('', RegExp.prototype.flags); |
+ |
+assertEquals('', RegExp('').flags); |
+assertEquals('', /./.flags); |
+assertEquals('gimy', RegExp('', 'ygmi').flags); |
+assertEquals('gimy', /foo/ymig.flags); |
+ |
+// When support for the `u` flag is added, uncomment the first line below and |
+// remove the second line. |
+//assertEquals(RegExp('', 'yumig').flags, 'gimuy'); |
+assertThrows(function() { RegExp('', 'yumig').flags; }, SyntaxError); |
+ |
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1108467#c0 |
+function testGenericFlags(object) { |
+ return Object |
+ .getOwnPropertyDescriptor(RegExp.prototype, 'flags') |
+ .get.call(object); |
mathias
2014/12/09 23:26:22
Nit: +2 indent
Will fix in the next patch, along
|
+} |
+ |
+assertEquals('', testGenericFlags({})); |
+assertEquals('i', testGenericFlags({ ignoreCase: true })); |
+assertEquals('uy', testGenericFlags({ global: 0, sticky: 1, unicode: 1 })); |
+assertEquals('m', testGenericFlags({ __proto__: { multiline: true } })); |
+assertThrows(function() { testGenericFlags(); }, TypeError); |
+assertThrows(function() { testGenericFlags(undefined); }, TypeError); |
+assertThrows(function() { testGenericFlags(null); }, TypeError); |
+assertThrows(function() { testGenericFlags(true); }, TypeError); |
+assertThrows(function() { testGenericFlags(false); }, TypeError); |
+assertThrows(function() { testGenericFlags(''); }, TypeError); |
+assertThrows(function() { testGenericFlags(42); }, TypeError); |