@@ -16,16 +16,6 @@ Test.prototype.comment = function (msg) {
16
16
this . result ( '\n' + msg . trim ( ) ) ;
17
17
} ;
18
18
19
- Test . prototype . result = function ( res ) {
20
- var self = this ;
21
- self . emit ( 'result' , res ) ;
22
- if ( self . _plan === self . assertCount ) {
23
- process . nextTick ( function ( ) {
24
- if ( ! self . ended ) self . end ( ) ;
25
- } ) ;
26
- }
27
- } ;
28
-
29
19
Test . prototype . plan = function ( n ) {
30
20
this . _plan = n ;
31
21
} ;
@@ -36,9 +26,11 @@ Test.prototype.end = function () {
36
26
} ;
37
27
38
28
Test . prototype . _assert = function assert ( ok , opts ) {
29
+ var self = this ;
39
30
var extra = opts . extra || { } ;
31
+
40
32
var res = {
41
- id : this . assertCount ++ ,
33
+ id : self . assertCount ++ ,
42
34
ok : Boolean ( ok ) ,
43
35
skip : defined ( extra . skip , opts . skip ) ,
44
36
name : defined ( extra . message , opts . message , '(unnamed assert)' ) ,
@@ -50,7 +42,14 @@ Test.prototype._assert = function assert (ok, opts) {
50
42
if ( ! ok ) {
51
43
res . error = defined ( extra . error , opts . error , new Error ( res . name ) ) ;
52
44
}
53
- this . emit ( 'result' , res ) ;
45
+
46
+ self . emit ( 'result' , res ) ;
47
+
48
+ if ( self . _plan === self . assertCount ) {
49
+ process . nextTick ( function ( ) {
50
+ if ( ! self . ended ) self . end ( ) ;
51
+ } ) ;
52
+ }
54
53
} ;
55
54
56
55
Test . prototype . fail = function ( msg , extra ) {
0 commit comments