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

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

Issue 1838563003: Remove --harmony-regexps flag (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months 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 | « test/mjsunit/es6/no-unicode-regexp-flag.js ('k') | test/mjsunit/es6/regexp-sticky.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-regexps --harmony-unicode-regexps 5 // Flags: --harmony-unicode-regexps
6 6
7 var r1 = /abc/gi; 7 var r1 = /abc/gi;
8 assertEquals("abc", r1.source); 8 assertEquals("abc", r1.source);
9 assertTrue(r1.global); 9 assertTrue(r1.global);
10 assertTrue(r1.ignoreCase); 10 assertTrue(r1.ignoreCase);
11 assertFalse(r1.multiline); 11 assertFalse(r1.multiline);
12 assertFalse(r1.sticky); 12 assertFalse(r1.sticky);
13 assertFalse(r1.unicode); 13 assertFalse(r1.unicode);
14 14
15 // Internal slot of prototype is not read. 15 // Internal slot of prototype is not read.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 "get " + name, 57 "get " + name,
58 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name); 58 Object.getOwnPropertyDescriptor(RegExp.prototype, name).get.name);
59 } 59 }
60 60
61 testName("global"); 61 testName("global");
62 testName("ignoreCase"); 62 testName("ignoreCase");
63 testName("multiline"); 63 testName("multiline");
64 testName("source"); 64 testName("source");
65 testName("sticky"); 65 testName("sticky");
66 testName("unicode"); 66 testName("unicode");
67
68
69 RegExp.prototype.flags = 'setter should be undefined';
70
71 assertEquals('', RegExp('').flags);
72 assertEquals('', /./.flags);
73 assertEquals('gimuy', RegExp('', 'yugmi').flags);
74 assertEquals('gimuy', /foo/yumig.flags);
75
76 var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
77 assertTrue(descriptor.configurable);
78 assertFalse(descriptor.enumerable);
79 assertInstanceof(descriptor.get, Function);
80 assertEquals(undefined, descriptor.set);
81
82 function testGenericFlags(object) {
83 return descriptor.get.call(object);
84 }
85
86 assertEquals('', testGenericFlags({}));
87 assertEquals('i', testGenericFlags({ ignoreCase: true }));
88 assertEquals('uy', testGenericFlags({ global: 0, sticky: 1, unicode: 1 }));
89 assertEquals('m', testGenericFlags({ __proto__: { multiline: true } }));
90 assertThrows(function() { testGenericFlags(); }, TypeError);
91 assertThrows(function() { testGenericFlags(undefined); }, TypeError);
92 assertThrows(function() { testGenericFlags(null); }, TypeError);
93 assertThrows(function() { testGenericFlags(true); }, TypeError);
94 assertThrows(function() { testGenericFlags(false); }, TypeError);
95 assertThrows(function() { testGenericFlags(''); }, TypeError);
96 assertThrows(function() { testGenericFlags(42); }, TypeError);
97
98 var counter = 0;
99 var map = {};
100 var object = {
101 get global() {
102 map.g = counter++;
103 },
104 get ignoreCase() {
105 map.i = counter++;
106 },
107 get multiline() {
108 map.m = counter++;
109 },
110 get unicode() {
111 map.u = counter++;
112 },
113 get sticky() {
114 map.y = counter++;
115 }
116 };
117 testGenericFlags(object);
118 assertEquals({ g: 0, i: 1, m: 2, u: 3, y: 4 }, map);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/no-unicode-regexp-flag.js ('k') | test/mjsunit/es6/regexp-sticky.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698