Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Commit

Permalink
Make sure generator.return(argument) works for newborn generators.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Aug 17, 2014
1 parent 9096dd3 commit 46f47f1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/tests.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 46f47f1

Please sign in to comment.