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

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: Fix nits; generator object fields are undefined if not set 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
« no previous file with comments | « test/mjsunit/harmony/generators-instantiation.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 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
49 TestContextAllocation(); 50
51 // Test the properties and prototype of a generator object.
52 function TestGeneratorObject() {
53 function* g() { yield 1; }
54
55 var iter = g();
56 assertSame(g.prototype, Object.getPrototypeOf(iter));
57 assertTrue(iter instanceof g);
58 assertEquals([], Object.getOwnPropertyNames(iter));
59 assertTrue(iter !== g());
60
61 // g() is the same as new g().
62 iter = new g();
63 assertSame(g.prototype, Object.getPrototypeOf(iter));
64 assertTrue(iter instanceof g);
65 assertEquals([], Object.getOwnPropertyNames(iter));
66 assertTrue(iter !== new g());
67 }
68 TestGeneratorObject();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/generators-instantiation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698