nl_tokens: ### . throw ( constructor )
pl_tokens: function assertThrows ( constructor , errMsg , msg ) { if ( msg ) flag ( this , 'message' , msg ) ; var obj = flag ( this , 'object' ) ; new Assertion ( obj , msg ) . is . a ( 'function' ) ; var thrown = false , desiredError = null , name = null , thrownError = null ; if ( arguments . length === 0 ) { errMsg = null ; constructor = null ; } else if ( constructor && ( constructor instanceof RegExp || 'string' === typeof constructor ) ) { errMsg = constructor ; constructor = null ; } else if ( constructor && constructor instanceof Error ) { desiredError = constructor ; constructor = null ; errMsg = null ; } else if ( typeof constructor === 'function' ) { name = constructor . prototype . name || constructor . name ; if ( name === 'Error' && constructor !== Error ) { name = ( new constructor ( ) ) . <mask> ; } } else { constructor = null ; } try { obj ( ) ; } catch ( err ) { // first, check desired error if ( desiredError ) { this . assert ( err === desiredError , 'expected #{this} to throw #{exp} but #{act} was thrown' , 'expected #{this} to not throw #{exp}' , ( desiredError instanceof Error ? desiredError . toString ( ) : desiredError ) , ( err instanceof Error ? err . toString ( ) : err ) ) ; flag ( this , 'object' , err ) ; return this ; } // next, check constructor if ( constructor ) { this . assert ( err instanceof constructor , 'expected #{this} to throw #{exp} but #{act} was thrown' , 'expected #{this} to not throw #{exp} but #{act} was thrown' , name , ( err instanceof Error ? err . toString ( ) : err ) ) ; if ( ! errMsg ) { flag ( this , 'object' , err ) ; return this ; } } // next, check message var message = 'error' === _ . type ( err ) && "message" in err ? err . message : '' + err ; if ( ( message != null ) && errMsg && errMsg instanceof RegExp ) { this . assert ( errMsg . exec ( message ) , 'expected #{this} to throw error matching #{exp} but got #{act}' , 'expected #{this} to throw error not matching #{exp}' , errMsg , message ) ; flag ( this , 'object' , err ) ; return this ; } else if ( ( message != null ) && errMsg && 'string' === typeof errMsg ) { this . assert ( ~ message . indexOf ( errMsg ) , 'expected #{this} to throw error including #{exp} but got #{act}' , 'expected #{this} to throw error not including #{act}' , errMsg , message ) ; flag ( this , 'object' , err ) ; return this ; } else { thrown = true ; thrownError = err ; } } var actuallyGot = '' , expectedThrown = name !== null ? name : desiredError ? '#{exp}' //_.inspect(desiredError) : 'an error' ; if ( thrown ) { actuallyGot = ' but #{act} was thrown' } this . assert ( thrown === true , 'expected #{this} to throw ' + expectedThrown + actuallyGot , 'expected #{this} to not throw ' + expectedThrown + actuallyGot , ( desiredError instanceof Error ? desiredError . toString ( ) : desiredError ) , ( thrownError instanceof Error ? thrownError . toString ( ) : thrownError ) ) ; flag ( this , 'object' , thrownError ) ; }