From 46f47f150943977b7e784688d110468c707f8cac Mon Sep 17 00:00:00 2001 From: Ben Newman <bn@cs.stanford.edu> Date: Sat, 12 Apr 2014 14:25:37 -0700 Subject: [PATCH] Make sure generator.return(argument) works for newborn generators. --- test/tests.es6.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/tests.es6.js b/test/tests.es6.js index a15f52ff3..a5f830095 100644 --- a/test/tests.es6.js +++ b/test/tests.es6.js @@ -1799,8 +1799,28 @@ describe("for-of loops", function() { }); describe("generator return method", function() { - (runningInTranslation ? it : xit) - ("should behave as if generator actually returned", function() { + if (!runningInTranslation) { + // The return method has not been specified or implemented natively, + // yet, so these tests need only pass in translation. + return; + } + + it("should work with newborn generators", function() { + function *gen() { + yield 0; + } + + var g = gen(); + + assert.deepEqual(g.return("argument"), { + value: "argument", + done: true + }); + + assertAlreadyFinished(g); + }); + + it("should behave as if generator actually returned", function() { var executedFinally = false; function *gen() {