File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed
Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -58,25 +58,23 @@ var create_callsite = function(location) {
5858} ;
5959
6060Error . prepareStackTrace = function ( error , structured_stack_trace ) {
61- console . log ( 'Error.prepareStackTrace' ) ;
62- console . log ( arguments ) ;
6361 error . __cached_trace__ = structured_stack_trace . filter ( function ( f ) {
64- console . log ( f ) ;
6562 return f . getFileName ( ) !== filename ;
6663 } ) ;
6764
68- if ( ! error . __previous__ && current_trace_error ) {
65+ if ( ! error . __previous__ && current_trace_error && current_trace_error !== error ) {
6966 error . __previous__ = current_trace_error ;
7067 }
7168
7269 ++ in_prepare ;
7370 var previous_trace = error . __previous__ ? error . __previous__ . stack : null ;
7471 -- in_prepare ;
72+
7573 if ( previous_trace ) {
7674 error . __cached_trace__ . push ( create_callsite ( exports . empty_frame ) ) ;
7775 Array . prototype . push . apply ( error . __cached_trace__ , previous_trace ) ;
7876 }
79-
77+
8078 if ( in_prepare > 0 ) { return error . __cached_trace__ ; }
8179 return exports . format_stack ( error , error . __cached_trace__ ) ;
8280} ;
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ describe('longjohn', function() {
2121
2222 it ( 'should track frames across setTimeout' , function ( done ) {
2323 setTimeout ( function ( ) {
24- console . log ( new Error ( 'foobar' ) . stack ) ;
24+ assert . equal ( new Error ( 'foobar' ) . stack . split ( longjohn . empty_frame ) . length , 2 ) ;
25+ done ( ) ;
2526 } , 1 ) ;
2627 } ) ;
2728
@@ -32,15 +33,7 @@ describe('longjohn', function() {
3233
3334 var foo = function ( ) {
3435 if ( ++ counter > 3 ) {
35- assert . throws ( function ( ) {
36- try {
37- throw new Error ( 'foo' ) ;
38- } catch ( e ) {
39- throw e ;
40- }
41- } , function ( err ) {
42- return err . stack . split ( longjohn . empty_frame ) . length === 3 ;
43- } ) ;
36+ assert . equal ( new Error ( 'foo' ) . stack . split ( longjohn . empty_frame ) . length , 3 ) ;
4437 return done ( ) ;
4538 }
4639 setTimeout ( foo , 1 ) ;
@@ -90,13 +83,14 @@ describe('longjohn', function() {
9083 setTimeout ( function ( ) {
9184 assert . deepEqual ( Array . prototype . slice . call ( arguments ) , [ 1 , 2 , 3 ] ) ;
9285 done ( ) ;
93- } , 1000 , 1 , 2 , 3 ) ;
86+ } , 1 , 1 , 2 , 3 ) ;
9487 } ) ;
9588
9689 it ( 'should work with setInterval' , function ( done ) {
97- setInterval ( function ( ) {
90+ var interval_id = setInterval ( function ( ) {
9891 assert . deepEqual ( Array . prototype . slice . call ( arguments ) , [ 1 , 2 , 3 ] ) ;
92+ clearInterval ( interval_id ) ;
9993 done ( ) ;
100- } , 1000 , 1 , 2 , 3 ) ;
94+ } , 1 , 1 , 2 , 3 ) ;
10195 } ) ;
10296} ) ;
You can’t perform that action at this time.
0 commit comments