summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-04-27 17:27:05 -0700
committerRich Trott <rtrott@gmail.com>2017-05-01 15:56:58 -0700
commita180259e428fbc3e220abdceb74d941482b87d40 (patch)
tree03377e9542c521963dbf6708b6b829899a7abaf7 /test
parentdd20e68b0feb966c2a7439c947bbb4d46e3b19fe (diff)
downloadandroid-node-v8-a180259e428fbc3e220abdceb74d941482b87d40.tar.gz
android-node-v8-a180259e428fbc3e220abdceb74d941482b87d40.tar.bz2
android-node-v8-a180259e428fbc3e220abdceb74d941482b87d40.zip
test,lib,doc: use function declarations
Replace function expressions with function declarations in preparation for a lint rule requiring function declarations. PR-URL: https://github.com/nodejs/node/pull/12711 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/addons-napi/test_async/test.js5
-rw-r--r--test/addons-napi/test_exception/test.js6
-rw-r--r--test/addons-napi/test_instanceof/test.js4
-rw-r--r--test/addons/make-callback/test.js4
-rw-r--r--test/inspector/inspector-helper.js8
-rw-r--r--test/parallel/test-assert.js3
-rw-r--r--test/parallel/test-child-process-fork-dgram.js4
-rw-r--r--test/parallel/test-child-process-fork-net.js12
-rw-r--r--test/parallel/test-child-process-fork-net2.js4
-rw-r--r--test/parallel/test-child-process-spawn-typeerror.js2
-rw-r--r--test/parallel/test-cluster-disconnect.js8
-rw-r--r--test/parallel/test-cluster-master-error.js2
-rw-r--r--test/parallel/test-cluster-master-kill.js2
-rw-r--r--test/parallel/test-cluster-message.js2
-rw-r--r--test/parallel/test-cluster-worker-exit.js2
-rw-r--r--test/parallel/test-console-not-call-toString.js2
-rw-r--r--test/parallel/test-event-emitter-add-listeners.js4
-rw-r--r--test/parallel/test-event-emitter-once.js4
-rw-r--r--test/parallel/test-fs-access.js4
-rw-r--r--test/parallel/test-fs-link.js4
-rw-r--r--test/parallel/test-fs-read-stream-fd-leak.js4
-rw-r--r--test/parallel/test-http-parser.js94
-rw-r--r--test/parallel/test-http-response-status-message.js4
-rw-r--r--test/parallel/test-https-simple.js2
-rw-r--r--test/parallel/test-net-server-max-connections-close-makes-more-available.js8
-rw-r--r--test/parallel/test-net-server-pause-on-connect.js4
-rw-r--r--test/parallel/test-os.js4
-rw-r--r--test/parallel/test-preload.js6
-rw-r--r--test/parallel/test-querystring.js2
-rw-r--r--test/parallel/test-readline-interface.js4
-rw-r--r--test/parallel/test-stream2-pipe-error-once-listener.js8
-rw-r--r--test/parallel/test-timers-ordering.js4
-rw-r--r--test/parallel/test-util-inspect.js2
-rw-r--r--test/pummel/test-dtrace-jsstack.js6
-rw-r--r--test/pummel/test-tls-session-timeout.js6
35 files changed, 120 insertions, 124 deletions
diff --git a/test/addons-napi/test_async/test.js b/test/addons-napi/test_async/test.js
index 7c140d79fc..2b4577624a 100644
--- a/test/addons-napi/test_async/test.js
+++ b/test/addons-napi/test_async/test.js
@@ -6,8 +6,7 @@ const test_async = require(`./build/${common.buildType}/test_async`);
test_async.Test(5, common.mustCall(function(err, val) {
assert.strictEqual(err, null);
assert.strictEqual(val, 10);
- process.nextTick(common.mustCall(function() {}));
+ process.nextTick(common.mustCall());
}));
-const cancelSuceeded = function() {};
-test_async.TestCancel(common.mustCall(cancelSuceeded));
+test_async.TestCancel(common.mustCall());
diff --git a/test/addons-napi/test_exception/test.js b/test/addons-napi/test_exception/test.js
index 83d2b5000e..94f9566a4b 100644
--- a/test/addons-napi/test_exception/test.js
+++ b/test/addons-napi/test_exception/test.js
@@ -4,12 +4,12 @@ const common = require('../../common');
const test_exception = require(`./build/${common.buildType}/test_exception`);
const assert = require('assert');
const theError = new Error('Some error');
-const throwTheError = function() {
+function throwTheError() {
throw theError;
-};
+}
let caughtError;
-const throwNoError = function() {};
+const throwNoError = common.noop;
// Test that the native side successfully captures the exception
let returnedError = test_exception.returnException(throwTheError);
diff --git a/test/addons-napi/test_instanceof/test.js b/test/addons-napi/test_instanceof/test.js
index 38d17031e9..418149d190 100644
--- a/test/addons-napi/test_instanceof/test.js
+++ b/test/addons-napi/test_instanceof/test.js
@@ -57,14 +57,14 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
(theObject instanceof theConstructor));
}
- const MyClass = function MyClass() {};
+ function MyClass() {}
Object.defineProperty(MyClass, Symbol.hasInstance, {
value: function(candidate) {
return 'mark' in candidate;
}
});
- const MySubClass = function MySubClass() {};
+ function MySubClass() {}
MySubClass.prototype = new MyClass();
let x = new MySubClass();
diff --git a/test/addons/make-callback/test.js b/test/addons/make-callback/test.js
index b67d1146a6..efea43df3c 100644
--- a/test/addons/make-callback/test.js
+++ b/test/addons/make-callback/test.js
@@ -57,9 +57,9 @@ const forward = vm.runInNewContext(`
})
`);
// Runs in outer context.
-const endpoint = function($Object) {
+function endpoint($Object) {
if (Object === $Object)
throw new Error('bad');
return Object;
-};
+}
assert.strictEqual(Object, makeCallback(process, forward, endpoint));
diff --git a/test/inspector/inspector-helper.js b/test/inspector/inspector-helper.js
index 05dd773552..2fb6a0e999 100644
--- a/test/inspector/inspector-helper.js
+++ b/test/inspector/inspector-helper.js
@@ -122,7 +122,7 @@ function timeout(message, multiplicator) {
TIMEOUT * (multiplicator || 1));
}
-const TestSession = function(socket, harness) {
+function TestSession(socket, harness) {
this.mainScriptPath = harness.mainScriptPath;
this.mainScriptId = null;
@@ -147,7 +147,7 @@ const TestSession = function(socket, harness) {
buffer = buffer.slice(consumed);
} while (consumed);
}).on('close', () => assert(this.expectClose_, 'Socket closed prematurely'));
-};
+}
TestSession.prototype.scriptUrlForId = function(id) {
return this.scripts_[id];
@@ -304,7 +304,7 @@ TestSession.prototype.testHttpResponse = function(path, check) {
};
-const Harness = function(port, childProcess) {
+function Harness(port, childProcess) {
this.port = port;
this.mainScriptPath = mainScript;
this.stderrFilters_ = [];
@@ -329,7 +329,7 @@ const Harness = function(port, childProcess) {
this.returnCode_ = code;
this.running_ = false;
});
-};
+}
Harness.prototype.addStderrFilter = function(regexp, callback) {
this.stderrFilters_.push((message) => {
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index 89a54df81a..568f23344e 100644
--- a/test/parallel/test-assert.js
+++ b/test/parallel/test-assert.js
@@ -449,7 +449,7 @@ a.throws(makeBlock(thrower, TypeError), function(err) {
AnotherErrorType = class extends Error {};
- const functionThatThrows = function() {
+ const functionThatThrows = () => {
throw new AnotherErrorType('foo');
};
@@ -493,6 +493,7 @@ a.throws(makeBlock(a.deepEqual, args, []));
// more checking that arguments objects are handled correctly
{
+ // eslint-disable-next-line func-style
const returnArguments = function() { return arguments; };
const someArgs = returnArguments('a');
diff --git a/test/parallel/test-child-process-fork-dgram.js b/test/parallel/test-child-process-fork-dgram.js
index 784e5e55f2..be351cced0 100644
--- a/test/parallel/test-child-process-fork-dgram.js
+++ b/test/parallel/test-child-process-fork-dgram.js
@@ -78,7 +78,7 @@ if (process.argv[2] === 'child') {
});
});
- const sendMessages = function() {
+ function sendMessages() {
const serverPort = parentServer.address().port;
const timer = setInterval(function() {
@@ -102,7 +102,7 @@ if (process.argv[2] === 'child') {
);
}
}, 1);
- };
+ }
parentServer.bind(0, '127.0.0.1');
diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js
index 42994007e8..de0ec6ca00 100644
--- a/test/parallel/test-child-process-fork-net.js
+++ b/test/parallel/test-child-process-fork-net.js
@@ -87,7 +87,7 @@ if (process.argv[2] === 'child') {
}));
// send net.Server to child and test by connecting
- const testServer = function(callback) {
+ function testServer(callback) {
// destroy server execute callback when done
const progress = new ProgressTracker(2, function() {
@@ -116,7 +116,7 @@ if (process.argv[2] === 'child') {
server.listen(0);
// handle client messages
- const messageHandlers = function(msg) {
+ function messageHandlers(msg) {
if (msg.what === 'listening') {
// make connections
@@ -138,13 +138,13 @@ if (process.argv[2] === 'child') {
child.removeListener('message', messageHandlers);
callback();
}
- };
+ }
child.on('message', messageHandlers);
- };
+ }
// send net.Socket to child
- const testSocket = function(callback) {
+ function testSocket(callback) {
// create a new server and connect to it,
// but the socket will be handled by the child
@@ -179,7 +179,7 @@ if (process.argv[2] === 'child') {
server.close();
});
});
- };
+ }
// create server and send it to child
let serverSuccess = false;
diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js
index 737720cd6a..b893685447 100644
--- a/test/parallel/test-child-process-fork-net2.js
+++ b/test/parallel/test-child-process-fork-net2.js
@@ -144,7 +144,7 @@ if (process.argv[2] === 'child') {
server.listen(0, '127.0.0.1');
- const closeServer = function() {
+ function closeServer() {
server.close();
setTimeout(function() {
@@ -153,7 +153,7 @@ if (process.argv[2] === 'child') {
child2.send('close');
child3.disconnect();
}, 200);
- };
+ }
process.on('exit', function() {
assert.strictEqual(disconnected, count);
diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js
index 70a0ea443c..cf5884b38f 100644
--- a/test/parallel/test-child-process-spawn-typeerror.js
+++ b/test/parallel/test-child-process-spawn-typeerror.js
@@ -89,7 +89,7 @@ assert.throws(function() {
// Argument types for combinatorics
const a = [];
const o = {};
-const c = function c() {};
+function c() {}
const s = 'string';
const u = undefined;
const n = null;
diff --git a/test/parallel/test-cluster-disconnect.js b/test/parallel/test-cluster-disconnect.js
index 0f43b4ef59..2286ca1d67 100644
--- a/test/parallel/test-cluster-disconnect.js
+++ b/test/parallel/test-cluster-disconnect.js
@@ -38,7 +38,7 @@ if (cluster.isWorker) {
const servers = 2;
// test a single TCP server
- const testConnection = function(port, cb) {
+ const testConnection = (port, cb) => {
const socket = net.connect(port, '127.0.0.1', () => {
// buffer result
let result = '';
@@ -52,7 +52,7 @@ if (cluster.isWorker) {
};
// test both servers created in the cluster
- const testCluster = function(cb) {
+ const testCluster = (cb) => {
let done = 0;
for (let i = 0; i < servers; i++) {
@@ -67,7 +67,7 @@ if (cluster.isWorker) {
};
// start two workers and execute callback when both is listening
- const startCluster = function(cb) {
+ const startCluster = (cb) => {
const workers = 8;
let online = 0;
@@ -81,7 +81,7 @@ if (cluster.isWorker) {
}
};
- const test = function(again) {
+ const test = (again) => {
//1. start cluster
startCluster(common.mustCall(() => {
//2. test cluster
diff --git a/test/parallel/test-cluster-master-error.js b/test/parallel/test-cluster-master-error.js
index 0a2dcc43fa..cc104ec441 100644
--- a/test/parallel/test-cluster-master-error.js
+++ b/test/parallel/test-cluster-master-error.js
@@ -101,7 +101,7 @@ if (cluster.isWorker) {
// Check that the cluster died accidentally (non-zero exit code)
masterExited = !!code;
- const pollWorkers = function() {
+ const pollWorkers = () => {
// When master is dead all workers should be dead too
let alive = false;
workers.forEach((pid) => alive = common.isAlive(pid));
diff --git a/test/parallel/test-cluster-master-kill.js b/test/parallel/test-cluster-master-kill.js
index f195599b3f..f00dc48b71 100644
--- a/test/parallel/test-cluster-master-kill.js
+++ b/test/parallel/test-cluster-master-kill.js
@@ -68,7 +68,7 @@ if (cluster.isWorker) {
assert.strictEqual(code, 0);
// check worker process status
- const pollWorker = function() {
+ const pollWorker = () => {
alive = common.isAlive(pid);
if (alive) {
setTimeout(pollWorker, 50);
diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js
index ee7100185a..df9f8ca2a4 100644
--- a/test/parallel/test-cluster-message.js
+++ b/test/parallel/test-cluster-message.js
@@ -80,7 +80,7 @@ if (cluster.isWorker) {
let client;
- const check = function(type, result) {
+ const check = (type, result) => {
checks[type].receive = true;
checks[type].correct = result;
console.error('check', checks);
diff --git a/test/parallel/test-cluster-worker-exit.js b/test/parallel/test-cluster-worker-exit.js
index db8835abe4..18d6fe25eb 100644
--- a/test/parallel/test-cluster-worker-exit.js
+++ b/test/parallel/test-cluster-worker-exit.js
@@ -103,7 +103,7 @@ if (cluster.isWorker) {
}
}));
- const finish_test = function() {
+ const finish_test = () => {
try {
checkResults(expected_results, results);
} catch (exc) {
diff --git a/test/parallel/test-console-not-call-toString.js b/test/parallel/test-console-not-call-toString.js
index 3c2df00d47..0f6f2624c5 100644
--- a/test/parallel/test-console-not-call-toString.js
+++ b/test/parallel/test-console-not-call-toString.js
@@ -23,7 +23,7 @@
require('../common');
const assert = require('assert');
-const func = function() {};
+function func() {}
let toStringCalled = false;
func.toString = function() {
toStringCalled = true;
diff --git a/test/parallel/test-event-emitter-add-listeners.js b/test/parallel/test-event-emitter-add-listeners.js
index a4bfcb3442..d6177a7880 100644
--- a/test/parallel/test-event-emitter-add-listeners.js
+++ b/test/parallel/test-event-emitter-add-listeners.js
@@ -68,8 +68,8 @@ const EventEmitter = require('events');
}
{
- const listen1 = function listen1() {};
- const listen2 = function listen2() {};
+ const listen1 = () => {};
+ const listen2 = () => {};
const ee = new EventEmitter();
ee.once('newListener', function() {
diff --git a/test/parallel/test-event-emitter-once.js b/test/parallel/test-event-emitter-once.js
index 8a7bbbf9bc..6823a9805e 100644
--- a/test/parallel/test-event-emitter-once.js
+++ b/test/parallel/test-event-emitter-once.js
@@ -33,9 +33,9 @@ e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
e.emit('hello', 'a', 'b');
-const remove = function() {
+function remove() {
assert.fail('once->foo should not be emitted');
-};
+}
e.once('foo', remove);
e.removeListener('foo', remove);
diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js
index d5934dd614..f378824cbc 100644
--- a/test/parallel/test-fs-access.js
+++ b/test/parallel/test-fs-access.js
@@ -7,10 +7,10 @@ const doesNotExist = path.join(common.tmpDir, '__this_should_not_exist');
const readOnlyFile = path.join(common.tmpDir, 'read_only_file');
const readWriteFile = path.join(common.tmpDir, 'read_write_file');
-const createFileWithPerms = function(file, mode) {
+function createFileWithPerms(file, mode) {
fs.writeFileSync(file, '');
fs.chmodSync(file, mode);
-};
+}
common.refreshTmpDir();
createFileWithPerms(readOnlyFile, 0o444);
diff --git a/test/parallel/test-fs-link.js b/test/parallel/test-fs-link.js
index d110ff80fe..525392aa2b 100644
--- a/test/parallel/test-fs-link.js
+++ b/test/parallel/test-fs-link.js
@@ -11,11 +11,11 @@ const srcPath = path.join(common.tmpDir, 'hardlink-target.txt');
const dstPath = path.join(common.tmpDir, 'link1.js');
fs.writeFileSync(srcPath, 'hello world');
-const callback = function(err) {
+function callback(err) {
assert.ifError(err);
const dstContent = fs.readFileSync(dstPath, 'utf8');
assert.strictEqual('hello world', dstContent);
-};
+}
fs.link(srcPath, dstPath, common.mustCall(callback));
diff --git a/test/parallel/test-fs-read-stream-fd-leak.js b/test/parallel/test-fs-read-stream-fd-leak.js
index 0a7a42a3ba..e6594afefc 100644
--- a/test/parallel/test-fs-read-stream-fd-leak.js
+++ b/test/parallel/test-fs-read-stream-fd-leak.js
@@ -29,7 +29,7 @@ function testLeak(endFn, callback) {
let i = 0;
let check = 0;
- const checkFunction = function() {
+ function checkFunction() {
if (openCount !== 0 && check < totalCheck) {
check++;
setTimeout(checkFunction, 100);
@@ -44,7 +44,7 @@ function testLeak(endFn, callback) {
openCount = 0;
callback && setTimeout(callback, 100);
- };
+ }
setInterval(function() {
const s = fs.createReadStream(emptyTxt);
diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js
index a4e03ab4c3..b919891cbf 100644
--- a/test/parallel/test-http-parser.js
+++ b/test/parallel/test-http-parser.js
@@ -96,9 +96,9 @@ function expectBody(expected) {
'GET /hello HTTP/1.1' + CRLF +
CRLF);
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 1);
assert.strictEqual(method, methods.indexOf('GET'));
@@ -137,9 +137,9 @@ function expectBody(expected) {
CRLF +
'pong');
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, undefined);
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 1);
@@ -147,7 +147,7 @@ function expectBody(expected) {
assert.strictEqual(statusMessage, 'OK');
};
- const onBody = function(buf, start, len) {
+ const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, 'pong');
};
@@ -167,9 +167,9 @@ function expectBody(expected) {
'HTTP/1.0 200 Connection established' + CRLF +
CRLF);
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 0);
assert.strictEqual(method, undefined);
@@ -201,15 +201,15 @@ function expectBody(expected) {
let seen_body = false;
- const onHeaders = function(headers, url) {
+ const onHeaders = (headers, url) => {
assert.ok(seen_body); // trailers should come after the body
assert.deepStrictEqual(headers,
['Vary', '*', 'Content-Type', 'text/plain']);
};
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@@ -218,7 +218,7 @@ function expectBody(expected) {
parser[kOnHeaders] = mustCall(onHeaders);
};
- const onBody = function(buf, start, len) {
+ const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, 'ping');
seen_body = true;
@@ -242,9 +242,9 @@ function expectBody(expected) {
'X-Filler2: 42' + CRLF +
CRLF);
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('GET'));
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 0);
@@ -272,9 +272,9 @@ function expectBody(expected) {
lots_of_headers +
CRLF);
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('GET'));
assert.strictEqual(url || parser.url, '/foo/bar/baz?quux=42#1337');
assert.strictEqual(versionMajor, 1);
@@ -306,16 +306,16 @@ function expectBody(expected) {
CRLF +
'foo=42&bar=1337');
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
assert.strictEqual(versionMinor, 1);
};
- const onBody = function(buf, start, len) {
+ const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, 'foo=42&bar=1337');
};
@@ -344,9 +344,9 @@ function expectBody(expected) {
'1234567890' + CRLF +
'0' + CRLF);
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@@ -356,7 +356,7 @@ function expectBody(expected) {
let body_part = 0;
const body_parts = ['123', '123456', '1234567890'];
- const onBody = function(buf, start, len) {
+ const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, body_parts[body_part++]);
};
@@ -382,9 +382,9 @@ function expectBody(expected) {
'6' + CRLF +
'123456' + CRLF);
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@@ -395,7 +395,7 @@ function expectBody(expected) {
const body_parts =
['123', '123456', '123456789', '123456789ABC', '123456789ABCDEF'];
- const onBody = function(buf, start, len) {
+ const onBody = (buf, start, len) => {
const body = '' + buf.slice(start, start + len);
assert.strictEqual(body, body_parts[body_part++]);
};
@@ -440,9 +440,9 @@ function expectBody(expected) {
'0' + CRLF);
function test(a, b) {
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/helpme');
assert.strictEqual(versionMajor, 1);
@@ -451,7 +451,7 @@ function expectBody(expected) {
let expected_body = '123123456123456789123456789ABC123456789ABCDEF';
- const onBody = function(buf, start, len) {
+ const onBody = (buf, start, len) => {
const chunk = '' + buf.slice(start, start + len);
assert.strictEqual(expected_body.indexOf(chunk), 0);
expected_body = expected_body.slice(chunk.length);
@@ -499,9 +499,9 @@ function expectBody(expected) {
'123456789ABCDEF' + CRLF +
'0' + CRLF);
- const onHeadersComplete = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url || parser.url, '/it');
assert.strictEqual(versionMajor, 1);
@@ -513,7 +513,7 @@ function expectBody(expected) {
let expected_body = '123123456123456789123456789ABC123456789ABCDEF';
- const onBody = function(buf, start, len) {
+ const onBody = (buf, start, len) => {
const chunk = '' + buf.slice(start, start + len);
assert.strictEqual(expected_body.indexOf(chunk), 0);
expected_body = expected_body.slice(chunk.length);
@@ -551,9 +551,9 @@ function expectBody(expected) {
CRLF +
'pong');
- const onHeadersComplete1 = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete1 = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('PUT'));
assert.strictEqual(url, '/this');
assert.strictEqual(versionMajor, 1);
@@ -563,9 +563,9 @@ function expectBody(expected) {
['Content-Type', 'text/plain', 'Transfer-Encoding', 'chunked']);
};
- const onHeadersComplete2 = function(versionMajor, versionMinor, headers,
- method, url, statusCode, statusMessage,
- upgrade, shouldKeepAlive) {
+ const onHeadersComplete2 = (versionMajor, versionMinor, headers,
+ method, url, statusCode, statusMessage,
+ upgrade, shouldKeepAlive) => {
assert.strictEqual(method, methods.indexOf('POST'));
assert.strictEqual(url, '/that');
assert.strictEqual(versionMajor, 1);
diff --git a/test/parallel/test-http-response-status-message.js b/test/parallel/test-http-response-status-message.js
index ca0618caf0..b618de7559 100644
--- a/test/parallel/test-http-response-status-message.js
+++ b/test/parallel/test-http-response-status-message.js
@@ -59,7 +59,7 @@ const server = net.createServer(function(connection) {
});
});
-const runTest = function(testCaseIndex) {
+function runTest(testCaseIndex) {
const testCase = testCases[testCaseIndex];
http.get({
@@ -82,7 +82,7 @@ const runTest = function(testCaseIndex) {
response.resume();
});
-};
+}
server.listen(0, function() { runTest(0); });
diff --git a/test/parallel/test-https-simple.js b/test/parallel/test-https-simple.js
index cb5a8d4146..d20f6bb205 100644
--- a/test/parallel/test-https-simple.js
+++ b/test/parallel/test-https-simple.js
@@ -39,7 +39,7 @@ const options = {
const tests = 2;
let successful = 0;
-const testSucceeded = function() {
+const testSucceeded = () => {
successful = successful + 1;
if (successful === tests) {
server.close();
diff --git a/test/parallel/test-net-server-max-connections-close-makes-more-available.js b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
index 887beb21d2..9fd34a6f45 100644
--- a/test/parallel/test-net-server-max-connections-close-makes-more-available.js
+++ b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
@@ -17,7 +17,7 @@ const connections = [];
const received = [];
const sent = [];
-const createConnection = function(index) {
+function createConnection(index) {
console.error('creating connection ' + index);
return new Promise(function(resolve, reject) {
@@ -45,9 +45,9 @@ const createConnection = function(index) {
connections[index] = connection;
});
-};
+}
-const closeConnection = function(index) {
+function closeConnection(index) {
console.error('closing connection ' + index);
return new Promise(function(resolve, reject) {
connections[index].on('end', function() {
@@ -55,7 +55,7 @@ const closeConnection = function(index) {
});
connections[index].end();
});
-};
+}
const server = net.createServer(function(socket) {
socket.on('data', function(data) {
diff --git a/test/parallel/test-net-server-pause-on-connect.js b/test/parallel/test-net-server-pause-on-connect.js
index 6041de9970..e015c24323 100644
--- a/test/parallel/test-net-server-pause-on-connect.js
+++ b/test/parallel/test-net-server-pause-on-connect.js
@@ -28,7 +28,7 @@ let stopped = true;
let server1Sock;
-const server1ConnHandler = function(socket) {
+const server1ConnHandler = (socket) => {
socket.on('data', function(data) {
if (stopped) {
assert.fail('data event should not have happened yet');
@@ -44,7 +44,7 @@ const server1ConnHandler = function(socket) {
const server1 = net.createServer({pauseOnConnect: true}, server1ConnHandler);
-const server2ConnHandler = function(socket) {
+const server2ConnHandler = (socket) => {
socket.on('data', function(data) {
assert.strictEqual(data.toString(), msg, 'invalid data received');
socket.end();
diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js
index 848e7963b2..6092c411a8 100644
--- a/test/parallel/test-os.js
+++ b/test/parallel/test-os.js
@@ -116,7 +116,7 @@ const interfaces = os.networkInterfaces();
switch (platform) {
case 'linux':
{
- const filter = function(e) { return e.address === '127.0.0.1'; };
+ const filter = (e) => e.address === '127.0.0.1';
const actual = interfaces.lo.filter(filter);
const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4',
@@ -126,7 +126,7 @@ switch (platform) {
}
case 'win32':
{
- const filter = function(e) { return e.address === '127.0.0.1'; };
+ const filter = (e) => e.address === '127.0.0.1';
const actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter);
const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4',
diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js
index 5d618e169e..17aef54290 100644
--- a/test/parallel/test-preload.js
+++ b/test/parallel/test-preload.js
@@ -13,7 +13,7 @@ if (common.isSunOS) {
const nodeBinary = process.argv[0];
-const preloadOption = function(preloads) {
+const preloadOption = (preloads) => {
let option = '';
preloads.forEach(function(preload, index) {
option += '-r ' + preload + ' ';
@@ -21,9 +21,7 @@ const preloadOption = function(preloads) {
return option;
};
-const fixture = function(name) {
- return path.join(common.fixturesDir, name);
-};
+const fixture = (name) => path.join(common.fixturesDir, name);
const fixtureA = fixture('printA.js');
const fixtureB = fixture('printB.js');
diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js
index 6d8dd2a7f2..0e5cfef362 100644
--- a/test/parallel/test-querystring.js
+++ b/test/parallel/test-querystring.js
@@ -107,7 +107,7 @@ const qsColonTestCases = [
];
// [wonkyObj, qs, canonicalObj]
-const extendedFunction = function() {};
+function extendedFunction() {}
extendedFunction.prototype = {a: 'b'};
const qsWeirdObjects = [
// eslint-disable-next-line no-unescaped-regexp-dot
diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js
index f7c66c90c5..50a6bf2daa 100644
--- a/test/parallel/test-readline-interface.js
+++ b/test/parallel/test-readline-interface.js
@@ -288,9 +288,7 @@ function isWarned(emitter) {
// \t does not become part of the input when there is a completer function
fi = new FakeInput();
- const completer = function(line) {
- return [[], line];
- };
+ const completer = (line) => [[], line];
rli = new readline.Interface({
input: fi,
output: fi,
diff --git a/test/parallel/test-stream2-pipe-error-once-listener.js b/test/parallel/test-stream2-pipe-error-once-listener.js
index 078c3d935f..de65c2469e 100644
--- a/test/parallel/test-stream2-pipe-error-once-listener.js
+++ b/test/parallel/test-stream2-pipe-error-once-listener.js
@@ -26,9 +26,9 @@ const util = require('util');
const stream = require('stream');
-const Read = function() {
+function Read() {
stream.Readable.call(this);
-};
+}
util.inherits(Read, stream.Readable);
Read.prototype._read = function(size) {
@@ -37,9 +37,9 @@ Read.prototype._read = function(size) {
};
-const Write = function() {
+function Write() {
stream.Writable.call(this);
-};
+}
util.inherits(Write, stream.Writable);
Write.prototype._write = function(buffer, encoding, cb) {
diff --git a/test/parallel/test-timers-ordering.js b/test/parallel/test-timers-ordering.js
index 8a807f94cd..b3388cc9be 100644
--- a/test/parallel/test-timers-ordering.js
+++ b/test/parallel/test-timers-ordering.js
@@ -29,7 +29,7 @@ const N = 30;
let last_i = 0;
let last_ts = 0;
-const f = function(i) {
+function f(i) {
if (i <= N) {
// check order
assert.strictEqual(i, last_i + 1, 'order is broken: ' + i + ' != ' +
@@ -46,5 +46,5 @@ const f = function(i) {
// schedule next iteration
setTimeout(f, 1, i + 1);
}
-};
+}
f(1);
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 0b58af4080..d44bb8b870 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -296,7 +296,7 @@ assert.strictEqual(
// Function with properties
{
- const value = function() {};
+ const value = () => {};
value.aprop = 42;
assert.strictEqual(util.inspect(value), '{ [Function: value] aprop: 42 }');
}
diff --git a/test/pummel/test-dtrace-jsstack.js b/test/pummel/test-dtrace-jsstack.js
index b580984075..2c8611d11d 100644
--- a/test/pummel/test-dtrace-jsstack.js
+++ b/test/pummel/test-dtrace-jsstack.js
@@ -34,18 +34,18 @@ if (!common.isSunOS) {
*/
const frames = [ 'stalloogle', 'bagnoogle', 'doogle' ];
-const stalloogle = function(str) {
+const stalloogle = (str) => {
global.expected = str;
os.loadavg();
};
-const bagnoogle = function(arg0, arg1) {
+const bagnoogle = (arg0, arg1) => {
stalloogle(arg0 + ' is ' + arg1 + ' except that it is read-only');
};
let done = false;
-const doogle = function() {
+const doogle = () => {
if (!done)
setTimeout(doogle, 10);
diff --git a/test/pummel/test-tls-session-timeout.js b/test/pummel/test-tls-session-timeout.js
index 23b79e312f..5807ae8a94 100644
--- a/test/pummel/test-tls-session-timeout.js
+++ b/test/pummel/test-tls-session-timeout.js
@@ -78,7 +78,7 @@ function doTest() {
// Expects a callback -- cb(connectionType : enum ['New'|'Reused'])
- const Client = function(cb) {
+ function Client(cb) {
const flags = [
's_client',
'-connect', 'localhost:' + common.PORT,
@@ -95,7 +95,7 @@ function doTest() {
});
client.on('exit', function(code) {
let connectionType;
- const grepConnectionType = function(line) {
+ const grepConnectionType = (line) => {
const matches = line.match(/(New|Reused), /);
if (matches) {
connectionType = matches[1];
@@ -108,7 +108,7 @@ function doTest() {
}
cb(connectionType);
});
- };
+ }
const server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {