Skip to content

Commit

Permalink
Fix incorrect binding in test functions.
Browse files Browse the repository at this point in the history
`env` wasn't being closed over properly.
  • Loading branch information
cloudhead committed May 24, 2010
1 parent b10a30a commit 9fa313c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ function addVows(tests) {
// before calling the inner context. Else, just run the inner context
// synchronously.
if (topic) {
topic.addListener("success", function (vow, ctx) {
topic.addListener("success", function (vow, ctx, env) {
return function (val) {
return run(new(Context)(vow, ctx, env), lastTopic);
};
}(vow, ctx));
}(vow, ctx, env));
} else {
run(new(Context)(vow, ctx, env), lastTopic);
}
Expand Down
20 changes: 20 additions & 0 deletions test/vows-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,26 @@ vows.describe("Vows").addVows({
}
}
}
}).addVows({
"Sibling contexts": {
"'A', with `this.foo = true`": {
topic: function () {
this.foo = true;
return this.foo;
},
"should have `this.foo` set to true": function (res) {
assert.equal(res, true);
}
},
"'B', with nothing set": {
topic: function () {
return this.foo;
},
"should have `this.foo` be undefined": function (res) {
assert.isUndefined(res);
}
}
}
}).addVows({
"A 2nd test suite": {
topic: function () {
Expand Down

0 comments on commit 9fa313c

Please sign in to comment.