mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
97f76f3f04
There are a few places where tests repeatedly concatenate strings to themselves in order to make them very long. Using `.repeat()` makes the code clearer. For example, before: for (var i = 0; i < 8; ++i) lots_of_headers += lots_of_headers; After: lots_of_headers = lots_of_headers.repeat(256); Using `.repeat()` makes it clear that the string will be repeated 256 times rather than 8 times. ("What?! That first one doesn't repeat 256 times! It only repeats 8... Oh, wait. Yes, I see your point now.") PR-URL: https://github.com/nodejs/node/pull/5311 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
31 lines
728 B
JavaScript
31 lines
728 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
|
|
var net = require('net');
|
|
|
|
var expected_bad_connections = 1;
|
|
var actual_bad_connections = 0;
|
|
|
|
var host = '*'.repeat(256);
|
|
|
|
function do_not_call() {
|
|
throw new Error('This function should not have been called.');
|
|
}
|
|
|
|
var socket = net.connect(42, host, do_not_call);
|
|
socket.on('error', function(err) {
|
|
assert.equal(err.code, 'ENOTFOUND');
|
|
actual_bad_connections++;
|
|
});
|
|
socket.on('lookup', function(err, ip, type) {
|
|
assert(err instanceof Error);
|
|
assert.equal(err.code, 'ENOTFOUND');
|
|
assert.equal(ip, undefined);
|
|
assert.equal(type, undefined);
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(actual_bad_connections, expected_bad_connections);
|
|
});
|