Skip to content

Commit 2ce364a

Browse files
pogilvieFishrock123
authored andcommittedSep 14, 2016
test: modernize JS and tighten equality checking
Node todo process example with the follow test-net-binary.js changes: var --> const where applicable ==, assert.equal--> ===, assert.strictEqual for all cases PR-URL: #8476 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 1a30fe5 commit 2ce364a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed
 

‎test/parallel/test-net-binary.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-disable strict */
22
require('../common');
3-
var assert = require('assert');
4-
var net = require('net');
3+
const assert = require('assert');
4+
const net = require('net');
55

66
var binaryString = '';
77
for (var i = 255; i >= 0; i--) {
8-
var s = '\'\\' + i.toString(8) + '\'';
9-
var S = eval(s);
10-
assert.ok(S.charCodeAt(0) == i);
11-
assert.ok(S == String.fromCharCode(i));
8+
const s = `'\\${i.toString(8)}'`;
9+
const S = eval(s);
10+
assert.strictEqual(S.charCodeAt(0), i);
11+
assert.strictEqual(S, String.fromCharCode(i));
1212
binaryString += S;
1313
}
1414

@@ -28,13 +28,13 @@ var recv = '';
2828

2929
echoServer.on('listening', function() {
3030
var j = 0;
31-
var c = net.createConnection({
31+
const c = net.createConnection({
3232
port: this.address().port
3333
});
3434

3535
c.setEncoding('latin1');
3636
c.on('data', function(chunk) {
37-
var n = j + chunk.length;
37+
const n = j + chunk.length;
3838
while (j < n && j < 256) {
3939
c.write(String.fromCharCode(j), 'latin1');
4040
j++;
@@ -57,11 +57,11 @@ echoServer.on('listening', function() {
5757
process.on('exit', function() {
5858
assert.equal(2 * 256, recv.length);
5959

60-
var a = recv.split('');
60+
const a = recv.split('');
6161

62-
var first = a.slice(0, 256).reverse().join('');
62+
const first = a.slice(0, 256).reverse().join('');
6363

64-
var second = a.slice(256, 2 * 256).join('');
64+
const second = a.slice(256, 2 * 256).join('');
6565

66-
assert.equal(first, second);
66+
assert.strictEqual(first, second);
6767
});

0 commit comments

Comments
 (0)
Please sign in to comment.