Skip to content

Commit 604fb93

Browse files
committed
#94 fix generators support
1 parent 22d61f2 commit 604fb93

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

lib/child.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,18 @@ if (generators.support) {
118118
global.test = QUnit.test = function(testName, expected, callback, async) {
119119
var fn;
120120

121-
if ( arguments.length === 2 ) {
121+
if (arguments.length === 2) {
122122
callback = expected;
123123
expected = null;
124124
}
125125

126126
if (generators.isGeneratorFn(callback)) {
127-
fn = function() {
127+
fn = function(assert) {
128128
stop();
129-
co(callback)();
130-
start();
129+
co(callback).call(this, assert, function(err) {
130+
if (err) return console.log(err.stack)
131+
start();
132+
});
131133
};
132134
} else {
133135
fn = callback;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "qunit",
33
"description": "QUnit testing framework for nodejs",
4-
"version": "0.7.0",
4+
"version": "0.7.1",
55
"author": "Oleg Slobodskoi <oleg008@gmail.com>",
66
"contributors": [
77
{

test/fixtures/generators-code.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
exports.getMyGen = function() {
2-
return function* () {
3-
return yield {a: 1};
1+
exports.thunk = function() {
2+
return function(callback) {
3+
setTimeout(function() {
4+
callback(null, {a: 1});
5+
}, 100);
46
};
57
};

test/fixtures/generators-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
test('generators', function* () {
2-
var data = yield getMyGen();
2+
var data = yield thunk();
33
deepEqual(data, {a: 1}, 'woks');
44
});

0 commit comments

Comments
 (0)