|
1 | | -var ourProcess = require('./browser'); |
2 | 1 | var assert = require('assert'); |
| 2 | +var ourProcess = require('./browser'); |
| 3 | +describe('test against process', function () { |
| 4 | + test(process); |
| 5 | +}); |
| 6 | +if (!process.browser) { |
| 7 | + describe('test against our shim', function () { |
| 8 | + test(ourProcess); |
| 9 | + }); |
| 10 | +} |
| 11 | +function test (ourProcess) { |
| 12 | + describe('test arguments', function (t) { |
| 13 | + it ('works', function (done) { |
| 14 | + var order = 0; |
| 15 | + |
3 | 16 |
|
4 | | -describe('test errors', function (t) { |
5 | | - it ('works', function (done) { |
6 | | - var order = 0; |
7 | | - process.removeAllListeners('uncaughtException'); |
8 | | - process.once('uncaughtException', function(err) { |
9 | | - assert.equal(2, order++, 'error is third'); |
10 | | - process.nextTick(function () { |
11 | | - assert.equal(5, order++, 'schedualed in error is last'); |
12 | | - done(); |
| 17 | + ourProcess.nextTick(function (num) { |
| 18 | + assert.equal(num, order++, 'first one works'); |
| 19 | + ourProcess.nextTick(function (num) { |
| 20 | + assert.equal(num, order++, 'recursive one is 4th'); |
| 21 | + }, 3); |
| 22 | + }, 0); |
| 23 | + ourProcess.nextTick(function (num) { |
| 24 | + assert.equal(num, order++, 'second one starts'); |
| 25 | + ourProcess.nextTick(function (num) { |
| 26 | + assert.equal(num, order++, 'this is third'); |
| 27 | + ourProcess.nextTick(function (num) { |
| 28 | + assert.equal(num, order++, 'this is last'); |
| 29 | + done(); |
| 30 | + }, 5); |
| 31 | + }, 4); |
| 32 | + }, 1); |
| 33 | + ourProcess.nextTick(function (num) { |
| 34 | + |
| 35 | + assert.equal(num, order++, '3rd schedualed happens after the error'); |
| 36 | + }, 2); |
13 | 37 | }); |
14 | 38 | }); |
15 | | - process.nextTick(function () { |
16 | | - assert.equal(0, order++, 'first one works'); |
17 | | - process.nextTick(function () { |
18 | | - assert.equal(4, order++, 'recursive one is 4th'); |
| 39 | + |
| 40 | + describe('test errors', function (t) { |
| 41 | + it ('works', function (done) { |
| 42 | + var order = 0; |
| 43 | + process.removeAllListeners('uncaughtException'); |
| 44 | + process.once('uncaughtException', function(err) { |
| 45 | + assert.equal(2, order++, 'error is third'); |
| 46 | + ourProcess.nextTick(function () { |
| 47 | + assert.equal(5, order++, 'schedualed in error is last'); |
| 48 | + done(); |
| 49 | + }); |
| 50 | + }); |
| 51 | + ourProcess.nextTick(function () { |
| 52 | + assert.equal(0, order++, 'first one works'); |
| 53 | + ourProcess.nextTick(function () { |
| 54 | + assert.equal(4, order++, 'recursive one is 4th'); |
| 55 | + }); |
| 56 | + }); |
| 57 | + ourProcess.nextTick(function () { |
| 58 | + assert.equal(1, order++, 'second one starts'); |
| 59 | + throw(new Error('an error is thrown')); |
| 60 | + }); |
| 61 | + ourProcess.nextTick(function () { |
| 62 | + assert.equal(3, order++, '3rd schedualed happens after the error'); |
| 63 | + }); |
19 | 64 | }); |
20 | 65 | }); |
21 | | - process.nextTick(function () { |
22 | | - assert.equal(1, order++, 'second one starts'); |
23 | | - throw(new Error('an error is thrown')); |
24 | | - }); |
25 | | - process.nextTick(function () { |
26 | | - assert.equal(3, order++, '3rd schedualed happens after the error'); |
27 | | - }); |
28 | | - }); |
29 | | -}); |
| 66 | +} |
0 commit comments