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

Side by Side Diff: test/mjsunit/es6/generators-runtime.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, 7 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 | « src/bootstrapper.cc ('k') | test/mjsunit/harmony/object-literals-method.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 f_own_property_names.sort(); 46 f_own_property_names.sort();
47 g_own_property_names.sort(); 47 g_own_property_names.sort();
48 48
49 assertArrayEquals(f_own_property_names, g_own_property_names); 49 assertArrayEquals(f_own_property_names, g_own_property_names);
50 var i; 50 var i;
51 for (i = 0; i < f_own_property_names.length; i++) { 51 for (i = 0; i < f_own_property_names.length; i++) {
52 var prop = f_own_property_names[i]; 52 var prop = f_own_property_names[i];
53 var f_desc = Object.getOwnPropertyDescriptor(f, prop); 53 var f_desc = Object.getOwnPropertyDescriptor(f, prop);
54 var g_desc = Object.getOwnPropertyDescriptor(g, prop); 54 var g_desc = Object.getOwnPropertyDescriptor(g, prop);
55 if (prop === "prototype") { 55 assertEquals(f_desc.configurable, g_desc.configurable, prop);
56 // ES6 draft 03-17-2015 section 25.2.2.2 56 assertEquals(f_desc.writable, g_desc.writable, prop);
57 assertFalse(g_desc.writable, prop); 57 assertEquals(f_desc.enumerable, g_desc.enumerable, prop);
58 assertFalse(g_desc.enumerable, prop);
59 assertFalse(g_desc.configurable, prop);
60 } else {
61 assertEquals(f_desc.configurable, g_desc.configurable, prop);
62 assertEquals(f_desc.writable, g_desc.writable, prop);
63 assertEquals(f_desc.enumerable, g_desc.enumerable, prop);
64 }
65 } 58 }
66 } 59 }
67 TestGeneratorFunctionInstance(); 60 TestGeneratorFunctionInstance();
68 61
69 62
70 // Generators have an additional object interposed in the chain between 63 // Generators have an additional object interposed in the chain between
71 // themselves and Function.prototype. 64 // themselves and Function.prototype.
72 function TestGeneratorFunctionPrototype() { 65 function TestGeneratorFunctionPrototype() {
73 // Sanity check. 66 // Sanity check.
74 assertSame(Object.getPrototypeOf(f), Function.prototype); 67 assertSame(Object.getPrototypeOf(f), Function.prototype);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 assertTrue(g instanceof Function); 142 assertTrue(g instanceof Function);
150 143
151 assertEquals("function* g() { yield 1; }", g.toString()); 144 assertEquals("function* g() { yield 1; }", g.toString());
152 145
153 // Not all functions are generators. 146 // Not all functions are generators.
154 assertTrue(f instanceof Function); // Sanity check. 147 assertTrue(f instanceof Function); // Sanity check.
155 assertTrue(!(f instanceof GeneratorFunction)); 148 assertTrue(!(f instanceof GeneratorFunction));
156 149
157 assertTrue((new GeneratorFunction()) instanceof GeneratorFunction); 150 assertTrue((new GeneratorFunction()) instanceof GeneratorFunction);
158 assertTrue(GeneratorFunction() instanceof GeneratorFunction); 151 assertTrue(GeneratorFunction() instanceof GeneratorFunction);
152
153 // ES6 draft 04-14-15, section 25.2.2.2
154 var prototype_desc = Object.getOwnPropertyDescriptor(GeneratorFunction,
155 "prototype");
156 assertFalse(prototype_desc.writable);
157 assertFalse(prototype_desc.enumerable);
158 assertFalse(prototype_desc.configurable);
159 } 159 }
160 TestGeneratorFunction(); 160 TestGeneratorFunction();
161 161
162 162
163 function TestPerGeneratorPrototype() { 163 function TestPerGeneratorPrototype() {
164 assertTrue((function*(){}).prototype !== (function*(){}).prototype); 164 assertTrue((function*(){}).prototype !== (function*(){}).prototype);
165 assertTrue((function*(){}).prototype !== g.prototype); 165 assertTrue((function*(){}).prototype !== g.prototype);
166 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); 166 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype));
167 assertTrue(!(g.prototype instanceof Function)); 167 assertTrue(!(g.prototype instanceof Function));
168 assertSame(typeof (g.prototype), "object"); 168 assertSame(typeof (g.prototype), "object");
169 169
170 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); 170 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype));
171 } 171 }
172 TestPerGeneratorPrototype(); 172 TestPerGeneratorPrototype();
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | test/mjsunit/harmony/object-literals-method.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698