Skip to content

Commit 337d2dd

Browse files
TrottMylesBorins
authored andcommitted
test: implement consistent braces
This change is in preparation for lint enforcement of brace style. PR-URL: #8348 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent f6e332d commit 337d2dd

25 files changed

+40
-76
lines changed

test/internet/test-dgram-broadcast-multi-process.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ if (process.argv[2] !== 'child') {
9494
//all child process are listening, so start sending
9595
sendSocket.sendNext();
9696
}
97-
}
98-
else if (msg.message) {
97+
} else if (msg.message) {
9998
worker.messagesReceived.push(msg.message);
10099

101100
if (worker.messagesReceived.length === messages.length) {

test/parallel/test-child-process-fork-exec-path.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ if (process.env.FORK) {
1212
assert.equal(process.argv[0], copyPath);
1313
process.send(msg);
1414
process.exit();
15-
}
16-
else {
15+
} else {
1716
common.refreshTmpDir();
1817
try {
1918
fs.unlinkSync(copyPath);
20-
}
21-
catch (e) {
19+
} catch (e) {
2220
if (e.code !== 'ENOENT') throw e;
2321
}
2422
fs.writeFileSync(copyPath, fs.readFileSync(nodePath));

test/parallel/test-child-process-recv-handle.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ function worker() {
4949
if (n === 1) {
5050
assert.equal(msg, 'one');
5151
assert.equal(handle, undefined);
52-
}
53-
else if (n === 2) {
52+
} else if (n === 2) {
5453
assert.equal(msg, 'two');
5554
assert.equal(typeof handle, 'object'); // Also matches null, therefore...
5655
assert.ok(handle); // also check that it's truthy.
5756
handle.close();
58-
}
59-
else if (n === 3) {
57+
} else if (n === 3) {
6058
assert.equal(msg, 'three');
6159
assert.equal(handle, undefined);
6260
process.exit();

test/parallel/test-cluster-basic.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ if (cluster.isWorker) {
1818
http.Server(function() {
1919

2020
}).listen(common.PORT, '127.0.0.1');
21-
}
22-
23-
else if (cluster.isMaster) {
21+
} else if (cluster.isMaster) {
2422

2523
var checks = {
2624
cluster: {

test/parallel/test-cluster-bind-privileged-port.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ if (cluster.isMaster) {
1818
cluster.fork().on('exit', common.mustCall(function(exitCode) {
1919
assert.equal(exitCode, 0);
2020
}));
21-
}
22-
else {
21+
} else {
2322
var s = net.createServer(common.fail);
2423
s.listen(42, common.fail.bind(null, 'listen should have failed'));
2524
s.on('error', common.mustCall(function(err) {

test/parallel/test-cluster-bind-twice.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ if (!id) {
6464
process.on('exit', function() {
6565
assert(ok);
6666
});
67-
}
68-
else if (id === 'one') {
67+
} else if (id === 'one') {
6968
if (cluster.isMaster) return startWorker();
7069

7170
http.createServer(common.fail).listen(common.PORT, function() {
@@ -75,8 +74,7 @@ else if (id === 'one') {
7574
process.on('message', function(m) {
7675
if (m === 'QUIT') process.exit();
7776
});
78-
}
79-
else if (id === 'two') {
77+
} else if (id === 'two') {
8078
if (cluster.isMaster) return startWorker();
8179

8280
let ok = false;
@@ -96,8 +94,7 @@ else if (id === 'two') {
9694
ok = true;
9795
});
9896
});
99-
}
100-
else {
97+
} else {
10198
assert(0); // bad command line argument
10299
}
103100

test/parallel/test-cluster-eaddrinuse.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ if (id === 'undefined') {
2121
});
2222
});
2323
});
24-
}
25-
else if (id === 'worker') {
24+
} else if (id === 'worker') {
2625
let server = net.createServer(common.fail);
2726
server.listen(common.PORT, common.fail);
2827
server.on('error', common.mustCall(function(e) {
@@ -36,7 +35,6 @@ else if (id === 'worker') {
3635
}));
3736
});
3837
}));
39-
}
40-
else {
38+
} else {
4139
assert(0); // Bad argument.
4240
}

test/parallel/test-cluster-listening-port.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ if (cluster.isMaster) {
1919
// ensure that the 'listening' handler has been called
2020
assert(port);
2121
});
22-
}
23-
else {
22+
} else {
2423
net.createServer(common.fail).listen(0);
2524
}

test/parallel/test-cluster-message.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ if (cluster.isWorker) {
4040
});
4141

4242
server.listen(common.PORT, '127.0.0.1');
43-
}
44-
45-
else if (cluster.isMaster) {
43+
} else if (cluster.isMaster) {
4644

4745
var checks = {
4846
global: {

test/parallel/test-cluster-net-listen.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ if (cluster.isMaster) {
1414
process.on('exit', function() {
1515
assert.equal(worker, null);
1616
});
17-
}
18-
else {
17+
} else {
1918
// listen() without port should not trigger a libuv assert
2019
net.createServer(common.fail).listen(process.exit);
2120
}

test/parallel/test-cluster-shared-handle-bind-error.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ if (cluster.isMaster) {
1616
server.close();
1717
}));
1818
});
19-
}
20-
else {
19+
} else {
2120
var s = net.createServer(common.fail);
2221
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
2322
s.on('error', common.mustCall(function(err) {

test/parallel/test-cluster-shared-handle-bind-privileged-port.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ if (cluster.isMaster) {
2020
cluster.fork().on('exit', common.mustCall(function(exitCode) {
2121
assert.equal(exitCode, 0);
2222
}));
23-
}
24-
else {
23+
} else {
2524
var s = net.createServer(common.fail);
2625
s.listen(42, common.fail.bind(null, 'listen should have failed'));
2726
s.on('error', common.mustCall(function(err) {

test/parallel/test-cluster-uncaught-exception.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ if (isTestRunner) {
2323
master.on('exit', function(code) {
2424
exitCode = code;
2525
});
26-
}
27-
else if (cluster.isMaster) {
26+
} else if (cluster.isMaster) {
2827
process.on('uncaughtException', function() {
2928
process.nextTick(function() {
3029
process.exit(MAGIC_EXIT_CODE);
@@ -33,7 +32,6 @@ else if (cluster.isMaster) {
3332

3433
cluster.fork();
3534
throw new Error('kill master');
36-
}
37-
else { // worker
35+
} else { // worker
3836
process.exit();
3937
}

test/parallel/test-cluster-worker-death.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ var cluster = require('cluster');
55

66
if (!cluster.isMaster) {
77
process.exit(42);
8-
}
9-
else {
8+
} else {
109
var seenExit = 0;
1110
var seenDeath = 0;
1211
var worker = cluster.fork();

test/parallel/test-crypto-authenticated.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ for (var i in TEST_CASES) {
362362
(function() {
363363
if (!test.password) return;
364364
if (common.hasFipsCrypto) {
365-
assert.throws(function()
366-
{ crypto.createCipher(test.algo, test.password); },
365+
assert.throws(() => { crypto.createCipher(test.algo, test.password); },
367366
/not supported in FIPS mode/);
368367
} else {
369368
var encrypt = crypto.createCipher(test.algo, test.password);
@@ -383,8 +382,7 @@ for (var i in TEST_CASES) {
383382
(function() {
384383
if (!test.password) return;
385384
if (common.hasFipsCrypto) {
386-
assert.throws(function()
387-
{ crypto.createDecipher(test.algo, test.password); },
385+
assert.throws(() => { crypto.createDecipher(test.algo, test.password); },
388386
/not supported in FIPS mode/);
389387
} else {
390388
var decrypt = crypto.createDecipher(test.algo, test.password);
@@ -415,9 +413,9 @@ for (var i in TEST_CASES) {
415413
'ipxp9a6i1Mb4USb4', '6fKjEjR3Vl30EUYC');
416414
encrypt.update('blah', 'ascii');
417415
encrypt.final();
418-
assert.throws(function() { encrypt.getAuthTag(); }, / state/);
419-
assert.throws(function() {
420-
encrypt.setAAD(new Buffer('123', 'ascii')); }, / state/);
416+
assert.throws(() => { encrypt.getAuthTag(); }, / state/);
417+
assert.throws(() => { encrypt.setAAD(Buffer.from('123', 'ascii')); },
418+
/ state/);
421419
})();
422420

423421
(function() {
@@ -431,9 +429,9 @@ for (var i in TEST_CASES) {
431429
(function() {
432430
// trying to set tag on encryption object:
433431
var encrypt = crypto.createCipheriv(test.algo,
434-
new Buffer(test.key, 'hex'), new Buffer(test.iv, 'hex'));
435-
assert.throws(function() {
436-
encrypt.setAuthTag(new Buffer(test.tag, 'hex')); }, / state/);
432+
Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex'));
433+
assert.throws(() => { encrypt.setAuthTag(Buffer.from(test.tag, 'hex')); },
434+
/ state/);
437435
})();
438436

439437
(function() {

test/parallel/test-debugger-util-regression.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ proc.stdout.on('data', (data) => {
3838
stdout.includes('> 4') && nextCount < 4) {
3939
nextCount++;
4040
proc.stdin.write('n\n');
41-
}
42-
else if (stdout.includes('{ a: \'b\' }')) {
41+
} else if (stdout.includes('{ a: \'b\' }')) {
4342
clearTimeout(timer);
4443
proc.stdin.write('.exit\n');
45-
}
46-
else if (stdout.includes('program terminated')) {
44+
} else if (stdout.includes('program terminated')) {
4745
// Catch edge case present in v4.x
4846
// process will terminate after call to util.inspect
4947
common.fail('the program should not terminate');

test/parallel/test-fs-open.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ try {
88
// should throw ENOENT, not EBADF
99
// see https://github.com/joyent/node/pull/1228
1010
fs.openSync('/path/to/file/that/does/not/exist', 'r');
11-
}
12-
catch (e) {
11+
} catch (e) {
1312
assert.equal(e.code, 'ENOENT');
1413
caughtException = true;
1514
}

test/parallel/test-fs-realpath.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ function asynctest(testBlock, args, callback, assertBlock) {
5353
if (assertBlock) {
5454
try {
5555
ignoreError = assertBlock.apply(assertBlock, arguments);
56-
}
57-
catch (e) {
56+
} catch (e) {
5857
err = e;
5958
}
6059
}

test/parallel/test-http-server-stale-close.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ if (process.env.NODE_TEST_FORK_PORT) {
1313
}, process.exit);
1414
req.write('BAM');
1515
req.end();
16-
}
17-
else {
16+
} else {
1817
var server = http.createServer(function(req, res) {
1918
res.writeHead(200, {'Content-Length': '42'});
2019
req.pipe(res);

test/parallel/test-next-tick-errors.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ process.on('uncaughtException', function() {
2424
if (!exceptionHandled) {
2525
exceptionHandled = true;
2626
order.push('B');
27-
}
28-
else {
27+
} else {
2928
// If we get here then the first process.nextTick got called twice
3029
order.push('OOPS!');
3130
}

test/parallel/test-process-argv-0.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ if (process.argv[2] !== 'child') {
1616
process.on('exit', function() {
1717
assert.equal(childArgv0, process.execPath);
1818
});
19-
}
20-
else {
19+
} else {
2120
process.stdout.write(process.argv[0]);
2221
}

test/parallel/test-repl-domain.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ putIn.write = function(data) {
1111
// give a false negative. Don't throw, just print and exit.
1212
if (data === 'OK\n') {
1313
console.log('ok');
14-
}
15-
else {
14+
} else {
1615
console.error(data);
1716
process.exit(1);
1817
}

test/parallel/test-vm-context.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ console.error('test runInContext signature');
3232
var gh1140Exception;
3333
try {
3434
vm.runInContext('throw new Error()', context, 'expected-filename.js');
35-
}
36-
catch (e) {
35+
} catch (e) {
3736
gh1140Exception = e;
3837
assert.ok(/expected-filename/.test(e.stack),
3938
'expected appearance of filename in Error stack');

test/pummel/test-fs-watch-file-slow.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ var nevents = 0;
1111

1212
try {
1313
fs.unlinkSync(FILENAME);
14-
}
15-
catch (e) {
14+
} catch (e) {
1615
// swallow
1716
}
1817

test/pummel/test-regress-GH-814.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds.
4444
if (bufPool.push(nuBuf) > 100) {
4545
bufPool.length = 0;
4646
}
47-
}
48-
else {
47+
} else {
4948
throw new Error("Buffer GC'ed test -> FAIL");
5049
}
5150

5251
if (Date.now() < timeToQuit) {
5352
process.nextTick(main);
54-
}
55-
else {
53+
} else {
5654
tail.kill();
5755
console.log("Buffer GC'ed test -> PASS (OK)");
5856
}

0 commit comments

Comments
 (0)