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/function-sent.js

Issue 1620253003: Implement the function.sent proposal. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add TODO Created 4 years, 10 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/runtime/runtime-generator.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
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-function-sent
6
7
8 {
9 function* g() { return function.sent }
10 assertEquals({value: 42, done: true}, g().next(42));
11 }
12
13
14 {
15 function* g() {
16 try {
17 yield function.sent;
18 } finally {
19 yield function.sent;
20 return function.sent;
21 }
22 }
23
24 {
25 x = g();
26 assertEquals({value: 1, done: false}, x.next(1));
27 assertEquals({value: 2, done: false}, x.next(2));
28 assertEquals({value: 3, done: true}, x.next(3));
29 }
30
31 {
32 x = g();
33 assertEquals({value: 1, done: false}, x.next(1));
34 assertEquals({value: 2, done: false}, x.throw(2));
35 assertEquals({value: 3, done: true}, x.next(3));
36 }
37 }
38
39
40 {
41 function* inner() {
42 try {
43 yield function.sent;
44 } finally {
45 return 666;
46 }
47 }
48
49 function* g() {
50 yield function.sent;
51 yield* inner();
52 return function.sent;
53 }
54
55 {
56 x = g();
57 assertEquals({value: 1, done: false}, x.next(1));
58 assertEquals({value: undefined, done: false}, x.next(2));
59 assertEquals({value: 3, done: true}, x.next(3));
60 }
61
62 {
63 x = g();
64 assertEquals({value: 1, done: false}, x.next(1));
65 assertEquals({value: undefined, done: false}, x.next(2));
66 assertEquals({value: 42, done: true}, x.throw(42));
67 }
68 }
69
70
71 assertThrows("function f() { return function.sent }", SyntaxError);
72 assertThrows("() => { return function.sent }", SyntaxError);
73 assertThrows("() => { function.sent }", SyntaxError);
74 assertThrows("() => function.sent", SyntaxError);
75 assertThrows("({*f() { function.sent }})", SyntaxError);
76 assertDoesNotThrow("({*f() { return function.sent }})");
OLDNEW
« no previous file with comments | « src/runtime/runtime-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698