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

Side by Side Diff: test/mjsunit/harmony/object-literals-method.js

Issue 1153633003: [es6] Define generator prototype as writable prop (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add requested regression test Created 5 years, 6 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/generators-runtime.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 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-object-literals --allow-natives-syntax 5 // Flags: --harmony-object-literals --allow-natives-syntax
6 6
7 7
8 (function TestBasics() { 8 (function TestBasics() {
9 var object = { 9 var object = {
10 method() { 10 method() {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 %OptimizeFunctionOnNextCall(object.method); 149 %OptimizeFunctionOnNextCall(object.method);
150 assertEquals(42, object.method()); 150 assertEquals(42, object.method());
151 assertFalse(object.method.hasOwnProperty('prototype')); 151 assertFalse(object.method.hasOwnProperty('prototype'));
152 })(); 152 })();
153 153
154 154
155 /////////////////////////////////////////////////////////////////////////////// 155 ///////////////////////////////////////////////////////////////////////////////
156 156
157 157
158 var GeneratorFunction = function*() {}.__proto__.constructor; 158 var GeneratorFunction = function*() {}.__proto__.constructor;
159 var GeneratorPrototype = Object.getPrototypeOf(function*() {}).prototype;
159 160
160 161
161 function assertIteratorResult(value, done, result) { 162 function assertIteratorResult(value, done, result) {
162 assertEquals({value: value, done: done}, result); 163 assertEquals({value: value, done: done}, result);
163 } 164 }
164 165
165 166
166 (function TestGeneratorBasics() { 167 (function TestGeneratorBasics() {
167 var object = { 168 var object = {
168 *method() { 169 *method() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 assertTrue(desc.configurable); 209 assertTrue(desc.configurable);
209 assertTrue(desc.writable); 210 assertTrue(desc.writable);
210 assertEquals('function', typeof desc.value); 211 assertEquals('function', typeof desc.value);
211 212
212 var g = desc.value(); 213 var g = desc.value();
213 assertIteratorResult(1, false, g.next()); 214 assertIteratorResult(1, false, g.next());
214 assertIteratorResult(undefined, true, g.next()); 215 assertIteratorResult(undefined, true, g.next());
215 })(); 216 })();
216 217
217 218
219 (function TestGeneratorPrototypeDescriptor() {
220 var object = {
221 *method() {}
222 };
223
224 var desc = Object.getOwnPropertyDescriptor(object.method, 'prototype');
225 assertFalse(desc.enumerable);
226 assertFalse(desc.configurable);
227 assertTrue(desc.writable);
228 assertEquals(GeneratorPrototype, Object.getPrototypeOf(desc.value));
229 })();
230
231
218 (function TestGeneratorProto() { 232 (function TestGeneratorProto() {
219 var object = { 233 var object = {
220 *method() {} 234 *method() {}
221 }; 235 };
222 236
223 assertEquals(GeneratorFunction.prototype, 237 assertEquals(GeneratorFunction.prototype,
224 Object.getPrototypeOf(object.method)); 238 Object.getPrototypeOf(object.method));
225 })(); 239 })();
226 240
227 241
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 var p = {}; 305 var p = {};
292 var object = { 306 var object = {
293 __proto__() { 307 __proto__() {
294 return 1; 308 return 1;
295 }, 309 },
296 __proto__: p 310 __proto__: p
297 }; 311 };
298 assertEquals(p, Object.getPrototypeOf(object)); 312 assertEquals(p, Object.getPrototypeOf(object));
299 assertEquals(1, object.__proto__()); 313 assertEquals(1, object.__proto__());
300 })(); 314 })();
OLDNEW
« no previous file with comments | « test/mjsunit/es6/generators-runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698