Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: test/mjsunit/harmony/regexp-flags.js

Issue 770333005: Implement the `RegExp.prototype.flags` getter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // TODO(dslomov): When support for the `u` flag is added, uncomment the first
16 // line below and 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);
OLDNEW
« no previous file with comments | « src/messages.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698