@@ -82,9 +82,10 @@ doh = {
82
82
var myT = new function ( ) {
83
83
this . _assertClosure = function ( method , args ) {
84
84
// If the Deferred instance is already "done", means callback or errback
85
- // had already been called dont do it again.
85
+ // had already been called don't do it again.
86
86
// This might be the case when e.g. the test timed out.
87
87
if ( d . fired > - 1 ) {
88
+ console . log ( 'FIXXXXXME multiple asserts or timeout ... d.fired = ' , d . fired , "GROUP and TEST: '" , d . test . group . name , "' " , d . test . name ) ;
88
89
return ;
89
90
}
90
91
try {
@@ -94,10 +95,16 @@ doh = {
94
95
d . errback ( e ) ;
95
96
}
96
97
} ;
98
+ var that = this ;
97
99
for ( var methodName in doh . assert ) {
98
100
if ( methodName . indexOf ( "assert" ) === 0 ) {
99
101
this [ methodName ] = ( function ( methodName ) { return function ( ) {
100
- this . _assertClosure ( methodName , arguments ) ;
102
+ // Make sure the current callstack is worked off before
103
+ // returning from any assert() method, we do this by
104
+ // setTimeout(). The bug was that assert() didn't make the
105
+ // test execute the return statement (if one was in there)
106
+ // before the test ended, this fixes it.
107
+ setTimeout ( doh . util . hitch ( that , "_assertClosure" , methodName , arguments ) , 1 ) ;
101
108
} } ) ( methodName ) ;
102
109
}
103
110
}
@@ -155,8 +162,8 @@ doh = {
155
162
if ( t . setUp ) {
156
163
t . setUp ( assertWrapperObject ) ;
157
164
}
158
- if ( ! t . test ) {
159
- t . test = function ( ) { deferred . errback ( new Error ( "Test missing." ) ) ; }
165
+ if ( ! t [ this . config . testFunctionName ] ) {
166
+ t [ this . config . testFunctionName ] = function ( ) { deferred . errback ( new Error ( "Test missing." ) ) ; }
160
167
}
161
168
deferred . groupName = g . name ;
162
169
deferred . test = t ;
@@ -207,6 +214,6 @@ doh = {
207
214
this . _testInFlight = true ;
208
215
209
216
t . startTime = new Date ( ) ;
210
- t . result = t . test ( assertWrapperObject ) ;
217
+ t . result = t [ this . config . testFunctionName ] ( assertWrapperObject ) ;
211
218
}
212
219
}
0 commit comments