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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-generator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/function-sent.js
diff --git a/test/mjsunit/harmony/function-sent.js b/test/mjsunit/harmony/function-sent.js
new file mode 100644
index 0000000000000000000000000000000000000000..9dbc16882ee5129ca0e34f1988cf5e5ac0378e3d
--- /dev/null
+++ b/test/mjsunit/harmony/function-sent.js
@@ -0,0 +1,76 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-function-sent
+
+
+{
+ function* g() { return function.sent }
+ assertEquals({value: 42, done: true}, g().next(42));
+}
+
+
+{
+ function* g() {
+ try {
+ yield function.sent;
+ } finally {
+ yield function.sent;
+ return function.sent;
+ }
+ }
+
+ {
+ x = g();
+ assertEquals({value: 1, done: false}, x.next(1));
+ assertEquals({value: 2, done: false}, x.next(2));
+ assertEquals({value: 3, done: true}, x.next(3));
+ }
+
+ {
+ x = g();
+ assertEquals({value: 1, done: false}, x.next(1));
+ assertEquals({value: 2, done: false}, x.throw(2));
+ assertEquals({value: 3, done: true}, x.next(3));
+ }
+}
+
+
+{
+ function* inner() {
+ try {
+ yield function.sent;
+ } finally {
+ return 666;
+ }
+ }
+
+ function* g() {
+ yield function.sent;
+ yield* inner();
+ return function.sent;
+ }
+
+ {
+ x = g();
+ assertEquals({value: 1, done: false}, x.next(1));
+ assertEquals({value: undefined, done: false}, x.next(2));
+ assertEquals({value: 3, done: true}, x.next(3));
+ }
+
+ {
+ x = g();
+ assertEquals({value: 1, done: false}, x.next(1));
+ assertEquals({value: undefined, done: false}, x.next(2));
+ assertEquals({value: 42, done: true}, x.throw(42));
+ }
+}
+
+
+assertThrows("function f() { return function.sent }", SyntaxError);
+assertThrows("() => { return function.sent }", SyntaxError);
+assertThrows("() => { function.sent }", SyntaxError);
+assertThrows("() => function.sent", SyntaxError);
+assertThrows("({*f() { function.sent }})", SyntaxError);
+assertDoesNotThrow("({*f() { return function.sent }})");
« 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