Skip to content

Commit 3ed0204

Browse files
cjihrigevanlucas
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 1f00359 commit 3ed0204

27 files changed

+47
-57
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;
@@ -14,12 +14,12 @@ assert(fl.length === 0);
1414
assert(!(e._events instanceof Object));
1515
assert.deepStrictEqual(Object.keys(e._events), []);
1616

17-
e.on('foo', assert.fail);
17+
e.on('foo', common.fail);
1818
fl = e.listeners('foo');
19-
assert(e._events.foo === assert.fail);
19+
assert(e._events.foo === common.fail);
2020
assert(Array.isArray(fl));
2121
assert(fl.length === 1);
22-
assert(fl[0] === assert.fail);
22+
assert(fl[0] === common.fail);
2323

2424
e.listeners('bar');
2525

@@ -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-createConnection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const server = http.createServer(common.mustCall(function(req, res) {
2121
res.resume();
2222
fn = common.mustCall(createConnectionError);
2323
http.get({ createConnection: fn }, function(res) {
24-
assert.fail(null, null, 'Unexpected response callback');
24+
common.fail('Unexpected response callback');
2525
}).on('error', common.mustCall(function(err) {
2626
assert.equal(err.message, 'Could not create socket');
2727
server.close();

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();

0 commit comments

Comments
 (0)