Browse Source

benchmark,lib,test: adjust for linting

Formatting changes for upcoming linter update.

PR-URL: https://github.com/nodejs/node/pull/10561
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
v6
Rich Trott 8 years ago
parent
commit
a68987c154
  1. 10
      lib/internal/module.js
  2. 5
      lib/os.js
  3. 27
      lib/repl.js
  4. 10
      test/internet/test-dns-ipv4.js
  5. 10
      test/internet/test-dns-ipv6.js
  6. 5
      test/parallel/test-cli-eval.js
  7. 5
      test/parallel/test-cluster-worker-exit.js
  8. 15
      test/parallel/test-crypto-authenticated.js
  9. 10
      test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
  10. 75
      test/parallel/test-preload.js
  11. 18
      test/parallel/test-punycode.js
  12. 6
      test/parallel/test-require-symlink.js
  13. 3
      test/parallel/test-util-inspect.js
  14. 12
      test/parallel/test-util-sigint-watchdog.js

10
lib/internal/module.js

@ -51,10 +51,12 @@ function stripBOM(content) {
return content;
}
exports.builtinLibs = ['assert', 'buffer', 'child_process', 'cluster',
'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'net',
'os', 'path', 'punycode', 'querystring', 'readline', 'repl', 'stream',
'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib'];
exports.builtinLibs = [
'assert', 'buffer', 'child_process', 'cluster', 'crypto', 'dgram', 'dns',
'domain', 'events', 'fs', 'http', 'https', 'net', 'os', 'path', 'punycode',
'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'tls', 'tty',
'url', 'util', 'v8', 'vm', 'zlib'
];
function addBuiltinLibsToObject(object) {
// Make built-in modules available directly (loaded lazily).

5
lib/os.js

@ -51,8 +51,9 @@ exports.tmpdir = function() {
return path;
};
exports.tmpDir = internalUtil.deprecate(exports.tmpdir,
'os.tmpDir() is deprecated. Use os.tmpdir() instead.');
const tmpDirDeprecationMsg =
'os.tmpDir() is deprecated. Use os.tmpdir() instead.';
exports.tmpDir = internalUtil.deprecate(exports.tmpdir, tmpDirDeprecationMsg);
exports.getNetworkInterfaces = internalUtil.deprecate(function() {
return exports.networkInterfaces();

27
lib/repl.js

@ -39,13 +39,13 @@ const debug = util.debuglog('repl');
const parentModule = module;
const replMap = new WeakMap();
const GLOBAL_OBJECT_PROPERTIES = ['NaN', 'Infinity', 'undefined',
'eval', 'parseInt', 'parseFloat', 'isNaN', 'isFinite', 'decodeURI',
'decodeURIComponent', 'encodeURI', 'encodeURIComponent',
'Object', 'Function', 'Array', 'String', 'Boolean', 'Number',
'Date', 'RegExp', 'Error', 'EvalError', 'RangeError',
'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
'Math', 'JSON'];
const GLOBAL_OBJECT_PROPERTIES = [
'NaN', 'Infinity', 'undefined', 'eval', 'parseInt', 'parseFloat', 'isNaN',
'isFinite', 'decodeURI', 'decodeURIComponent', 'encodeURI',
'encodeURIComponent', 'Object', 'Function', 'Array', 'String', 'Boolean',
'Number', 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError',
'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Math', 'JSON'
];
const GLOBAL_OBJECT_PROPERTY_MAP = {};
GLOBAL_OBJECT_PROPERTIES.forEach((p) => GLOBAL_OBJECT_PROPERTY_MAP[p] = p);
@ -1216,12 +1216,13 @@ function addStandardGlobals(completionGroups, filter) {
// Common keywords. Exclude for completion on the empty string, b/c
// they just get in the way.
if (filter) {
completionGroups.push(['break', 'case', 'catch', 'const',
'continue', 'debugger', 'default', 'delete', 'do', 'else',
'export', 'false', 'finally', 'for', 'function', 'if',
'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined',
'var', 'void', 'while', 'with', 'yield']);
completionGroups.push([
'break', 'case', 'catch', 'const', 'continue', 'debugger', 'default',
'delete', 'do', 'else', 'export', 'false', 'finally', 'for', 'function',
'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined', 'var',
'void', 'while', 'with', 'yield'
]);
}
}

10
test/internet/test-dns-ipv4.js

@ -164,21 +164,23 @@ TEST(function test_lookup_all_ipv4(done) {
});
done();
}
));
})
);
checkWrap(req);
});
TEST(function test_lookupservice_ip_ipv4(done) {
const req = dns.lookupService('127.0.0.1', 80,
const req = dns.lookupService(
'127.0.0.1', 80,
common.mustCall((err, host, service) => {
assert.ifError(err);
assert.strictEqual(typeof host, 'string');
assert(host);
assert(['http', 'www', '80'].includes(service));
done();
}));
})
);
checkWrap(req);
});

10
test/internet/test-dns-ipv6.js

@ -169,14 +169,15 @@ TEST(function test_lookup_all_ipv6(done) {
});
done();
}
));
})
);
checkWrap(req);
});
TEST(function test_lookupservice_ip_ipv6(done) {
const req = dns.lookupService('::1', 80,
const req = dns.lookupService(
'::1', 80,
common.mustCall((err, host, service) => {
if (err) {
// Not skipping the test, rather checking an alternative result,
@ -188,7 +189,8 @@ TEST(function test_lookupservice_ip_ipv6(done) {
assert(host);
assert(['http', 'www', '80'].includes(service));
done();
}));
})
);
checkWrap(req);
});

5
test/parallel/test-cli-eval.js

@ -87,8 +87,9 @@ child.exec(nodejs + ' -p "\\-42"',
child.exec(nodejs + ' --use-strict -p process.execArgv',
function(status, stdout, stderr) {
assert.strictEqual(stdout,
"[ '--use-strict', '-p', 'process.execArgv' ]\n");
assert.strictEqual(
stdout, "[ '--use-strict', '-p', 'process.execArgv' ]\n"
);
});
// Regression test for https://github.com/nodejs/node/issues/3574

5
test/parallel/test-cluster-worker-exit.js

@ -32,8 +32,9 @@ if (cluster.isWorker) {
worker_emitExit: [1, "the worker did not emit 'exit'"],
worker_state: ['disconnected', 'the worker state is incorrect'],
worker_suicideMode: [false, 'the worker.suicide flag is incorrect'],
worker_exitedAfterDisconnect: [false,
'the .exitedAfterDisconnect flag is incorrect'],
worker_exitedAfterDisconnect: [
false, 'the .exitedAfterDisconnect flag is incorrect'
],
worker_died: [true, 'the worker is still running'],
worker_exitCode: [EXIT_CODE, 'the worker exited w/ incorrect exitCode'],
worker_signalCode: [null, 'the worker exited w/ incorrect signalCode']

15
test/parallel/test-crypto-authenticated.js

@ -324,7 +324,8 @@ for (const i in TEST_CASES) {
{
const encrypt = crypto.createCipheriv(test.algo,
Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex'));
Buffer.from(test.key, 'hex'),
Buffer.from(test.iv, 'hex'));
if (test.aad)
encrypt.setAAD(Buffer.from(test.aad, 'hex'));
@ -342,7 +343,8 @@ for (const i in TEST_CASES) {
{
const decrypt = crypto.createDecipheriv(test.algo,
Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex'));
Buffer.from(test.key, 'hex'),
Buffer.from(test.iv, 'hex'));
decrypt.setAuthTag(Buffer.from(test.tag, 'hex'));
if (test.aad)
decrypt.setAAD(Buffer.from(test.aad, 'hex'));
@ -401,7 +403,8 @@ for (const i in TEST_CASES) {
{
// trying to get tag before inputting all data:
const encrypt = crypto.createCipheriv(test.algo,
Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex'));
Buffer.from(test.key, 'hex'),
Buffer.from(test.iv, 'hex'));
encrypt.update('blah', 'ascii');
assert.throws(function() { encrypt.getAuthTag(); }, / state/);
}
@ -409,7 +412,8 @@ for (const i in TEST_CASES) {
{
// trying to set tag on encryption object:
const encrypt = crypto.createCipheriv(test.algo,
Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex'));
Buffer.from(test.key, 'hex'),
Buffer.from(test.iv, 'hex'));
assert.throws(() => { encrypt.setAuthTag(Buffer.from(test.tag, 'hex')); },
/ state/);
}
@ -417,7 +421,8 @@ for (const i in TEST_CASES) {
{
// trying to read tag from decryption object:
const decrypt = crypto.createDecipheriv(test.algo,
Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex'));
Buffer.from(test.key, 'hex'),
Buffer.from(test.iv, 'hex'));
assert.throws(function() { decrypt.getAuthTag(); }, / state/);
}

10
test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js

@ -49,7 +49,8 @@ if (process.argv[2] === 'child') {
}
function runTestWithoutAbortOnUncaughtException() {
child_process.exec(createTestCmdLine(),
child_process.exec(
createTestCmdLine(),
function onTestDone(err, stdout, stderr) {
// When _not_ passing --abort-on-uncaught-exception, the process'
// uncaughtException handler _must_ be called, and thus the error
@ -58,13 +59,14 @@ function runTestWithoutAbortOnUncaughtException() {
assert(stderr.includes(uncaughtExceptionHandlerErrMsg),
'stderr output must include proper uncaughtException ' +
'handler\'s error\'s message');
assert(!stderr.includes(domainErrMsg), 'stderr output must not ' +
'include domain\'s error\'s message');
assert(!stderr.includes(domainErrMsg),
'stderr output must not include domain\'s error\'s message');
assert.notStrictEqual(err.code, 0,
'child process should have exited with a ' +
'non-zero exit code, but did not');
});
}
);
}
function runTestWithAbortOnUncaughtException() {

75
test/parallel/test-preload.js

@ -32,43 +32,41 @@ const fixtureD = fixture('define-global.js');
const fixtureThrows = fixture('throws_error4.js');
// test preloading a single module works
childProcess.exec(nodeBinary + ' ' +
preloadOption([fixtureA]) + ' ' +
fixtureB,
childProcess.exec(nodeBinary + ' ' + preloadOption([fixtureA]) + ' ' + fixtureB,
function(err, stdout, stderr) {
assert.ifError(err);
if (err) throw err;
assert.strictEqual(stdout, 'A\nB\n');
});
// test preloading multiple modules works
childProcess.exec(nodeBinary + ' ' +
preloadOption([fixtureA, fixtureB]) + ' ' +
fixtureC,
childProcess.exec(
nodeBinary + ' ' + preloadOption([fixtureA, fixtureB]) + ' ' + fixtureC,
function(err, stdout, stderr) {
assert.ifError(err);
if (err) throw err;
assert.strictEqual(stdout, 'A\nB\nC\n');
});
}
);
// test that preloading a throwing module aborts
childProcess.exec(nodeBinary + ' ' +
preloadOption([fixtureA, fixtureThrows]) + ' ' +
fixtureB,
childProcess.exec(
nodeBinary + ' ' + preloadOption([fixtureA, fixtureThrows]) + ' ' + fixtureB,
function(err, stdout, stderr) {
if (err) {
assert.strictEqual(stdout, 'A\n');
} else {
throw new Error('Preload should have failed');
}
});
}
);
// test that preload can be used with --eval
childProcess.exec(nodeBinary + ' ' +
preloadOption([fixtureA]) +
'-e "console.log(\'hello\');"',
childProcess.exec(
nodeBinary + ' ' + preloadOption([fixtureA]) + '-e "console.log(\'hello\');"',
function(err, stdout, stderr) {
assert.ifError(err);
if (err) throw err;
assert.strictEqual(stdout, 'A\nhello\n');
});
}
);
// test that preload can be used with stdin
const stdinProc = childProcess.spawn(
@ -108,42 +106,43 @@ replProc.on('close', function(code) {
// test that preload placement at other points in the cmdline
// also test that duplicated preload only gets loaded once
childProcess.exec(nodeBinary + ' ' +
preloadOption([fixtureA]) +
'-e "console.log(\'hello\');" ' +
preloadOption([fixtureA, fixtureB]),
childProcess.exec(
nodeBinary + ' ' + preloadOption([fixtureA]) +
'-e "console.log(\'hello\');" ' + preloadOption([fixtureA, fixtureB]),
function(err, stdout, stderr) {
assert.ifError(err);
if (err) throw err;
assert.strictEqual(stdout, 'A\nB\nhello\n');
});
}
);
// test that preload works with -i
const interactive = childProcess.exec(nodeBinary + ' ' +
preloadOption([fixtureD]) +
'-i',
const interactive = childProcess.exec(
nodeBinary + ' ' + preloadOption([fixtureD]) + '-i',
common.mustCall(function(err, stdout, stderr) {
assert.ifError(err);
assert.strictEqual(stdout, "> 'test'\n> ");
}));
})
);
interactive.stdin.write('a\n');
interactive.stdin.write('process.exit()\n');
childProcess.exec(nodeBinary + ' ' +
'--require ' + fixture('cluster-preload.js') + ' ' +
childProcess.exec(
nodeBinary + ' ' + '--require ' + fixture('cluster-preload.js') + ' ' +
fixture('cluster-preload-test.js'),
function(err, stdout, stderr) {
assert.ifError(err);
if (err) throw err;
assert.ok(/worker terminated with code 43/.test(stdout));
});
}
);
// https://github.com/nodejs/node/issues/1691
process.chdir(common.fixturesDir);
childProcess.exec(nodeBinary + ' ' +
'--expose_debug_as=v8debug ' +
'--require ' + fixture('cluster-preload.js') + ' ' +
'cluster-preload-test.js',
childProcess.exec(
nodeBinary + ' ' + '--expose_debug_as=v8debug ' + '--require ' +
fixture('cluster-preload.js') + ' ' + 'cluster-preload-test.js',
function(err, stdout, stderr) {
assert.ifError(err);
if (err) throw err;
assert.ok(/worker terminated with code 43/.test(stdout));
});
}
);

18
test/parallel/test-punycode.js

@ -6,17 +6,23 @@ const assert = require('assert');
assert.strictEqual(punycode.encode('ü'), 'tda');
assert.strictEqual(punycode.encode('Goethe'), 'Goethe-');
assert.strictEqual(punycode.encode('Bücher'), 'Bcher-kva');
assert.strictEqual(punycode.encode(
'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'),
'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal');
assert.strictEqual(
punycode.encode(
'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'
),
'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'
);
assert.strictEqual(punycode.encode('日本語'), 'wgv71a119e');
assert.strictEqual(punycode.decode('tda'), 'ü');
assert.strictEqual(punycode.decode('Goethe-'), 'Goethe');
assert.strictEqual(punycode.decode('Bcher-kva'), 'Bücher');
assert.strictEqual(punycode.decode(
'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'),
'Willst du die Blüthe des frühen, die Früchte des späteren Jahres');
assert.strictEqual(
punycode.decode(
'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'
),
'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'
);
assert.strictEqual(punycode.decode('wgv71a119e'), '日本語');
// http://tools.ietf.org/html/rfc3492#section-7.1

6
test/parallel/test-require-symlink.js

@ -13,8 +13,10 @@ common.refreshTmpDir();
const linkTarget = path.join(common.fixturesDir,
'/module-require-symlink/node_modules/dep2/');
const linkDir = path.join(common.fixturesDir,
'/module-require-symlink/node_modules/dep1/node_modules/dep2');
const linkDir = path.join(
common.fixturesDir,
'/module-require-symlink/node_modules/dep1/node_modules/dep2'
);
const linkScriptTarget = path.join(common.fixturesDir,
'/module-require-symlink/symlinked.js');

3
test/parallel/test-util-inspect.js

@ -206,7 +206,8 @@ for (const showHidden of [true, false]) {
// Objects without prototype
{
const out = util.inspect(Object.create(null,
{ name: {value: 'Tim', enumerable: true},
{ name: {value: 'Tim',
enumerable: true},
hidden: {value: 'secret'}}), true);
if (out !== "{ [hidden]: 'secret', name: 'Tim' }" &&
out !== "{ name: 'Tim', [hidden]: 'secret' }") {

12
test/parallel/test-util-sigint-watchdog.js

@ -16,7 +16,7 @@ if (common.isWindows) {
assert.strictEqual(hadPendingSignals, false);
next();
},
(next) => {
(next) => {
// Test with one call to the watchdog, one signal.
binding.startSigintWatchdog();
process.kill(process.pid, 'SIGINT');
@ -25,8 +25,8 @@ if (common.isWindows) {
assert.strictEqual(hadPendingSignals, true);
next();
}));
},
(next) => {
},
(next) => {
// Nested calls are okay.
binding.startSigintWatchdog();
binding.startSigintWatchdog();
@ -38,8 +38,8 @@ if (common.isWindows) {
assert.strictEqual(hadPendingSignals2, false);
next();
}));
},
() => {
},
() => {
// Signal comes in after first call to stop.
binding.startSigintWatchdog();
binding.startSigintWatchdog();
@ -50,7 +50,7 @@ if (common.isWindows) {
assert.strictEqual(hadPendingSignals1, false);
assert.strictEqual(hadPendingSignals2, true);
}));
}].reduceRight((a, b) => common.mustCall(b).bind(null, a))();
}].reduceRight((a, b) => common.mustCall(b).bind(null, a))();
function waitForPendingSignal(cb) {
if (binding.watchdogHasPendingSigint())

Loading…
Cancel
Save