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

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

Issue 13704010: Generator objects can suspend (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Use sentinel values for continuations 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 | « src/x64/full-codegen-x64.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 20 matching lines...) Expand all
31 31
32 // Yield statements. 32 // Yield statements.
33 function* g() { yield 3; yield 4; } 33 function* g() { yield 3; yield 4; }
34 34
35 // Yield expressions. 35 // Yield expressions.
36 function* g() { (yield 3) + (yield 4); } 36 function* g() { (yield 3) + (yield 4); }
37 37
38 // You can have a generator in strict mode. 38 // You can have a generator in strict mode.
39 function* g() { "use strict"; yield 3; yield 4; } 39 function* g() { "use strict"; yield 3; yield 4; }
40 40
41 // Generators can have return statements also, which internally parse to a kind
42 // of yield expression.
43 function* g() { yield 1; return; }
44 function* g() { yield 1; return 2; }
45 function* g() { yield 1; return 2; yield "dead"; }
46
41 // Generator expression. 47 // Generator expression.
42 (function* () { yield 3; }); 48 (function* () { yield 3; });
43 49
44 // Named generator expression. 50 // Named generator expression.
45 (function* g() { yield 3; }); 51 (function* g() { yield 3; });
46 52
47 // A generator without a yield is specified as causing an early error. This 53 // A generator without a yield is specified as causing an early error. This
48 // behavior is currently unimplemented. See 54 // behavior is currently unimplemented. See
49 // https://bugs.ecmascript.org/show_bug.cgi?id=1283. 55 // https://bugs.ecmascript.org/show_bug.cgi?id=1283.
50 function* g() { } 56 function* g() { }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 assertThrows("function* g() { yield 3 + yield 4; }", SyntaxError); 97 assertThrows("function* g() { yield 3 + yield 4; }", SyntaxError);
92 98
93 // Yield is still a future-reserved-word in strict mode 99 // Yield is still a future-reserved-word in strict mode
94 assertThrows("function f() { \"use strict\"; var yield = 13; }", SyntaxError); 100 assertThrows("function f() { \"use strict\"; var yield = 13; }", SyntaxError);
95 101
96 // The name of the NFE is let-bound in G, so is invalid. 102 // The name of the NFE is let-bound in G, so is invalid.
97 assertThrows("function* g() { yield (function yield() {}); }", SyntaxError); 103 assertThrows("function* g() { yield (function yield() {}); }", SyntaxError);
98 104
99 // In generators, yield is invalid as a formal argument name. 105 // In generators, yield is invalid as a formal argument name.
100 assertThrows("function* g(yield) { yield (10); }", SyntaxError); 106 assertThrows("function* g(yield) { yield (10); }", SyntaxError);
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698