Skip to content

Instantly share code, notes, and snippets.

@gerad
Created November 16, 2009 02:50
Show Gist options
  • Save gerad/235665 to your computer and use it in GitHub Desktop.
Save gerad/235665 to your computer and use it in GitHub Desktop.
test("pass through", function() {
function increment(i) { return i + 1; }
function asyncIncrement(i, callback) {
async(function() { callback(i + 1); });
}
function asyncIncrement2(i) {
var d = new Deferred().pause();
async(function() { d.restart(i + 1); });
return d;
}
var d = new Deferred();
d.add(
d.fn(asyncIncrement, [0, d.okFn]), // async with callback
increment, // synchronous
increment,
asyncIncrement2, // async with deferred
increment,
function(result) {
equals(result, 5, "incremented the correct number of times");
start(); // for qunit
}
);
expect(1);
stop(); // for qunit
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment