OLD | NEW |
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: --strong-mode --allow-natives-syntax | 5 // Flags: --strong-mode --allow-natives-syntax |
6 // Flags: --harmony-arrow-functions --harmony-rest-parameters | 6 // Flags: --harmony-arrow-functions --harmony-rest-parameters |
7 // Flags: --harmony-destructuring | 7 // Flags: --harmony-destructuring --harmony-spread-arrays |
8 | 8 |
9 'use strict'; | 9 'use strict'; |
10 | 10 |
11 (function WeakObjectLiterals() { | 11 (function WeakObjectLiterals() { |
12 assertTrue(!%IsStrong({})); | 12 function assertWeakObject(x) { |
13 assertTrue(!%IsStrong({a: 0, b: 0})); | 13 assertFalse(%IsStrong(x)); |
14 assertTrue(!%IsStrong({a: [], b: {}})); | 14 assertSame(Object.prototype, Object.getPrototypeOf(x)); |
15 assertTrue(!%IsStrong({a: [], b: {}}.a)); | 15 } |
16 assertTrue(!%IsStrong({a: [], b: {}}.b)); | 16 assertWeakObject({}); |
17 assertTrue(!%IsStrong({a: {b: {c: {}}}}.a)); | 17 assertWeakObject({a: 0, b: 0}); |
18 assertTrue(!%IsStrong({a: {b: {c: {}}}}.a.b)); | 18 assertWeakObject({a: [], b: {}}); |
19 assertTrue(!%IsStrong({a: {b: {c: {}}}}.a.b.c)); | 19 assertWeakObject({a: [], b: {}}.b); |
20 assertTrue(!%IsStrong({f: function(){}})); | 20 assertWeakObject({a: {b: {c: {}}}}.a); |
21 assertTrue(!%IsStrong(Realm.eval(Realm.current(), | 21 assertWeakObject({a: {b: {c: {}}}}.a.b); |
22 "({f: function(){}})"))); | 22 assertWeakObject({a: {b: {c: {}}}}.a.b.c); |
| 23 assertWeakObject([[1], {}, [[3]]][1]); |
| 24 assertWeakObject({f: function(){}}); |
| 25 assertWeakObject( |
| 26 Realm.eval(Realm.current(), "({f: function(){}})")); |
23 })(); | 27 })(); |
24 | 28 |
25 (function StrongObjectLiterals() { | 29 (function StrongObjectLiterals() { |
26 'use strong'; | 30 'use strong'; |
27 assertTrue(%IsStrong({})); | 31 function assertStrongObject(x) { |
28 assertTrue(%IsStrong({a: 0, b: 0})); | 32 assertTrue(%IsStrong(x)); |
29 assertTrue(%IsStrong({a: [], b: {}})); | 33 // TODO(rossberg) |
30 assertTrue(%IsStrong({a: [], b: {}}.a)); | 34 // assertSame(Object.prototype, Object.getPrototypeOf(x)); |
31 assertTrue(%IsStrong({a: [], b: {}}.b)); | 35 } |
32 assertTrue(%IsStrong({a: {b: {c: {}}}}.a)); | 36 assertStrongObject({}); |
33 assertTrue(%IsStrong({a: {b: {c: {}}}}.a.b)); | 37 assertStrongObject({a: 0, b: 0}); |
34 assertTrue(%IsStrong({a: {b: {c: {}}}}.a.b.c)); | 38 assertStrongObject({a: [], b: {}}); |
| 39 assertStrongObject({a: [], b: {}}.b); |
| 40 assertStrongObject({a: {b: {c: {}}}}.a); |
| 41 assertStrongObject({a: {b: {c: {}}}}.a.b); |
| 42 assertStrongObject({a: {b: {c: {}}}}.a.b.c); |
35 // Maps for literals with too many properties are not cached. | 43 // Maps for literals with too many properties are not cached. |
36 assertTrue(%IsStrong({ | 44 assertStrongObject({ |
37 x001: 0, x002: 0, x003: 0, x004: 0, x005: 0, | 45 x001: 0, x002: 0, x003: 0, x004: 0, x005: 0, |
38 x006: 0, x007: 0, x008: 0, x009: 0, x010: 0, | 46 x006: 0, x007: 0, x008: 0, x009: 0, x010: 0, |
39 x011: 0, x012: 0, x013: 0, x014: 0, x015: 0, | 47 x011: 0, x012: 0, x013: 0, x014: 0, x015: 0, |
40 x016: 0, x017: 0, x018: 0, x019: 0, x020: 0, | 48 x016: 0, x017: 0, x018: 0, x019: 0, x020: 0, |
41 x021: 0, x022: 0, x023: 0, x024: 0, x025: 0, | 49 x021: 0, x022: 0, x023: 0, x024: 0, x025: 0, |
42 x026: 0, x027: 0, x028: 0, x029: 0, x030: 0, | 50 x026: 0, x027: 0, x028: 0, x029: 0, x030: 0, |
43 x031: 0, x032: 0, x033: 0, x034: 0, x035: 0, | 51 x031: 0, x032: 0, x033: 0, x034: 0, x035: 0, |
44 x036: 0, x037: 0, x038: 0, x039: 0, x040: 0, | 52 x036: 0, x037: 0, x038: 0, x039: 0, x040: 0, |
45 x041: 0, x042: 0, x043: 0, x044: 0, x045: 0, | 53 x041: 0, x042: 0, x043: 0, x044: 0, x045: 0, |
46 x046: 0, x047: 0, x048: 0, x049: 0, x050: 0, | 54 x046: 0, x047: 0, x048: 0, x049: 0, x050: 0, |
(...skipping 20 matching lines...) Expand all Loading... |
67 x151: 0, x152: 0, x153: 0, x154: 0, x155: 0, | 75 x151: 0, x152: 0, x153: 0, x154: 0, x155: 0, |
68 x156: 0, x157: 0, x158: 0, x159: 0, x160: 0, | 76 x156: 0, x157: 0, x158: 0, x159: 0, x160: 0, |
69 x161: 0, x162: 0, x163: 0, x164: 0, x165: 0, | 77 x161: 0, x162: 0, x163: 0, x164: 0, x165: 0, |
70 x166: 0, x167: 0, x168: 0, x169: 0, x170: 0, | 78 x166: 0, x167: 0, x168: 0, x169: 0, x170: 0, |
71 x171: 0, x172: 0, x173: 0, x174: 0, x175: 0, | 79 x171: 0, x172: 0, x173: 0, x174: 0, x175: 0, |
72 x176: 0, x177: 0, x178: 0, x179: 0, x180: 0, | 80 x176: 0, x177: 0, x178: 0, x179: 0, x180: 0, |
73 x181: 0, x182: 0, x183: 0, x184: 0, x185: 0, | 81 x181: 0, x182: 0, x183: 0, x184: 0, x185: 0, |
74 x186: 0, x187: 0, x188: 0, x189: 0, x190: 0, | 82 x186: 0, x187: 0, x188: 0, x189: 0, x190: 0, |
75 x191: 0, x192: 0, x193: 0, x194: 0, x195: 0, | 83 x191: 0, x192: 0, x193: 0, x194: 0, x195: 0, |
76 x196: 0, x197: 0, x198: 0, x199: 0, x200: 0, | 84 x196: 0, x197: 0, x198: 0, x199: 0, x200: 0, |
77 })); | 85 }); |
78 assertTrue(%IsStrong({__proto__: {}, get a() {}, set b(x) {}})); | 86 assertStrongObject([[1], {}, [[3]]][1]); |
79 assertTrue(%IsStrong({[Date() + ""]: 0, [Symbol()]: 0})); | 87 assertStrongObject({__proto__: {}, get a() {}, set b(x) {}}); |
80 assertTrue(%IsStrong({m() { super.m() }})); | 88 assertStrongObject({[Date() + ""]: 0, [Symbol()]: 0}); |
| 89 assertStrongObject({m() { super.m() }}); |
81 // Object literals with constant functions are treated specially, | 90 // Object literals with constant functions are treated specially, |
82 // but currently only on the toplevel (using Realm.eval to emulate that). | 91 // but currently only on the toplevel (using Realm.eval to emulate that). |
83 assertTrue(%IsStrong({f: function(){}})); | 92 assertStrongObject({f: function(){}}); |
84 assertTrue(%IsStrong(Realm.eval(Realm.current(), | 93 assertStrongObject( |
85 "'use strong'; ({f: function(){}})"))); | 94 Realm.eval(Realm.current(), "'use strong'; ({f: function(){}})")); |
86 })(); | 95 })(); |
87 | 96 |
88 (function WeakArrayLiterals(...args) { | 97 (function WeakArrayLiterals(...args) { |
| 98 function assertWeakArray(x) { |
| 99 assertFalse(%IsStrong(x)); |
| 100 assertSame(Array.prototype, Object.getPrototypeOf(x)); |
| 101 } |
89 let [...r] = []; | 102 let [...r] = []; |
90 assertTrue(!%IsStrong(args)); | 103 assertWeakArray(args); |
91 assertTrue(!%IsStrong(r)); | 104 assertWeakArray(r); |
92 assertTrue(!%IsStrong([])); | 105 assertWeakArray([]); |
93 assertTrue(!%IsStrong([1, 2, 3])); | 106 assertWeakArray([1, 2, 3]); |
94 assertTrue(!%IsStrong([[[]]])); | 107 assertWeakArray([1, 2, ...[3, 4], 5]); |
95 assertTrue(!%IsStrong([[1], {}, [[3]]])); | 108 assertWeakArray([[[]]]); |
96 assertTrue(!%IsStrong([[1], {}, [[3]]][0])); | 109 assertWeakArray([[1], {}, [[3]]]); |
97 assertTrue(!%IsStrong([[1], {}, [[3]]][1])); | 110 assertWeakArray([[1], {}, [[3]]][0]); |
98 assertTrue(!%IsStrong([[1], {}, [[3]]][2])); | 111 assertWeakArray([[1], {}, [[3]]][2]); |
99 assertTrue(!%IsStrong([[1], {}, [[3]]][2][0])); | 112 assertWeakArray([[1], {}, [[3]]][2][0]); |
| 113 assertWeakArray({a: [], b: {}}.a); |
100 })(); | 114 })(); |
101 | 115 |
102 (function StrongArrayLiterals(...args) { | 116 (function StrongArrayLiterals(...args) { |
103 'use strong'; | 117 'use strong'; |
| 118 function assertStrongArray(x) { |
| 119 assertTrue(%IsStrong(x)); |
| 120 assertSame(Array.prototype, Object.getPrototypeOf(x)); |
| 121 } |
104 let [...r] = []; | 122 let [...r] = []; |
105 // TODO(rossberg): teach strongness to FastCloneShallowArrayStub | 123 assertStrongArray(args); |
106 // assertTrue(%IsStrong(args)); | 124 assertStrongArray(r); |
107 // assertTrue(%IsStrong(r)); | 125 assertStrongArray([]); |
108 // assertTrue(%IsStrong([])); | 126 assertStrongArray([1, 2, 3]); |
109 // assertTrue(%IsStrong([1, 2, 3])); | 127 assertStrongArray([1, 2, ...[3, 4], 5]); |
110 // assertTrue(%IsStrong([1, 2, ...[3, 4], 5])); | 128 assertStrongArray([[[]]]); |
111 assertTrue(%IsStrong([[[]]])); | 129 assertStrongArray([[1], {}, [[3]]]); |
112 assertTrue(%IsStrong([[1], {}, [[3]]])); | 130 assertStrongArray([[1], {}, [[3]]][0]); |
113 assertTrue(%IsStrong([[1], {}, [[3]]][0])); | 131 assertStrongArray([[1], {}, [[3]]][2]); |
114 assertTrue(%IsStrong([[1], {}, [[3]]][1])); | 132 assertStrongArray([[1], {}, [[3]]][2][0]); |
115 assertTrue(%IsStrong([[1], {}, [[3]]][2])); | 133 assertStrongArray({a: [], b: {}}.a); |
116 assertTrue(%IsStrong([[1], {}, [[3]]][2][0])); | |
117 })(); | 134 })(); |
118 | 135 |
119 (function WeakFunctionLiterals() { | 136 (function WeakFunctionLiterals() { |
| 137 function assertWeakFunction(x) { |
| 138 assertFalse(%IsStrong(x)); |
| 139 assertFalse(%IsStrong(x.prototype)); |
| 140 assertSame(Function.prototype, Object.getPrototypeOf(x)); |
| 141 } |
120 function f() {} | 142 function f() {} |
121 assertTrue(!%IsStrong(f)); | 143 assertWeakFunction(f); |
122 assertTrue(!%IsStrong(function(){})); | 144 assertWeakFunction(function(){}); |
123 assertTrue(!%IsStrong(function f(){})); | 145 assertWeakFunction(function f(){}); |
124 assertTrue(!%IsStrong(() => {})); | 146 assertWeakFunction(() => {}); |
125 assertTrue(!%IsStrong(x => x)); | 147 assertWeakFunction(x => x); |
126 assertTrue(!%IsStrong({m(){}}.m)); | 148 assertWeakFunction({m(){}}.m); |
127 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( | 149 assertWeakFunction(Object.getOwnPropertyDescriptor( |
128 {get a(){}}, 'a').get)); | 150 {get a(){}}, 'a').get); |
129 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( | 151 assertWeakFunction(Object.getOwnPropertyDescriptor( |
130 {set a(x){}}, 'a').set)); | 152 {set a(x){}}, 'a').set); |
131 assertTrue(!%IsStrong((class {static m(){}}).m)); | 153 assertWeakFunction((class {static m(){}}).m); |
132 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( | 154 assertWeakFunction(Object.getOwnPropertyDescriptor( |
133 class {static get a(){}}, 'a').get)); | 155 class {static get a(){}}, 'a').get); |
134 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( | 156 assertWeakFunction(Object.getOwnPropertyDescriptor( |
135 class {static set a(x){}}, 'a').set)); | 157 class {static set a(x){}}, 'a').set); |
136 assertTrue(!%IsStrong((new class {m(){}}).m)); | 158 assertWeakFunction((new class {m(){}}).m); |
137 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( | 159 assertWeakFunction(Object.getOwnPropertyDescriptor( |
138 (class {get a(){}}).prototype, 'a').get)); | 160 (class {get a(){}}).prototype, 'a').get); |
139 assertTrue(!%IsStrong(Object.getOwnPropertyDescriptor( | 161 assertWeakFunction(Object.getOwnPropertyDescriptor( |
140 (class {set a(x){}}).prototype, 'a').set)); | 162 (class {set a(x){}}).prototype, 'a').set); |
141 })(); | 163 })(); |
142 | 164 |
143 (function StrongFunctionLiterals() { | 165 (function StrongFunctionLiterals() { |
144 'use strong'; | 166 'use strong'; |
| 167 function assertStrongFunction(x) { |
| 168 assertTrue(%IsStrong(x)); |
| 169 assertFalse('prototype' in x); |
| 170 assertSame(Function.prototype, Object.getPrototypeOf(x)); |
| 171 } |
145 function f() {} | 172 function f() {} |
146 assertTrue(%IsStrong(f)); | 173 assertStrongFunction(f); |
147 assertTrue(%IsStrong(function(){})); | 174 assertStrongFunction(function(){}); |
148 assertTrue(%IsStrong(function f(){})); | 175 assertStrongFunction(function f(){}); |
149 assertTrue(%IsStrong(() => {})); | 176 assertStrongFunction(() => {}); |
150 assertTrue(%IsStrong(x => x)); | 177 assertStrongFunction(x => x); |
151 assertTrue(%IsStrong({m(){}}.m)); | 178 assertStrongFunction({m(){}}.m); |
152 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 179 assertStrongFunction(Object.getOwnPropertyDescriptor( |
153 {get a(){}}, 'a').get)); | 180 {get a(){}}, 'a').get); |
154 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 181 assertStrongFunction(Object.getOwnPropertyDescriptor( |
155 {set a(x){}}, 'a').set)); | 182 {set a(x){}}, 'a').set); |
156 assertTrue(%IsStrong((class {static m(){}}).m)); | 183 assertStrongFunction((class {static m(){}}).m); |
157 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 184 assertStrongFunction(Object.getOwnPropertyDescriptor( |
158 class {static get a(){}}, 'a').get)); | 185 class {static get a(){}}, 'a').get); |
159 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 186 assertStrongFunction(Object.getOwnPropertyDescriptor( |
160 class {static set a(x){}}, 'a').set)); | 187 class {static set a(x){}}, 'a').set); |
161 assertTrue(%IsStrong((new class {m(){}}).m)); | 188 assertStrongFunction((new class {m(){}}).m); |
162 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 189 assertStrongFunction(Object.getOwnPropertyDescriptor( |
163 (class {get a(){}}).prototype, 'a').get)); | 190 (class {get a(){}}).prototype, 'a').get); |
164 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 191 assertStrongFunction(Object.getOwnPropertyDescriptor( |
165 (class {set a(x){}}).prototype, 'a').set)); | 192 (class {set a(x){}}).prototype, 'a').set); |
166 })(); | 193 })(); |
167 | 194 |
168 (function SelfStrongFunctionLiterals() { | 195 (function SelfStrongFunctionLiterals() { |
| 196 function assertStrongFunction(x) { |
| 197 assertTrue(%IsStrong(x)); |
| 198 assertFalse('prototype' in x); |
| 199 assertSame(Function.prototype, Object.getPrototypeOf(x)); |
| 200 } |
169 function f() {'use strong'} | 201 function f() {'use strong'} |
170 assertTrue(%IsStrong(f)); | 202 assertStrongFunction(f); |
171 assertTrue(%IsStrong(function(){'use strong'})); | 203 assertStrongFunction(function(){'use strong'}); |
172 assertTrue(%IsStrong(function f(){'use strong'})); | 204 assertStrongFunction(function f(){'use strong'}); |
173 assertTrue(%IsStrong(() => {'use strong'})); | 205 assertStrongFunction(() => {'use strong'}); |
174 assertTrue(%IsStrong(x => {'use strong'})); | 206 assertStrongFunction(x => {'use strong'}); |
175 assertTrue(%IsStrong({m(){'use strong'}}.m)); | 207 assertStrongFunction({m(){'use strong'}}.m); |
176 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 208 assertStrongFunction(Object.getOwnPropertyDescriptor( |
177 {get a(){'use strong'}}, 'a').get)); | 209 {get a(){'use strong'}}, 'a').get); |
178 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 210 assertStrongFunction(Object.getOwnPropertyDescriptor( |
179 {set a(x){'use strong'}}, 'a').set)); | 211 {set a(x){'use strong'}}, 'a').set); |
180 assertTrue(%IsStrong((class {static m(){'use strong'}}).m)); | 212 assertStrongFunction((class {static m(){'use strong'}}).m); |
181 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 213 assertStrongFunction(Object.getOwnPropertyDescriptor( |
182 class {static get a(){'use strong'}}, 'a').get)); | 214 class {static get a(){'use strong'}}, 'a').get); |
183 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 215 assertStrongFunction(Object.getOwnPropertyDescriptor( |
184 class {static set a(x){'use strong'}}, 'a').set)); | 216 class {static set a(x){'use strong'}}, 'a').set); |
185 assertTrue(%IsStrong((new class {m(){'use strong'}}).m)); | 217 assertStrongFunction((new class {m(){'use strong'}}).m); |
186 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 218 assertStrongFunction(Object.getOwnPropertyDescriptor( |
187 (class {get a(){'use strong'}}).prototype, 'a').get)); | 219 (class {get a(){'use strong'}}).prototype, 'a').get); |
188 assertTrue(%IsStrong(Object.getOwnPropertyDescriptor( | 220 assertStrongFunction(Object.getOwnPropertyDescriptor( |
189 (class {set a(x){'use strong'}}).prototype, 'a').set)); | 221 (class {set a(x){'use strong'}}).prototype, 'a').set); |
190 })(); | 222 })(); |
| 223 |
| 224 let GeneratorPrototype = (function*(){}).__proto__; |
191 | 225 |
192 (function WeakGeneratorLiterals() { | 226 (function WeakGeneratorLiterals() { |
| 227 function assertWeakGenerator(x) { |
| 228 assertFalse(%IsStrong(x)); |
| 229 assertFalse(%IsStrong(x.prototype)); |
| 230 assertSame(GeneratorPrototype, Object.getPrototypeOf(x)); |
| 231 assertFalse(%IsStrong(x())); |
| 232 } |
193 function* g() {} | 233 function* g() {} |
194 assertTrue(!%IsStrong(g)); | 234 assertWeakGenerator(g); |
195 assertTrue(!%IsStrong(function*(){})); | 235 assertWeakGenerator(function*(){}); |
196 assertTrue(!%IsStrong(function* g(){})); | 236 assertWeakGenerator(function* g(){}); |
197 assertTrue(!%IsStrong({*m(){}}.m)); | 237 assertWeakGenerator({*m(){}}.m); |
198 assertTrue(!%IsStrong((class {static *m(){}}).m)); | 238 assertWeakGenerator((class {static *m(){}}).m); |
199 assertTrue(!%IsStrong((new class {*m(){}}).m)); | 239 assertWeakGenerator((new class {*m(){}}).m); |
200 })(); | 240 })(); |
201 | 241 |
202 (function StrongGeneratorLiterals() { | 242 (function StrongGeneratorLiterals() { |
203 'use strong'; | 243 'use strong'; |
| 244 function assertStrongGenerator(x) { |
| 245 assertTrue(%IsStrong(x)); |
| 246 // TODO(rossberg): strongify generator prototypes |
| 247 // assertTrue(%IsStrong(x.prototype)); |
| 248 assertSame(GeneratorPrototype, Object.getPrototypeOf(x)); |
| 249 // TODO(rossberg): strongify generator instances |
| 250 // assertTrue(%IsStrong(x())); |
| 251 } |
204 function* g() {} | 252 function* g() {} |
205 assertTrue(%IsStrong(g)); | 253 assertStrongGenerator(g); |
206 assertTrue(%IsStrong(function*(){})); | 254 assertStrongGenerator(function*(){}); |
207 assertTrue(%IsStrong(function* g(){})); | 255 assertStrongGenerator(function* g(){}); |
208 assertTrue(%IsStrong({*m(){}}.m)); | 256 assertStrongGenerator({*m(){}}.m); |
209 assertTrue(%IsStrong((class {static *m(){}}).m)); | 257 assertStrongGenerator((class {static *m(){}}).m); |
210 assertTrue(%IsStrong((new class {*m(){}}).m)); | 258 assertStrongGenerator((new class {*m(){}}).m); |
211 })(); | 259 })(); |
212 | 260 |
213 (function SelfStrongGeneratorLiterals() { | 261 (function SelfStrongGeneratorLiterals() { |
| 262 function assertStrongGenerator(x) { |
| 263 assertTrue(%IsStrong(x)); |
| 264 // TODO(rossberg): strongify generator prototypes |
| 265 // assertTrue(%IsStrong(x.prototype)); |
| 266 assertSame(GeneratorPrototype, Object.getPrototypeOf(x)); |
| 267 // TODO(rossberg): strongify generator instances |
| 268 // assertTrue(%IsStrong(x())); |
| 269 } |
214 function* g() {'use strong'} | 270 function* g() {'use strong'} |
215 assertTrue(%IsStrong(g)); | 271 assertStrongGenerator(g); |
216 assertTrue(%IsStrong(function*(){'use strong'})); | 272 assertStrongGenerator(function*(){'use strong'}); |
217 assertTrue(%IsStrong(function* g(){'use strong'})); | 273 assertStrongGenerator(function* g(){'use strong'}); |
218 assertTrue(%IsStrong({*m(){'use strong'}}.m)); | 274 assertStrongGenerator({*m(){'use strong'}}.m); |
219 assertTrue(%IsStrong((class {static *m(){'use strong'}}).m)); | 275 assertStrongGenerator((class {static *m(){'use strong'}}).m); |
220 assertTrue(%IsStrong((new class {*m(){'use strong'}}).m)); | 276 assertStrongGenerator((new class {*m(){'use strong'}}).m); |
221 })(); | 277 })(); |
222 | 278 |
223 (function WeakClassLiterals() { | 279 (function WeakClassLiterals() { |
224 function assertWeakClass(C) { | 280 function assertWeakClass(x) { |
225 assertTrue(!%IsStrong(C)); | 281 assertFalse(%IsStrong(x)); |
226 assertTrue(!%IsStrong(C.prototype)); | 282 assertFalse(%IsStrong(x.prototype)); |
| 283 assertFalse(%IsStrong(new x)); |
227 } | 284 } |
228 class C {}; | 285 class C {}; |
229 class D extends C {}; | 286 class D extends C {}; |
230 class E extends Object {}; | 287 class E extends Object {}; |
231 class F extends null {}; | 288 // class F extends null {}; |
232 const S = (() => {'use strong'; return class {}})(); | 289 const S = (() => {'use strong'; return class {}})(); |
233 class G extends S {}; | 290 class G extends S {}; |
234 assertWeakClass(C); | 291 assertWeakClass(C); |
235 assertWeakClass(D); | 292 assertWeakClass(D); |
236 assertWeakClass(E); | 293 assertWeakClass(E); |
237 assertWeakClass(F); | 294 // assertWeakClass(F); |
238 assertWeakClass(G); | 295 assertWeakClass(G); |
239 assertWeakClass(class {}); | 296 assertWeakClass(class {}); |
240 assertWeakClass(class extends Object {}); | 297 assertWeakClass(class extends Object {}); |
241 assertWeakClass(class extends null {}); | 298 // assertWeakClass(class extends null {}); |
242 assertWeakClass(class extends C {}); | 299 assertWeakClass(class extends C {}); |
243 assertWeakClass(class extends S {}); | 300 assertWeakClass(class extends S {}); |
244 assertWeakClass(class extends class {} {}); | 301 assertWeakClass(class extends class {} {}); |
245 assertWeakClass(class C {}); | 302 assertWeakClass(class C {}); |
246 assertWeakClass(class D extends Object {}); | 303 assertWeakClass(class D extends Object {}); |
247 assertWeakClass(class D extends null {}); | 304 // assertWeakClass(class D extends null {}); |
248 assertWeakClass(class D extends C {}); | 305 assertWeakClass(class D extends C {}); |
249 assertWeakClass(class D extends S {}); | 306 assertWeakClass(class D extends S {}); |
250 assertWeakClass(class D extends class {} {}); | 307 assertWeakClass(class D extends class {} {}); |
251 })(); | 308 })(); |
252 | 309 |
253 (function StrongClassLiterals() { | 310 (function StrongClassLiterals() { |
254 'use strong'; | 311 'use strong'; |
255 function assertStrongClass(C) { | 312 function assertStrongClass(x) { |
256 assertTrue(%IsStrong(C)); | 313 assertTrue(%IsStrong(x)); |
257 // TODO(rossberg): prototype object is not yet strongified | 314 // TODO(rossberg): strongify class prototype and instance |
258 // assertTrue(%IsStrong(C.prototype)); | 315 // assertTrue(%IsStrong(x.prototype)); |
| 316 // assertTrue(%IsStrong(new x)); |
259 } | 317 } |
260 class C {}; | 318 class C {}; |
261 class D extends C {}; | 319 class D extends C {}; |
262 class E extends Object {}; | 320 class E extends Object {}; |
263 class F extends null {}; | |
264 const W = (1, eval)(() => {'use strict'; return class {}})(); | 321 const W = (1, eval)(() => {'use strict'; return class {}})(); |
265 class G extends W {}; | 322 class G extends W {}; |
266 assertStrongClass(C); | 323 assertStrongClass(C); |
267 assertStrongClass(D); | 324 assertStrongClass(D); |
268 assertStrongClass(E); | 325 assertStrongClass(E); |
269 assertStrongClass(F); | |
270 assertStrongClass(G); | 326 assertStrongClass(G); |
271 assertStrongClass(class {}); | 327 assertStrongClass(class {}); |
272 assertStrongClass(class extends Object {}); | 328 assertStrongClass(class extends Object {}); |
273 assertStrongClass(class extends null {}); | |
274 assertStrongClass(class extends C {}); | 329 assertStrongClass(class extends C {}); |
275 assertStrongClass(class extends W {}); | 330 assertStrongClass(class extends W {}); |
276 assertStrongClass(class extends class {} {}); | 331 assertStrongClass(class extends class {} {}); |
277 assertStrongClass(class C {}); | 332 assertStrongClass(class C {}); |
278 assertStrongClass(class D extends Object {}); | 333 assertStrongClass(class D extends Object {}); |
279 assertStrongClass(class D extends null {}); | |
280 assertStrongClass(class D extends C {}); | 334 assertStrongClass(class D extends C {}); |
281 assertStrongClass(class D extends W {}); | 335 assertStrongClass(class D extends W {}); |
282 assertStrongClass(class D extends class {} {}); | 336 assertStrongClass(class D extends class {} {}); |
283 })(); | 337 })(); |
284 | 338 |
285 (function WeakRegExpLiterals() { | 339 (function WeakRegExpLiterals() { |
286 assertTrue(!%IsStrong(/abc/)); | 340 function assertWeakRegExp(x) { |
| 341 assertFalse(%IsStrong(x)); |
| 342 } |
| 343 assertWeakRegExp(/abc/); |
287 })(); | 344 })(); |
288 | 345 |
289 (function StrongRegExpLiterals() { | 346 (function StrongRegExpLiterals() { |
290 'use strong'; | 347 'use strong'; |
291 // TODO(rossberg): implement strong regexp literals | 348 function assertStrongRegExp(x) { |
292 // assertTrue(%IsStrong(/abc/)); | 349 // TODO(rossberg): strongify regexps |
| 350 // assertTrue(%IsStrong(x)); |
| 351 } |
| 352 assertStrongRegExp(/abc/); |
293 })(); | 353 })(); |
OLD | NEW |