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