Skip to content
Browse files

Merge pull request #35 from MatthewMueller/add/context-test

update readme and add test for co.call
  • Loading branch information...
2 parents dd4c826 + 82acd1e commit 42ec32ebe09002bfb6ba440cec73d08f7339abae @tj committed
Showing with 24 additions and 1 deletion.
  1. +11 −1 Readme.md
  2. +13 −0 test/receiver.js
View
12 Readme.md
@@ -109,7 +109,17 @@ function foo() {
co.call(ctx, function *(){
assert(this == ctx);
yield foo;
-});
+})()
+```
+
+ You also pass arguments through the generator:
+
+```js
+co.call(ctx, function *(a){
+ assert(this == ctx);
+ assert('yay' == a);
+ yield foo;
+})('yay');
```
## API
View
13 test/receiver.js
@@ -44,6 +44,19 @@ describe('co.call(receiver)', function(){
})(done);
})
+ it('should pass args', function(done){
+ function foo(done) {
+ assert(this == ctx);
+ done();
+ }
+
+ co.call(ctx, function *(a){
+ assert('yay' == a);
+ assert(ctx == this);
+ yield foo;
+ })('yay', done);
+ })
+
it('should set join delegate generator receiver', function(done){
function *baz() {
assert(ctx == this);

0 comments on commit 42ec32e

Please sign in to comment.
Something went wrong with that request. Please try again.