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

Commit

Permalink
Add test inspired by issue #275.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Feb 17, 2017
1 parent aec5966 commit 3f0d47f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/tests.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,49 @@ describe("delegated yield", function() {
}
});

it("should execute finally blocks of delegate generators", function() {
var markers = [];

function* parent() {
try {
return yield* child();
} finally {
markers.push("parent");
}
}

function* child() {
try {
return yield 1;
} finally {
yield 2;
markers.push("child");
}
}

var g = parent();

assert.deepEqual(g.next(), {
value: 1,
done: false
});

// The generator function has been carefully constructed so that .next
// and .return have the same effect, so that these tests should pass
// in versions of Node that do not support .return.
assert.deepEqual((g.return || g.next).call(g, 3), {
value: 2,
done: false
});

assert.deepEqual(g.next(), {
value: 3,
done: true
});

assert.deepEqual(markers, ["child", "parent"]);
});

it("should evaluate to the return value of the delegate", function() {
function *inner() {
yield 1;
Expand Down

0 comments on commit 3f0d47f

Please sign in to comment.