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

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

Issue 13542002: Calling a generator function returns a generator object (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Link generator iterator definitions and uses through local variable 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
« src/runtime.cc ('K') | « src/runtime.cc ('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 28 matching lines...) Expand all
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 48
49 // Test the properties and prototype of an iterator.
50 function TestGeneratorIterator() {
51 function* g() { yield 1; }
52
53 var iterator = g();
54 assertSame(g.prototype, Object.getPrototypeOf(iterator));
55 assertTrue(iterator instanceof g);
56 assertEquals([], Object.getOwnPropertyNames(iterator));
57 assertTrue(iterator !== g());
58
59 // g() is the same as new g().
60 iterator = new g();
61 assertSame(g.prototype, Object.getPrototypeOf(iterator));
62 assertTrue(iterator instanceof g);
63 assertEquals([], Object.getOwnPropertyNames(iterator));
64 assertTrue(iterator !== new g());
65 }
66
49 TestContextAllocation(); 67 TestContextAllocation();
68 TestGeneratorIterator();
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698