Skip to content

Commit 6abbe17

Browse files
Trottevanlucas
authored andcommitted
test: favor strict equality in http tests
PR-URL: #8151 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: jasnell - James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent cc9bb34 commit 6abbe17

17 files changed

+32
-32
lines changed

‎test/parallel/test-http-agent.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ server.listen(0, function(){
1919
for(varj=0;j<M;j++){
2020
http.get({port: port,path: '/'},function(res){
2121
console.log('%d %d',responses,res.statusCode);
22-
if(++responses==N*M){
22+
if(++responses===N*M){
2323
console.error('Received all responses, closing server');
2424
server.close();
2525
}

‎test/parallel/test-http-allow-req-after-204-res.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function nextRequest(){
2828
path: '/'
2929
},function(response){
3030
response.on('end',function(){
31-
if(methods.length==0){
31+
if(methods.length===0){
3232
console.error('close server');
3333
server.close();
3434
}else{

‎test/parallel/test-http-client-abort.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ server.listen(0, function(){
3737
console.log('Client response code '+res.statusCode);
3838

3939
res.resume();
40-
if(++responses==N){
40+
if(++responses===N){
4141
console.log('All clients connected, destroying.');
4242
requests.forEach(function(outReq){
4343
console.log('abort');

‎test/parallel/test-http-client-timeout-agent.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ server.listen(0, options.host, function(){
7171

7272
process.on('exit',function(){
7373
console.error('done=%j sent=%j',requests_done,requests_sent);
74-
assert.ok(requests_done==requests_sent,
75-
'timeout on http request called too much');
74+
assert.strictEqual(requests_done,requests_sent,
75+
'timeout on http request called too much');
7676
});

‎test/parallel/test-http-exceptions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ var exception_count = 0;
2020
process.on('uncaughtException',function(err){
2121
console.log('Caught an exception: '+err);
2222
if(err.name==='AssertionError')throwerr;
23-
if(++exception_count==4)process.exit(0);
23+
if(++exception_count===4)process.exit(0);
2424
});
2525

‎test/parallel/test-http-expect-continue.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ server.on('listening', function(){
5858
assert.equal(body,test_res_body,'Response body doesn\'t match.');
5959
assert.ok('abcd'inres.headers,'Response headers missing.');
6060
outstanding_reqs--;
61-
if(outstanding_reqs==0){
61+
if(outstanding_reqs===0){
6262
server.close();
6363
process.exit();
6464
}

‎test/parallel/test-http-get-pipeline-problem.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var total = 10;
1919
varrequests=0,responses=0;
2020

2121
varserver=http.Server(function(req,res){
22-
if(++requests==total){
22+
if(++requests===total){
2323
server.close();
2424
}
2525

@@ -51,7 +51,7 @@ server.listen(0, function(){
5151

5252
s.on('finish',function(){
5353
console.error('done '+x);
54-
if(++responses==total){
54+
if(++responses===total){
5555
checkFiles();
5656
}
5757
});

‎test/parallel/test-http-incoming-pipelined-socket-destroy.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ server.listen(0, function(){
5252
varclient=net.connect({port: this.address().port});
5353
vardone=0;
5454
server.on('requestDone',function(){
55-
if(++done==seeds.length){
55+
if(++done===seeds.length){
5656
server.close();
5757
}
5858
});

‎test/parallel/test-http-legacy.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var body0 = ''
99
varbody1='';
1010

1111
varserver=http.createServer(function(req,res){
12-
if(responses_sent==0){
12+
if(responses_sent===0){
1313
assert.equal('GET',req.method);
1414
assert.equal('/hello',url.parse(req.url).pathname);
1515

@@ -21,7 +21,7 @@ var server = http.createServer(function(req, res){
2121
assert.equal('bar',req.headers['foo']);
2222
}
2323

24-
if(responses_sent==1){
24+
if(responses_sent===1){
2525
assert.equal('POST',req.method);
2626
assert.equal('/world',url.parse(req.url).pathname);
2727
this.close();

‎test/parallel/test-http-malformed-request.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var server = http.createServer(function(req, res){
1818
res.write('Hello World');
1919
res.end();
2020

21-
if(++nrequests_completed==nrequests_expected)server.close();
21+
if(++nrequests_completed===nrequests_expected)server.close();
2222
});
2323
server.listen(0);
2424

0 commit comments

Comments
(0)