async-try-catch
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "async-try-catch", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Async try catch", | ||
@@ -5,0 +5,0 @@ "main": "lib/AsyncTryCatch.js", |
@@ -81,3 +81,3 @@ /* | ||
it( "Async: setTimeout" , function( done ) { | ||
it( "setTimeout()" , function( done ) { | ||
@@ -95,5 +95,31 @@ asyncTry( function() { | ||
it( "Async: nested setTimeout" , function( done ) { | ||
it( "setImmediate()" , function( done ) { | ||
asyncTry( function() { | ||
setImmediate( function() { | ||
throw new Error( 'setImmediate error' ) ; | ||
} , 0 ) ; | ||
} ) | ||
.catch( function( error ) { | ||
expect( error.message ).to.be( 'setImmediate error' ) ; | ||
done() ; | ||
} ) ; | ||
} ) ; | ||
it( "process.nextTick()" , function( done ) { | ||
asyncTry( function() { | ||
process.nextTick( function() { | ||
throw new Error( 'nextTick error' ) ; | ||
} , 0 ) ; | ||
} ) | ||
.catch( function( error ) { | ||
expect( error.message ).to.be( 'nextTick error' ) ; | ||
done() ; | ||
} ) ; | ||
} ) ; | ||
it( "nested setTimeout" , function( done ) { | ||
asyncTry( function() { | ||
setTimeout( function() { | ||
@@ -111,3 +137,3 @@ setTimeout( function() { | ||
it( "Async: five nested setTimeout" , function( done ) { | ||
it( "five nested setTimeout" , function( done ) { | ||
@@ -133,3 +159,3 @@ asyncTry( function() { | ||
it( "Async: nested setTimeout and async try catch, it should throw from the inner try, re-throw from the inner catch, bubble up to the outer catch" , function( done ) { | ||
it( "nested setTimeout and async try catch, it should throw from the inner try, re-throw from the inner catch, bubble up to the outer catch" , function( done ) { | ||
@@ -165,3 +191,3 @@ asyncTry( function outerTry() { | ||
it( "an exception thrown from a listener within an async-try closure should be catched" , function( done ) { | ||
it( "an exception thrown synchronously from a listener within an async-try closure should be catched" , function( done ) { | ||
@@ -181,16 +207,19 @@ var emitter = Object.create( Events.prototype ) ; | ||
it( "an exception thrown from a listener, whose emit is within an async-try closure should be catched if everything is synchronous" , function( done ) { | ||
// works because emit is sync here | ||
it( "an exception thrown asynchronously from a listener within an async-try closure should be catched" , function( done ) { | ||
var emitter = Object.create( Events.prototype ) ; | ||
emitter.on( 'damage' , function() { throw new Error( 'argh!' ) ; } ) ; | ||
asyncTry( function() { | ||
emitter.emit( 'damage' ) ; | ||
emitter.on( 'damage' , function() { | ||
setTimeout( function() { | ||
throw new Error( 'delayed argh!' ) ; | ||
} , 0 ) ; | ||
} ) ; | ||
} ) | ||
.catch( function( error ) { | ||
expect( error.message ).to.be( 'argh!' ) ; | ||
expect( error.message ).to.be( 'delayed argh!' ) ; | ||
done() ; | ||
} ) ; | ||
emitter.emit( 'damage' ) ; | ||
} ) ; | ||
@@ -203,3 +232,3 @@ } ) ; | ||
it( "an exception thrown from a listener within an async-try closure should be catched" , function( done ) { | ||
it( "an exception thrown synchronously from a listener within an async-try closure should be catched" , function( done ) { | ||
@@ -219,4 +248,22 @@ var emitter = Object.create( NextGenEvents.prototype ) ; | ||
it( "an exception thrown asynchronously from a listener within an async-try closure should be catched" , function( done ) { | ||
var emitter = Object.create( NextGenEvents.prototype ) ; | ||
asyncTry( function() { | ||
emitter.on( 'damage' , function() { | ||
setTimeout( function() { | ||
throw new Error( 'delayed argh!' ) ; | ||
} , 0 ) ; | ||
} ) ; | ||
} ) | ||
.catch( function( error ) { | ||
expect( error.message ).to.be( 'delayed argh!' ) ; | ||
done() ; | ||
} ) ; | ||
emitter.emit( 'damage' ) ; | ||
} ) ; | ||
} ) ; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23048
367