Skip to content

Commit b0c441c

Browse files
cjihrigrvagg
authored andcommitted
test: s/assert.fail/common.fail as appropriate
Many tests use assert.fail(null, null, msg) where it would be simpler to use common.fail(msg). This is largely because common.fail() is fairly new. This commit makes the replacement when applicable. PR-URL: #7735 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent af16339 commit b0c441c

25 files changed

+46
-56
lines changed

test/internet/test-dgram-send-cb-quelches-error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function callbackOnly(err) {
2828
}
2929

3030
function onEvent(err) {
31-
assert.fail(null, null, 'Error should not be emitted if there is callback');
31+
common.fail('Error should not be emitted if there is callback');
3232
}
3333

3434
function onError(err) {

test/parallel/test-event-emitter-listeners-side-effects.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44
var assert = require('assert');
55

66
var EventEmitter = require('events').EventEmitter;
@@ -13,12 +13,12 @@ assert(Array.isArray(fl));
1313
assert(fl.length === 0);
1414
assert.deepEqual(e._events, {});
1515

16-
e.on('foo', assert.fail);
16+
e.on('foo', common.fail);
1717
fl = e.listeners('foo');
18-
assert(e._events.foo === assert.fail);
18+
assert(e._events.foo === common.fail);
1919
assert(Array.isArray(fl));
2020
assert(fl.length === 1);
21-
assert(fl[0] === assert.fail);
21+
assert(fl[0] === common.fail);
2222

2323
e.listeners('bar');
2424
assert(!e._events.hasOwnProperty('bar'));
@@ -28,12 +28,12 @@ fl = e.listeners('foo');
2828

2929
assert(Array.isArray(e._events.foo));
3030
assert(e._events.foo.length === 2);
31-
assert(e._events.foo[0] === assert.fail);
31+
assert(e._events.foo[0] === common.fail);
3232
assert(e._events.foo[1] === assert.ok);
3333

3434
assert(Array.isArray(fl));
3535
assert(fl.length === 2);
36-
assert(fl[0] === assert.fail);
36+
assert(fl[0] === common.fail);
3737
assert(fl[1] === assert.ok);
3838

3939
console.log('ok');

test/parallel/test-event-emitter-once.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
var assert = require('assert');
44
var events = require('events');
55

@@ -16,7 +16,7 @@ e.emit('hello', 'a', 'b');
1616
e.emit('hello', 'a', 'b');
1717

1818
var remove = function() {
19-
assert.fail(1, 0, 'once->foo should not be emitted', '!');
19+
common.fail('once->foo should not be emitted');
2020
};
2121

2222
e.once('foo', remove);

test/parallel/test-http-client-reject-chunked-with-content-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ server.listen(0, () => {
1818
// both a Content-Length header and a Transfer-Encoding: chunked
1919
// header, which is a violation of the HTTP spec.
2020
const req = http.get({port: server.address().port}, (res) => {
21-
assert.fail(null, null, 'callback should not be called');
21+
common.fail('callback should not be called');
2222
});
2323
req.on('error', common.mustCall((err) => {
2424
assert(/^Parse Error/.test(err.message));

test/parallel/test-http-client-reject-cr-no-lf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ server.listen(0, () => {
1717
// The callback should not be called because the server is sending a
1818
// header field that ends only in \r with no following \n
1919
const req = http.get({port: server.address().port}, (res) => {
20-
assert.fail(null, null, 'callback should not be called');
20+
common.fail('callback should not be called');
2121
});
2222
req.on('error', common.mustCall((err) => {
2323
assert(/^Parse Error/.test(err.message));

test/parallel/test-http-double-content-length.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ server.listen(0, () => {
2323
// Send two content-length header values.
2424
headers: {'Content-Length': [1, 2]}},
2525
(res) => {
26-
assert.fail(null, null, 'an error should have occurred');
27-
server.close();
26+
common.fail('an error should have occurred');
2827
}
2928
);
3029
req.on('error', common.mustCall(() => {

test/parallel/test-http-localaddress-bind-error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
var assert = require('assert');
44
var http = require('http');
55

@@ -24,7 +24,7 @@ server.listen(0, '127.0.0.1', function() {
2424
method: 'GET',
2525
localAddress: invalidLocalAddress
2626
}, function(res) {
27-
assert.fail(null, null, 'unexpectedly got response from server');
27+
common.fail('unexpectedly got response from server');
2828
}).on('error', function(e) {
2929
console.log('client got error: ' + e.message);
3030
gotError = true;

test/parallel/test-http-response-multi-content-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const server = http.createServer((req, res) => {
1919
res.writeHead(200, {'content-length': [1, 2]});
2020
break;
2121
default:
22-
assert.fail(null, null, 'should never get here');
22+
common.fail('should never get here');
2323
}
2424
res.end('ok');
2525
});

test/parallel/test-http-response-splitting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const server = http.createServer((req, res) => {
3838
}));
3939
break;
4040
default:
41-
assert.fail(null, null, 'should not get to here.');
41+
common.fail('should not get to here.');
4242
}
4343
if (count === 3)
4444
server.close();

test/parallel/test-http-server-reject-chunked-with-content-length.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const reqstr = 'POST / HTTP/1.1\r\n' +
1010
'Transfer-Encoding: chunked\r\n\r\n';
1111

1212
const server = http.createServer((req, res) => {
13-
assert.fail(null, null, 'callback should not be invoked');
13+
common.fail('callback should not be invoked');
1414
});
1515
server.on('clientError', common.mustCall((err) => {
1616
assert(/^Parse Error/.test(err.message));
@@ -25,7 +25,7 @@ server.listen(0, () => {
2525
client.on('data', (data) => {
2626
// Should not get to this point because the server should simply
2727
// close the connection without returning any data.
28-
assert.fail(null, null, 'no data should be returned by the server');
28+
common.fail('no data should be returned by the server');
2929
});
3030
client.on('end', common.mustCall(() => {}));
3131
});

0 commit comments

Comments
 (0)