Created
November 16, 2009 02:50
-
-
Save gerad/235665 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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