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

Side by Side Diff: test/mjsunit/harmony/generators-runtime.js

Issue 14857009: GeneratorFunction() makes generator instances (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nit Created 7 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/harmony/generators-iteration.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 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 assertTrue(g instanceof GeneratorFunction); 103 assertTrue(g instanceof GeneratorFunction);
104 104
105 assertSame(Function, Object.getPrototypeOf(GeneratorFunction)); 105 assertSame(Function, Object.getPrototypeOf(GeneratorFunction));
106 assertTrue(g instanceof Function); 106 assertTrue(g instanceof Function);
107 107
108 assertEquals("function* g() { yield 1; }", g.toString()); 108 assertEquals("function* g() { yield 1; }", g.toString());
109 109
110 // Not all functions are generators. 110 // Not all functions are generators.
111 assertTrue(f instanceof Function); // Sanity check. 111 assertTrue(f instanceof Function); // Sanity check.
112 assertTrue(!(f instanceof GeneratorFunction)); 112 assertTrue(!(f instanceof GeneratorFunction));
113
114 assertTrue((new GeneratorFunction()) instanceof GeneratorFunction);
115 assertTrue(GeneratorFunction() instanceof GeneratorFunction);
113 } 116 }
114 TestGeneratorFunction(); 117 TestGeneratorFunction();
115 118
116 119
117 function TestPerGeneratorPrototype() { 120 function TestPerGeneratorPrototype() {
118 assertTrue((function*(){}).prototype !== (function*(){}).prototype); 121 assertTrue((function*(){}).prototype !== (function*(){}).prototype);
119 assertTrue((function*(){}).prototype !== g.prototype); 122 assertTrue((function*(){}).prototype !== g.prototype);
120 assertTrue(g.prototype instanceof GeneratorFunctionPrototype); 123 assertTrue(g.prototype instanceof GeneratorFunctionPrototype);
121 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); 124 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype));
122 assertTrue(!(g.prototype instanceof Function)); 125 assertTrue(!(g.prototype instanceof Function));
123 assertSame(typeof (g.prototype), "object"); 126 assertSame(typeof (g.prototype), "object");
124 127
125 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); 128 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype));
126 } 129 }
127 TestPerGeneratorPrototype(); 130 TestPerGeneratorPrototype();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/generators-iteration.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698