File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ var test = require ( '../' ) ;
2+
3+ test ( 'a simple test' , function ( t ) {
4+ t . plan ( 2 ) ;
5+
6+ t . equal ( typeof Date . now , 'function' ) ;
7+ var start = Date . now ( ) ;
8+
9+ setTimeout ( function ( ) {
10+ t . equal ( Date . now ( ) - start , 100 ) ;
11+ } , 100 ) ;
12+ } ) ;
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ Test.prototype.plan = function (n) {
3939
4040Test . prototype . end = function ( ) {
4141 if ( ! this . ended ) this . emit ( 'end' ) ;
42+ if ( ! this . _planError && this . assertCount !== this . _plan ) {
43+ this . _planError = true ;
44+ this . fail ( 'plan != count' , {
45+ expected : this . _plan ,
46+ actual : this . assertCount
47+ } ) ;
48+ }
4249 this . ended = true ;
4350} ;
4451
@@ -68,6 +75,14 @@ Test.prototype._assert = function assert (ok, opts) {
6875 if ( ! self . ended ) self . end ( ) ;
6976 } ) ;
7077 }
78+
79+ if ( ! self . _planError && self . assertCount > self . _plan ) {
80+ self . _planError = true ;
81+ self . fail ( 'plan != count' , {
82+ expected : self . _plan ,
83+ actual : self . assertCount
84+ } ) ;
85+ }
7186} ;
7287
7388Test . prototype . fail = function ( msg , extra ) {
You can’t perform that action at this time.
0 commit comments