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

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

Issue 13542002: Calling a generator function returns a generator object (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Rebased to apply to bleeding_edge Created 7 years, 8 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
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 27 matching lines...) Expand all
38 function* g4() { var x = 10; yield 1; return x; } 38 function* g4() { var x = 10; yield 1; return x; }
39 // Temporary variable context allocation 39 // Temporary variable context allocation
40 function* g5(l) { "use strict"; yield 1; for (let x in l) { yield x; } } 40 function* g5(l) { "use strict"; yield 1; for (let x in l) { yield x; } }
41 41
42 g1(); 42 g1();
43 g2(); 43 g2();
44 g3(); 44 g3();
45 g4(); 45 g4();
46 g5(["foo"]); 46 g5(["foo"]);
47 } 47 }
48 TestContextAllocation();
48 49
Michael Starzinger 2013/04/11 19:17:39 nit: Add a second empty newline between the two te
wingo 2013/04/12 10:50:17 Done.
49 TestContextAllocation(); 50 // Test the properties and prototype of a generator object.
51 function TestGeneratorObject() {
52 function* g() { yield 1; }
53
54 var iter = g();
55 assertSame(g.prototype, Object.getPrototypeOf(iter));
56 assertTrue(iter instanceof g);
57 assertEquals([], Object.getOwnPropertyNames(iter));
58 assertTrue(iter !== g());
59
60 // g() is the same as new g().
61 iter = new g();
62 assertSame(g.prototype, Object.getPrototypeOf(iter));
63 assertTrue(iter instanceof g);
64 assertEquals([], Object.getOwnPropertyNames(iter));
65 assertTrue(iter !== new g());
66 }
67 TestGeneratorObject();
OLDNEW
« src/parser.cc ('K') | « test/mjsunit/harmony/generators-instantiation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698