Skip to content

Commit

Permalink
fixed #189
Browse files Browse the repository at this point in the history
  • Loading branch information
bjouhier committed Dec 26, 2013
1 parent c34e5a8 commit 8abfe39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/callbacks/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,22 +847,22 @@ if (typeof exports !== 'undefined') {
};

function _canonFlows(node, options) {
function _doIt(node, parent) {
function _doIt(node, parent, force) {
var scope = node._scope;

function _doAsyncFor(node) {
// extra pass to wrap async condition and update
if (node.condition && node.condition._async && node.condition.type !== CALL) node.condition = _flowsTemplates.CONDITION.generate(node, {
$name: "__$" + node._scope.name,
$condition: node.condition
$condition: _doIt(node.condition, node, true),
});
if (node.update && node.update._async) node.update = _flowsTemplates.UPDATE.generate(node, {
$name: "__$" + node._scope.name,
$update: _statementify(node.update)
});
}
if (node.type == FOR && node._pass === "flows") _doAsyncFor(node);
if (!scope || !scope.isAsync() || node._pass === "flows") return _propagate(node, _doIt);
if (!scope || !scope.isAsync() || (!force && node._pass === "flows")) return _propagate(node, _doIt);

switch (node.type) {
case IF:
Expand Down
14 changes: 14 additions & 0 deletions test/common/eval-test._js
Original file line number Diff line number Diff line change
Expand Up @@ -796,3 +796,17 @@ asyncTest("futures on _(fn, idx)", 1, function(_) {
start();
});

asyncTest("do while", 1, function(_) {
var i = 0;
function read(_) {
return delay(_, ++i);
}
var s = "";
var v = read(_);
do {
s += v;
} while ((v = read(_)) < 5);
strictEqual(s, "1234");
start();
});

0 comments on commit 8abfe39

Please sign in to comment.