Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
295f3e1
commit 51549be
Showing
2 changed files
with
76 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,66 @@ | ||
var ourProcess = require('./browser'); | ||
var assert = require('assert'); | ||
var ourProcess = require('./browser'); | ||
describe('test against process', function () { | ||
test(process); | ||
}); | ||
if (!process.browser) { | ||
describe('test against our shim', function () { | ||
test(ourProcess); | ||
}); | ||
} | ||
function test (ourProcess) { | ||
describe('test arguments', function (t) { | ||
it ('works', function (done) { | ||
var order = 0; | ||
|
||
|
||
describe('test errors', function (t) { | ||
it ('works', function (done) { | ||
var order = 0; | ||
process.removeAllListeners('uncaughtException'); | ||
process.once('uncaughtException', function(err) { | ||
assert.equal(2, order++, 'error is third'); | ||
process.nextTick(function () { | ||
assert.equal(5, order++, 'schedualed in error is last'); | ||
done(); | ||
ourProcess.nextTick(function (num) { | ||
assert.equal(num, order++, 'first one works'); | ||
ourProcess.nextTick(function (num) { | ||
assert.equal(num, order++, 'recursive one is 4th'); | ||
}, 3); | ||
}, 0); | ||
ourProcess.nextTick(function (num) { | ||
assert.equal(num, order++, 'second one starts'); | ||
ourProcess.nextTick(function (num) { | ||
assert.equal(num, order++, 'this is third'); | ||
ourProcess.nextTick(function (num) { | ||
assert.equal(num, order++, 'this is last'); | ||
done(); | ||
}, 5); | ||
}, 4); | ||
}, 1); | ||
ourProcess.nextTick(function (num) { | ||
|
||
assert.equal(num, order++, '3rd schedualed happens after the error'); | ||
}, 2); | ||
}); | ||
}); | ||
process.nextTick(function () { | ||
assert.equal(0, order++, 'first one works'); | ||
process.nextTick(function () { | ||
assert.equal(4, order++, 'recursive one is 4th'); | ||
|
||
describe('test errors', function (t) { | ||
it ('works', function (done) { | ||
var order = 0; | ||
process.removeAllListeners('uncaughtException'); | ||
process.once('uncaughtException', function(err) { | ||
assert.equal(2, order++, 'error is third'); | ||
ourProcess.nextTick(function () { | ||
assert.equal(5, order++, 'schedualed in error is last'); | ||
done(); | ||
}); | ||
}); | ||
ourProcess.nextTick(function () { | ||
assert.equal(0, order++, 'first one works'); | ||
ourProcess.nextTick(function () { | ||
assert.equal(4, order++, 'recursive one is 4th'); | ||
}); | ||
}); | ||
ourProcess.nextTick(function () { | ||
assert.equal(1, order++, 'second one starts'); | ||
throw(new Error('an error is thrown')); | ||
}); | ||
ourProcess.nextTick(function () { | ||
assert.equal(3, order++, '3rd schedualed happens after the error'); | ||
}); | ||
}); | ||
}); | ||
process.nextTick(function () { | ||
assert.equal(1, order++, 'second one starts'); | ||
throw(new Error('an error is thrown')); | ||
}); | ||
process.nextTick(function () { | ||
assert.equal(3, order++, '3rd schedualed happens after the error'); | ||
}); | ||
}); | ||
}); | ||
} |