12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /**
- * Module dependencies
- */
- var Machine = require('../');
- xdescribe('maxRecursion', function (){
- describe('by default', function (){
- var machineInstance;
- before(function (){
- machineInstance = Machine.build(function horribleEndlesslyRecursingMachine(inputs, exits, env){
- var recursiveMachine = env.thisMachine();
- // console.log('Calling self. Max recursion:', recursiveMachine.maxRecursion);
- // console.log('Current recursion depth:', recursiveMachine._recursiveDepth);
- recursiveMachine.exec({
- error: function (err){
- return exits.error(err);
- },
- success: function (){
- return exits.success();
- }
- });
- });
- });
- it('should prevent "maximum call stack exceeded" errors by default', function (done){
- machineInstance().exec({
- error: function (err) {
- if (err.code === 'E_MAX_RECURSION') {
- return done();
- }
- return done(new Error('Expecting Error instance w/ `code` === "E_MAX_RECURSION", but instead got this error (code:'+err.code+'): '+err.stack));
- },
- success: function (){
- return done(new Error('wtf'));
- }
- });
- });
- });
- });
|