@@ -29,7 +29,7 @@ exports.tmpDir = path.join(exports.testDir, 'tmp');
29
29
exports . PORT = 12346 ;
30
30
exports . PROXY_PORT = 1234567 ;
31
31
32
- if ( process . platform == 'win32' ) {
32
+ if ( process . platform === 'win32' ) {
33
33
exports . PIPE = '\\\\.\\pipe\\libuv-test' ;
34
34
} else {
35
35
exports . PIPE = exports . tmpDir + '/test.sock' ;
@@ -54,9 +54,10 @@ exports.indirectInstanceOf = function(obj, cls) {
54
54
55
55
56
56
exports . ddCommand = function ( filename , kilobytes ) {
57
- if ( process . platform == 'win32' ) {
58
- return '"' + process . argv [ 0 ] + '" "' + path . resolve ( exports . fixturesDir ,
59
- 'create-file.js' ) + '" "' + filename + '" ' + ( kilobytes * 1024 ) ;
57
+ if ( process . platform === 'win32' ) {
58
+ var p = path . resolve ( exports . fixturesDir , 'create-file.js' ) ;
59
+ return '"' + process . argv [ 0 ] + '" "' + p + '" "' +
60
+ filename + '" ' + ( kilobytes * 1024 ) ;
60
61
} else {
61
62
return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes ;
62
63
}
@@ -66,7 +67,7 @@ exports.ddCommand = function(filename, kilobytes) {
66
67
exports . spawnPwd = function ( options ) {
67
68
var spawn = require ( 'child_process' ) . spawn ;
68
69
69
- if ( process . platform == 'win32' ) {
70
+ if ( process . platform === 'win32' ) {
70
71
return spawn ( 'cmd.exe' , [ '/c' , 'cd' ] , options ) ;
71
72
} else {
72
73
return spawn ( 'pwd' , [ ] , options ) ;
@@ -81,8 +82,10 @@ process.on('exit', function() {
81
82
if ( ! exports . globalCheck ) return ;
82
83
var knownGlobals = [ setTimeout ,
83
84
setInterval ,
85
+ setImmediate ,
84
86
clearTimeout ,
85
87
clearInterval ,
88
+ clearImmediate ,
86
89
console ,
87
90
Buffer ,
88
91
process ,
@@ -111,6 +114,7 @@ process.on('exit', function() {
111
114
knownGlobals . push ( ArrayBuffer ) ;
112
115
knownGlobals . push ( Int8Array ) ;
113
116
knownGlobals . push ( Uint8Array ) ;
117
+ knownGlobals . push ( Uint8ClampedArray ) ;
114
118
knownGlobals . push ( Int16Array ) ;
115
119
knownGlobals . push ( Uint16Array ) ;
116
120
knownGlobals . push ( Int32Array ) ;
@@ -138,8 +142,43 @@ process.on('exit', function() {
138
142
} ) ;
139
143
140
144
141
- // This function allows one two run an HTTP test agaist both HTTPS and
142
- // normal HTTP modules. This ensures they fit the same API.
143
- exports . httpTest = function httpTest ( cb ) {
144
- } ;
145
+ var mustCallChecks = [ ] ;
146
+
147
+
148
+ function runCallChecks ( ) {
149
+ var failed = mustCallChecks . filter ( function ( context ) {
150
+ return context . actual !== context . expected ;
151
+ } ) ;
152
+
153
+ failed . forEach ( function ( context ) {
154
+ console . log ( 'Mismatched %s function calls. Expected %d, actual %d.' ,
155
+ context . name ,
156
+ context . expected ,
157
+ context . actual ) ;
158
+ console . log ( context . stack . split ( '\n' ) . slice ( 2 ) . join ( '\n' ) ) ;
159
+ } ) ;
160
+
161
+ if ( failed . length ) process . exit ( 1 ) ;
162
+ }
145
163
164
+
165
+ exports . mustCall = function ( fn , expected ) {
166
+ if ( typeof expected !== 'number' ) expected = 1 ;
167
+
168
+ var context = {
169
+ expected : expected ,
170
+ actual : 0 ,
171
+ stack : ( new Error ) . stack ,
172
+ name : fn . name || '<anonymous>'
173
+ } ;
174
+
175
+ // add the exit listener only once to avoid listener leak warnings
176
+ if ( mustCallChecks . length === 0 ) process . on ( 'exit' , runCallChecks ) ;
177
+
178
+ mustCallChecks . push ( context ) ;
179
+
180
+ return function ( ) {
181
+ context . actual ++ ;
182
+ return fn . apply ( this , arguments ) ;
183
+ } ;
184
+ } ;
0 commit comments