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. 4
      benchmark/url/whatwg-url-properties.js
  2. 10
      lib/internal/module.js
  3. 5
      lib/os.js
  4. 27
      lib/repl.js
  5. 6
      lib/util.js
  6. 2
      test/common.js
  7. 8
      test/inspector/test-inspector.js
  8. 92
      test/internet/test-dns-ipv4.js
  9. 62
      test/internet/test-dns-ipv6.js
  10. 8
      test/parallel/test-assert.js
  11. 14
      test/parallel/test-buffer-fill.js
  12. 4
      test/parallel/test-buffer-includes.js
  13. 62
      test/parallel/test-buffer-slice.js
  14. 69
      test/parallel/test-cli-eval.js
  15. 5
      test/parallel/test-cluster-worker-exit.js
  16. 15
      test/parallel/test-crypto-authenticated.js
  17. 4
      test/parallel/test-crypto-hash.js
  18. 26
      test/parallel/test-crypto-hmac.js
  19. 8
      test/parallel/test-crypto-rsa-dsa.js
  20. 2
      test/parallel/test-dns.js
  21. 32
      test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
  22. 6
      test/parallel/test-fs-non-number-arguments-throw.js
  23. 28
      test/parallel/test-fs-realpath.js
  24. 6
      test/parallel/test-http-double-content-length.js
  25. 8
      test/parallel/test-http-localaddress.js
  26. 4
      test/parallel/test-http-proxy.js
  27. 8
      test/parallel/test-os.js
  28. 83
      test/parallel/test-preload.js
  29. 18
      test/parallel/test-punycode.js
  30. 10
      test/parallel/test-querystring.js
  31. 2
      test/parallel/test-readline-interface.js
  32. 2
      test/parallel/test-repl-tab-complete.js
  33. 10
      test/parallel/test-require-symlink.js
  34. 2
      test/parallel/test-spawn-cmd-named-pipe.js
  35. 38
      test/parallel/test-tls-client-verify.js
  36. 4
      test/parallel/test-tls-no-sslv3.js
  37. 2
      test/parallel/test-tls-server-failed-handshake-emits-clienterror.js
  38. 118
      test/parallel/test-tls-server-verify.js
  39. 2
      test/parallel/test-tls-socket-failed-handshake-emits-error.js
  40. 11
      test/parallel/test-util-inspect.js
  41. 64
      test/parallel/test-util-sigint-watchdog.js
  42. 6
      test/parallel/test-whatwg-url-properties.js
  43. 2
      test/parallel/test-zerolengthbufferbug.js
  44. 6
      test/parallel/test-zlib-invalid-input.js
  45. 6
      test/parallel/test-zlib.js
  46. 6
      test/sequential/test-crypto-timing-safe-equal.js

4
benchmark/url/whatwg-url-properties.js

@ -11,8 +11,8 @@ var bench = common.createBenchmark(main, {
'http://user:pass@foo.bar.com:21/aaa/zzz?l=24#test'
],
prop: ['toString', 'href', 'origin', 'protocol',
'username', 'password', 'host', 'hostname', 'port',
'pathname', 'search', 'searchParams', 'hash'],
'username', 'password', 'host', 'hostname', 'port',
'pathname', 'search', 'searchParams', 'hash'],
n: [1e4]
});

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'
]);
}
}

6
lib/util.js

@ -407,7 +407,7 @@ function formatValue(ctx, value, recurseTimes) {
if (keys.length === 0) {
if (typeof value === 'function') {
return ctx.stylize(`[Function${value.name ? `: ${value.name}` : ''}]`,
'special');
'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
@ -667,7 +667,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
for (var i = 0; i < maxLength; ++i) {
if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
String(i), true));
} else {
output.push('');
}
@ -678,7 +678,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
keys.forEach(function(key) {
if (typeof key === 'symbol' || !key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
key, true));
}
});
return output;

2
test/common.js

@ -470,7 +470,7 @@ exports.canCreateSymLink = function() {
// If unix tools are in the path, they can shadow the one we want,
// so use the full path while executing whoami
const whoamiPath = path.join(process.env['SystemRoot'],
'System32', 'whoami.exe');
'System32', 'whoami.exe');
let err = false;
let output = '';

8
test/inspector/test-inspector.js

@ -114,10 +114,10 @@ function testSetBreakpointAndResume(session) {
const commands = [
{ 'method': 'Debugger.setBreakpointByUrl',
'params': { 'lineNumber': 5,
'url': session.mainScriptPath,
'columnNumber': 0,
'condition': ''
}
'url': session.mainScriptPath,
'columnNumber': 0,
'condition': ''
}
},
{ 'method': 'Debugger.resume'},
[ { 'method': 'Debugger.getScriptSource',

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

@ -36,61 +36,61 @@ function checkWrap(req) {
TEST(function test_resolve4(done) {
const req = dns.resolve4('www.google.com',
common.mustCall((err, ips) => {
assert.ifError(err);
common.mustCall((err, ips) => {
assert.ifError(err);
assert.ok(ips.length > 0);
assert.ok(ips.length > 0);
for (let i = 0; i < ips.length; i++) {
assert.ok(isIPv4(ips[i]));
}
for (let i = 0; i < ips.length; i++) {
assert.ok(isIPv4(ips[i]));
}
done();
}));
done();
}));
checkWrap(req);
});
TEST(function test_reverse_ipv4(done) {
const req = dns.reverse('8.8.8.8',
common.mustCall((err, domains) => {
assert.ifError(err);
common.mustCall((err, domains) => {
assert.ifError(err);
assert.ok(domains.length > 0);
assert.ok(domains.length > 0);
for (let i = 0; i < domains.length; i++) {
assert.ok(domains[i]);
assert.ok(typeof domains[i] === 'string');
}
for (let i = 0; i < domains.length; i++) {
assert.ok(domains[i]);
assert.ok(typeof domains[i] === 'string');
}
done();
}));
done();
}));
checkWrap(req);
});
TEST(function test_lookup_ipv4_explicit(done) {
const req = dns.lookup('www.google.com', 4,
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);
done();
}));
done();
}));
checkWrap(req);
});
TEST(function test_lookup_ipv4_implicit(done) {
const req = dns.lookup('www.google.com',
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);
done();
}));
done();
}));
checkWrap(req);
});
@ -125,26 +125,26 @@ TEST(function test_lookup_ipv4_hint_addrconfig(done) {
TEST(function test_lookup_ip_ipv4(done) {
const req = dns.lookup('127.0.0.1',
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);
done();
}));
done();
}));
checkWrap(req);
});
TEST(function test_lookup_localhost_ipv4(done) {
const req = dns.lookup('localhost', 4,
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);
done();
}));
done();
}));
checkWrap(req);
});
@ -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);
});

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

@ -41,45 +41,45 @@ function checkWrap(req) {
TEST(function test_resolve6(done) {
const req = dns.resolve6('ipv6.google.com',
common.mustCall((err, ips) => {
assert.ifError(err);
common.mustCall((err, ips) => {
assert.ifError(err);
assert.ok(ips.length > 0);
assert.ok(ips.length > 0);
for (let i = 0; i < ips.length; i++)
assert.ok(isIPv6(ips[i]));
for (let i = 0; i < ips.length; i++)
assert.ok(isIPv6(ips[i]));
done();
}));
done();
}));
checkWrap(req);
});
TEST(function test_reverse_ipv6(done) {
const req = dns.reverse('2001:4860:4860::8888',
common.mustCall((err, domains) => {
assert.ifError(err);
common.mustCall((err, domains) => {
assert.ifError(err);
assert.ok(domains.length > 0);
assert.ok(domains.length > 0);
for (let i = 0; i < domains.length; i++)
assert.ok(typeof domains[i] === 'string');
for (let i = 0; i < domains.length; i++)
assert.ok(typeof domains[i] === 'string');
done();
}));
done();
}));
checkWrap(req);
});
TEST(function test_lookup_ipv6_explicit(done) {
const req = dns.lookup('ipv6.google.com', 6,
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(isIPv6(ip));
assert.strictEqual(family, 6);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(isIPv6(ip));
assert.strictEqual(family, 6);
done();
}));
done();
}));
checkWrap(req);
});
@ -142,13 +142,13 @@ TEST(function test_lookup_ipv6_hint(done) {
TEST(function test_lookup_ip_ipv6(done) {
const req = dns.lookup('::1',
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(isIPv6(ip));
assert.strictEqual(family, 6);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(isIPv6(ip));
assert.strictEqual(family, 6);
done();
}));
done();
}));
checkWrap(req);
});
@ -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);
});

8
test/parallel/test-assert.js

@ -64,7 +64,7 @@ assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, '2'),
// deepEqual joy!
// 7.2
assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000, 3, 14),
new Date(2000, 3, 14)),
new Date(2000, 3, 14)),
'deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))');
assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000, 3, 14)),
@ -81,7 +81,7 @@ assert.doesNotThrow(makeBlock(
a.notDeepEqual,
new Date(),
new Date(2000, 3, 14)),
'notDeepEqual(new Date(), new Date(2000, 3, 14))'
'notDeepEqual(new Date(), new Date(2000, 3, 14))'
);
// 7.3
@ -365,7 +365,7 @@ assert.doesNotThrow(function() { assert.ifError(); });
assert.throws(() => {
assert.doesNotThrow(makeBlock(thrower, Error), 'user message');
}, /Got unwanted exception. user message/,
'a.doesNotThrow ignores user message');
'a.doesNotThrow ignores user message');
// make sure that validating using constructor really works
threw = false;
@ -489,7 +489,7 @@ testAssertionMessage({}, '{}');
testAssertionMessage(circular, '{ y: 1, x: [Circular] }');
testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }');
testAssertionMessage({a: NaN, b: Infinity, c: -Infinity},
'{ a: NaN, b: Infinity, c: -Infinity }');
'{ a: NaN, b: Infinity, c: -Infinity }');
// #2893
try {

14
test/parallel/test-buffer-fill.js

@ -184,20 +184,20 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);
assert.throws(() => buf1.fill(0, -1), /^RangeError: Out of range index$/);
assert.throws(() =>
buf1.fill(0, 0, buf1.length + 1),
/^RangeError: Out of range index$/);
/^RangeError: Out of range index$/);
assert.throws(() => buf1.fill('', -1), /^RangeError: Out of range index$/);
assert.throws(() =>
buf1.fill('', 0, buf1.length + 1),
/^RangeError: Out of range index$/);
/^RangeError: Out of range index$/);
assert.throws(() =>
buf1.fill('a', 0, buf1.length, 'node rocks!'),
/^TypeError: Unknown encoding: node rocks!$/);
/^TypeError: Unknown encoding: node rocks!$/);
assert.throws(() =>
buf1.fill('a', 0, 0, NaN),
/^TypeError: encoding must be a string$/);
/^TypeError: encoding must be a string$/);
assert.throws(() =>
buf1.fill('a', 0, 0, null),
/^TypeError: encoding must be a string$/);
/^TypeError: encoding must be a string$/);
assert.throws(() =>
buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/);
@ -271,10 +271,10 @@ function testBufs(string, offset, length, encoding) {
// Make sure these throw.
assert.throws(() =>
Buffer.allocUnsafe(8).fill('a', -1),
/^RangeError: Out of range index$/);
/^RangeError: Out of range index$/);
assert.throws(() =>
Buffer.allocUnsafe(8).fill('a', 0, 9),
/^RangeError: Out of range index$/);
/^RangeError: Out of range index$/);
// Make sure this doesn't hang indefinitely.
Buffer.allocUnsafe(8).fill('');

4
test/parallel/test-buffer-includes.js

@ -159,10 +159,10 @@ assert(
6, mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2'));
assert(
10, mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'),
0, 'ucs2'));
0, 'ucs2'));
assert(
-1, mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'),
0, 'ucs2'));
0, 'ucs2'));
twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');

62
test/parallel/test-buffer-slice.js

@ -8,54 +8,54 @@ assert.strictEqual(0, Buffer('hello', 'utf8').slice(0, 0).length);
const buf = Buffer.from('0123456789', 'utf8');
assert.strictEqual(0, Buffer.compare(buf.slice(-10, 10),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(-20, 10),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(-20, -10),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(0),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(0, 0),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(undefined),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice('foobar'),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(undefined, undefined),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(2),
Buffer.from('23456789', 'utf8')));
Buffer.from('23456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(5),
Buffer.from('56789', 'utf8')));
Buffer.from('56789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(10),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(5, 8),
Buffer.from('567', 'utf8')));
Buffer.from('567', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(8, -1),
Buffer.from('8', 'utf8')));
Buffer.from('8', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(-10),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(0, -9),
Buffer.from('0', 'utf8')));
Buffer.from('0', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(0, -10),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(0, -1),
Buffer.from('012345678', 'utf8')));
Buffer.from('012345678', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(2, -2),
Buffer.from('234567', 'utf8')));
Buffer.from('234567', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(0, 65536),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(65536, 0),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(-5, -8),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(-5, -3),
Buffer.from('56', 'utf8')));
Buffer.from('56', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice(-10, 10),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
for (let i = 0, s = buf; i < buf.length; ++i) {
assert.strictEqual(0, Buffer.compare(buf.slice(i), s.slice(i)));
assert.strictEqual(0, Buffer.compare(buf.slice(0, i), s.slice(0, i)));
@ -67,19 +67,19 @@ const utf16Buf = Buffer.from('0123456789', 'utf16le');
assert.deepStrictEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le'));
assert.strictEqual(0, Buffer.compare(buf.slice('0', '1'),
Buffer.from('0', 'utf8')));
Buffer.from('0', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice('-5', '10'),
Buffer.from('56789', 'utf8')));
Buffer.from('56789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice('-10', '10'),
Buffer.from('0123456789', 'utf8')));
Buffer.from('0123456789', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice('-10', '-5'),
Buffer.from('01234', 'utf8')));
Buffer.from('01234', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice('-10', '-0'),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice('111'),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
assert.strictEqual(0, Buffer.compare(buf.slice('0', '-111'),
Buffer.from('', 'utf8')));
Buffer.from('', 'utf8')));
// try to slice a zero length Buffer
// see https://github.com/joyent/node/issues/5881

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

@ -18,27 +18,27 @@ var filename = __filename.replace(/\\/g, '/');
// assert that nothing is written to stdout
child.exec(nodejs + ' --eval 42',
function(err, stdout, stderr) {
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '');
});
function(err, stdout, stderr) {
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '');
});
// assert that "42\n" is written to stderr
child.exec(nodejs + ' --eval "console.error(42)"',
function(err, stdout, stderr) {
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '42\n');
});
function(err, stdout, stderr) {
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '42\n');
});
// assert that the expected output is written to stdout
['--print', '-p -e', '-pe', '-p'].forEach(function(s) {
var cmd = nodejs + ' ' + s + ' ';
child.exec(cmd + '42',
function(err, stdout, stderr) {
assert.strictEqual(stdout, '42\n');
assert.strictEqual(stderr, '');
});
function(err, stdout, stderr) {
assert.strictEqual(stdout, '42\n');
assert.strictEqual(stderr, '');
});
child.exec(cmd + "'[]'", common.mustCall(
function(err, stdout, stderr) {
@ -49,22 +49,22 @@ child.exec(nodejs + ' --eval "console.error(42)"',
// assert that module loading works
child.exec(nodejs + ' --eval "require(\'' + filename + '\')"',
function(status, stdout, stderr) {
assert.strictEqual(status.code, 42);
});
function(status, stdout, stderr) {
assert.strictEqual(status.code, 42);
});
// Check that builtin modules are pre-defined.
child.exec(nodejs + ' --print "os.platform()"',
function(status, stdout, stderr) {
assert.strictEqual(stderr, '');
assert.strictEqual(stdout.trim(), require('os').platform());
});
function(status, stdout, stderr) {
assert.strictEqual(stderr, '');
assert.strictEqual(stdout.trim(), require('os').platform());
});
// module path resolve bug, regression test
child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"',
function(status, stdout, stderr) {
assert.strictEqual(status.code, 42);
});
function(status, stdout, stderr) {
assert.strictEqual(status.code, 42);
});
// Missing argument should not crash
child.exec(nodejs + ' -e', common.mustCall(function(status, stdout, stderr) {
@ -80,24 +80,25 @@ child.exec(nodejs + ' -e ""', function(status, stdout, stderr) {
// "\\-42" should be interpreted as an escaped expression, not a switch
child.exec(nodejs + ' -p "\\-42"',
function(err, stdout, stderr) {
assert.strictEqual(stdout, '-42\n');
assert.strictEqual(stderr, '');
});
function(err, stdout, stderr) {
assert.strictEqual(stdout, '-42\n');
assert.strictEqual(stderr, '');
});
child.exec(nodejs + ' --use-strict -p process.execArgv',
function(status, stdout, stderr) {
assert.strictEqual(stdout,
"[ '--use-strict', '-p', 'process.execArgv' ]\n");
});
function(status, stdout, stderr) {
assert.strictEqual(
stdout, "[ '--use-strict', '-p', 'process.execArgv' ]\n"
);
});
// Regression test for https://github.com/nodejs/node/issues/3574
const emptyFile = path.join(common.fixturesDir, 'empty.js');
child.exec(nodejs + ` -e 'require("child_process").fork("${emptyFile}")'`,
function(status, stdout, stderr) {
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '');
});
function(status, stdout, stderr) {
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '');
});
// Regression test for https://github.com/nodejs/node/issues/8534.
{

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/);
}

4
test/parallel/test-crypto-hash.js

@ -109,9 +109,9 @@ h3.digest();
assert.throws(function() {
h3.digest();
},
/Digest already called/);
/Digest already called/);
assert.throws(function() {
h3.update('foo');
},
/Digest already called/);
/Digest already called/);

26
test/parallel/test-crypto-hmac.js

@ -115,7 +115,7 @@ var rfc4231 = [
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' +
'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
'hex'),
'hex'),
hmac: {
sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea',
sha256:
@ -132,10 +132,10 @@ var rfc4231 = [
},
{
key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819',
'hex'),
'hex'),
data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd',
'hex'),
'hex'),
hmac: {
sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a',
sha256:
@ -256,16 +256,16 @@ var rfc2202_md5 = [
key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' +
'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
'hex'),
'hex'),
hmac: '56be34521d144c88dbb8c733f0e8b3f6'
},
{
key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819',
'hex'),
'hex'),
data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
'cdcdcdcdcd',
'hex'),
'hex'),
hmac: '697eaf0aca3a3aea3a75164746ffaa79'
},
{
@ -278,7 +278,7 @@ var rfc2202_md5 = [
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaa',
'hex'),
'hex'),
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd'
},
@ -287,7 +287,7 @@ var rfc2202_md5 = [
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaa',
'hex'),
'hex'),
data:
'Test Using Larger Than Block-Size Key and Larger Than One ' +
'Block-Size Data',
@ -310,16 +310,16 @@ var rfc2202_sha1 = [
data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddd' +
'ddddddddddddddddddddddddddddddddddddddddddddd' +
'dddddddddd',
'hex'),
'hex'),
hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3'
},
{
key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819',
'hex'),
'hex'),
data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
'cdcdcdcdcd',
'hex'),
'hex'),
hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da'
},
{
@ -332,7 +332,7 @@ var rfc2202_sha1 = [
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaa',
'hex'),
'hex'),
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112'
},
@ -341,7 +341,7 @@ var rfc2202_sha1 = [
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
'aaaaaaaaaaaaaaaaaaaaaa',
'hex'),
'hex'),
data:
'Test Using Larger Than Block-Size Key and Larger Than One ' +
'Block-Size Data',

8
test/parallel/test-crypto-rsa-dsa.js

@ -14,15 +14,15 @@ const crypto = require('crypto');
var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem',
'ascii');
'ascii');
var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
'ascii');
'ascii');
var rsaKeyPemEncrypted = fs.readFileSync(
common.fixturesDir + '/test_rsa_privkey_encrypted.pem', 'ascii');
var dsaPubPem = fs.readFileSync(common.fixturesDir + '/test_dsa_pubkey.pem',
'ascii');
'ascii');
var dsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_dsa_privkey.pem',
'ascii');
'ascii');
var dsaKeyPemEncrypted = fs.readFileSync(
common.fixturesDir + '/test_dsa_privkey_encrypted.pem', 'ascii');

2
test/parallel/test-dns.js

@ -112,7 +112,7 @@ assert.doesNotThrow(() => dns.lookup(NaN, noop));
*/
assert.throws(() => {
dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 },
noop);
noop);
}, /^TypeError: Invalid argument: hints must use valid flags$/);
assert.throws(() => dns.lookup('www.google.com'),

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

@ -49,22 +49,24 @@ if (process.argv[2] === 'child') {
}
function runTestWithoutAbortOnUncaughtException() {
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
// message must include only the message of the error thrown from the
// process' uncaughtException handler.
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');
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
// message must include only the message of the error thrown from the
// process' uncaughtException handler.
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.notStrictEqual(err.code, 0,
'child process should have exited with a ' +
'non-zero exit code, but did not');
});
assert.notStrictEqual(err.code, 0,
'child process should have exited with a ' +
'non-zero exit code, but did not');
}
);
}
function runTestWithAbortOnUncaughtException() {

6
test/parallel/test-fs-non-number-arguments-throw.js

@ -16,17 +16,17 @@ const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 });
assert.throws(function() {
fs.createReadStream(tempFile, { start: '4', end: 6 });
}, /^TypeError: "start" option must be a Number$/,
"start as string didn't throw an error for createReadStream");
"start as string didn't throw an error for createReadStream");
assert.throws(function() {
fs.createReadStream(tempFile, { start: 4, end: '6' });
}, /^TypeError: "end" option must be a Number$/,
"end as string didn't throw an error for createReadStream");
"end as string didn't throw an error for createReadStream");
assert.throws(function() {
fs.createWriteStream(tempFile, { start: '4' });
}, /^TypeError: "start" option must be a Number$/,
"start as string didn't throw an error for createWriteStream");
"start as string didn't throw an error for createWriteStream");
saneEmitter.on('data', common.mustCall(function(data) {
assert.strictEqual(sanity, data.toString('utf8'), 'read ' +

28
test/parallel/test-fs-realpath.js

@ -137,13 +137,13 @@ function test_deep_relative_file_symlink(callback) {
.relative(path.join(targetsAbsDir, 'nested-index', 'one'),
expected);
const linkPath1 = path.join(targetsAbsDir,
'nested-index', 'one', 'symlink1.js');
'nested-index', 'one', 'symlink1.js');
try { fs.unlinkSync(linkPath1); } catch (e) {}
fs.symlinkSync(linkData1, linkPath1, 'file');
const linkData2 = '../one/symlink1.js';
const entry = path.join(targetsAbsDir,
'nested-index', 'two', 'symlink1-b.js');
'nested-index', 'two', 'symlink1-b.js');
try { fs.unlinkSync(entry); } catch (e) {}
fs.symlinkSync(linkData2, entry, 'file');
unlink.push(linkPath1);
@ -170,7 +170,7 @@ function test_deep_relative_dir_symlink(callback) {
const linkData2b = '../one/symlink1-dir';
const entry = path.join(targetsAbsDir,
'nested-index', 'two', 'symlink12-dir');
'nested-index', 'two', 'symlink12-dir');
try { fs.unlinkSync(entry); } catch (e) {}
fs.symlinkSync(linkData2b, entry, 'dir');
unlink.push(linkPath1b);
@ -237,7 +237,7 @@ function test_relative_input_cwd(callback) {
// we need to calculate the relative path to the tmp dir from cwd
const entrydir = process.cwd();
const entry = path.relative(entrydir,
path.join(common.tmpDir + '/cycles/realpath-3a'));
path.join(common.tmpDir + '/cycles/realpath-3a'));
const expected = common.tmpDir + '/cycles/root.js';
[
[entry, '../cycles/realpath-3b'],
@ -292,14 +292,14 @@ function test_deep_symlink_mix(callback) {
[
[entry, common.tmpDir + '/node-test-realpath-d1/foo'],
[tmp('node-test-realpath-d1'),
common.tmpDir + '/node-test-realpath-d2'],
common.tmpDir + '/node-test-realpath-d2'],
[tmp('node-test-realpath-d2/foo'), '../node-test-realpath-f2'],
[tmp('node-test-realpath-f2'), targetsAbsDir +
'/nested-index/one/realpath-c'],
[targetsAbsDir + '/nested-index/one/realpath-c', targetsAbsDir +
'/nested-index/two/realpath-c'],
[targetsAbsDir + '/nested-index/two/realpath-c',
common.tmpDir + '/cycles/root.js']
common.tmpDir + '/cycles/root.js']
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
fs.symlinkSync(t[1], t[0]);
@ -361,7 +361,7 @@ function test_up_multiple(cb) {
}
function cleanup() {
['a/b',
'a'
'a'
].forEach(function(folder) {
try { fs.rmdirSync(tmp(folder)); } catch (ex) {}
});
@ -418,14 +418,14 @@ function test_abs_with_kids(cb) {
const root = tmpAbsDir + '/node-test-realpath-abs-kids';
function cleanup() {
['/a/b/c/x.txt',
'/a/link'
'/a/link'
].forEach(function(file) {
try { fs.unlinkSync(root + file); } catch (ex) {}
});
['/a/b/c',
'/a/b',
'/a',
''
'/a/b',
'/a',
''
].forEach(function(folder) {
try { fs.rmdirSync(root + folder); } catch (ex) {}
});
@ -433,9 +433,9 @@ function test_abs_with_kids(cb) {
function setup() {
cleanup();
['',
'/a',
'/a/b',
'/a/b/c'
'/a',
'/a/b',
'/a/b/c'
].forEach(function(folder) {
console.log('mkdir ' + root + folder);
fs.mkdirSync(root + folder, 0o700);

6
test/parallel/test-http-double-content-length.js

@ -22,9 +22,9 @@ server.listen(0, () => {
port: server.address().port,
// Send two content-length header values.
headers: {'Content-Length': [1, 2]}},
(res) => {
common.fail('an error should have occurred');
}
(res) => {
common.fail('an error should have occurred');
}
);
req.on('error', common.mustCall(() => {
server.close();

8
test/parallel/test-http-localaddress.js

@ -21,10 +21,10 @@ var server = http.createServer(function(req, res) {
server.listen(0, '127.0.0.1', function() {
var options = { host: 'localhost',
port: this.address().port,
path: '/',
method: 'GET',
localAddress: '127.0.0.2' };
port: this.address().port,
path: '/',
method: 'GET',
localAddress: '127.0.0.2' };
var req = http.request(options, function(res) {
res.on('end', function() {

4
test/parallel/test-http-proxy.js

@ -10,8 +10,8 @@ var cookies = [
];
var headers = {'content-type': 'text/plain',
'set-cookie': cookies,
'hello': 'world' };
'set-cookie': cookies,
'hello': 'world' };
var backend = http.createServer(function(req, res) {
console.error('backend request');

8
test/parallel/test-os.js

@ -107,8 +107,8 @@ switch (platform) {
const filter = function(e) { return 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',
internal: true }];
mac: '00:00:00:00:00:00', family: 'IPv4',
internal: true }];
assert.deepStrictEqual(actual, expected);
break;
}
@ -117,8 +117,8 @@ switch (platform) {
const filter = function(e) { return 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',
internal: true }];
mac: '00:00:00:00:00:00', family: 'IPv4',
internal: true }];
assert.deepStrictEqual(actual, expected);
break;
}

83
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,
function(err, stdout, stderr) {
assert.ifError(err);
assert.strictEqual(stdout, 'A\nB\n');
});
childProcess.exec(nodeBinary + ' ' + preloadOption([fixtureA]) + ' ' + fixtureB,
function(err, stdout, stderr) {
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') + ' ' +
fixture('cluster-preload-test.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

10
test/parallel/test-querystring.js

@ -44,11 +44,11 @@ var qsTestCases = [
['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }],
// See: https://github.com/joyent/node/issues/1707
['hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz',
'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz',
{ hasOwnProperty: 'x',
toString: 'foo',
valueOf: 'bar',
__defineGetter__: 'baz' }],
'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz',
{ hasOwnProperty: 'x',
toString: 'foo',
valueOf: 'bar',
__defineGetter__: 'baz' }],
// See: https://github.com/joyent/node/issues/3058
['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }],
[null, '', {}],

2
test/parallel/test-readline-interface.js

@ -62,7 +62,7 @@ function isWarned(emitter) {
// disable history
fi = new FakeInput();
rli = new readline.Interface({ input: fi, output: fi, terminal: terminal,
historySize: 0 });
historySize: 0 });
assert.strictEqual(rli.historySize, 0);
fi.emit('data', 'asdf\n');

2
test/parallel/test-repl-tab-complete.js

@ -290,7 +290,7 @@ const testNonGlobal = repl.start({
});
const builtins = [['Infinity', '', 'Int16Array', 'Int32Array',
'Int8Array'], 'I'];
'Int8Array'], 'I'];
if (common.hasIntl) {
builtins[0].push('Intl');

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

@ -11,13 +11,15 @@ const util = require('util');
common.refreshTmpDir();
const linkTarget = path.join(common.fixturesDir,
'/module-require-symlink/node_modules/dep2/');
'/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');
'/module-require-symlink/symlinked.js');
const linkScript = path.join(common.tmpDir, 'module-require-symlink.js');

2
test/parallel/test-spawn-cmd-named-pipe.js

@ -43,7 +43,7 @@ if (!process.argv[2]) {
}
const args = ['/c', process.execPath, __filename, 'child',
'<', stdinPipeName, '>', stdoutPipeName];
'<', stdinPipeName, '>', stdoutPipeName];
const child = spawn(comspec, args);

38
test/parallel/test-tls-client-verify.js

@ -12,36 +12,36 @@ const fs = require('fs');
const hosterr = /Hostname\/IP doesn't match certificate's altnames/g;
const testCases =
[{ ca: ['ca1-cert'],
key: 'agent2-key',
cert: 'agent2-cert',
servers: [
[{ ca: ['ca1-cert'],
key: 'agent2-key',
cert: 'agent2-cert',
servers: [
{ ok: true, key: 'agent1-key', cert: 'agent1-cert' },
{ ok: false, key: 'agent2-key', cert: 'agent2-cert' },
{ ok: false, key: 'agent3-key', cert: 'agent3-cert' }
]
},
]
},
{ ca: [],
key: 'agent2-key',
cert: 'agent2-cert',
servers: [
{ ca: [],
key: 'agent2-key',
cert: 'agent2-cert',
servers: [
{ ok: false, key: 'agent1-key', cert: 'agent1-cert' },
{ ok: false, key: 'agent2-key', cert: 'agent2-cert' },
{ ok: false, key: 'agent3-key', cert: 'agent3-cert' }
]
},
]
},
{ ca: ['ca1-cert', 'ca2-cert'],
key: 'agent2-key',
cert: 'agent2-cert',
servers: [
{ ca: ['ca1-cert', 'ca2-cert'],
key: 'agent2-key',
cert: 'agent2-cert',
servers: [
{ ok: true, key: 'agent1-key', cert: 'agent1-cert' },
{ ok: false, key: 'agent2-key', cert: 'agent2-cert' },
{ ok: true, key: 'agent3-key', cert: 'agent3-cert' }
]
}
];
]
}
];
function filenamePEM(n) {
return require('path').join(common.fixturesDir, 'keys', n + '.pem');

4
test/parallel/test-tls-no-sslv3.js

@ -25,8 +25,8 @@ let stderr = '';
server.listen(0, '127.0.0.1', function() {
const address = this.address().address + ':' + this.address().port;
const args = ['s_client',
'-ssl3',
'-connect', address];
'-ssl3',
'-connect', address];
// for the performance and stability issue in s_client on Windows
if (common.isWindows)

2
test/parallel/test-tls-server-failed-handshake-emits-clienterror.js

@ -23,7 +23,7 @@ const server = tls.createServer({})
'Instance of Error should be passed to error handler');
assert.ok(e.message.match(
/SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol/),
'Expecting SSL unknown protocol');
'Expecting SSL unknown protocol');
server.close();
}));

118
test/parallel/test-tls-server-verify.js

@ -15,88 +15,88 @@ if (!common.opensslCli) {
// - accepted and "authorized".
const testCases =
[{ title: 'Do not request certs. Everyone is unauthorized.',
requestCert: false,
rejectUnauthorized: false,
renegotiate: false,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: false },
[{ title: 'Do not request certs. Everyone is unauthorized.',
requestCert: false,
rejectUnauthorized: false,
renegotiate: false,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: false },
{ name: 'agent2', shouldReject: false, shouldAuth: false },
{ name: 'agent3', shouldReject: false, shouldAuth: false },
{ name: 'nocert', shouldReject: false, shouldAuth: false }
]
},
{ title: 'Allow both authed and unauthed connections with CA1',
requestCert: true,
rejectUnauthorized: false,
renegotiate: false,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
]
},
{ title: 'Allow both authed and unauthed connections with CA1',
requestCert: true,
rejectUnauthorized: false,
renegotiate: false,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
{ name: 'agent2', shouldReject: false, shouldAuth: false },
{ name: 'agent3', shouldReject: false, shouldAuth: false },
{ name: 'nocert', shouldReject: false, shouldAuth: false }
]
},
{ title: 'Do not request certs at connection. Do that later',
requestCert: false,
rejectUnauthorized: false,
renegotiate: true,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
]
},
{ title: 'Do not request certs at connection. Do that later',
requestCert: false,
rejectUnauthorized: false,
renegotiate: true,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
{ name: 'agent2', shouldReject: false, shouldAuth: false },
{ name: 'agent3', shouldReject: false, shouldAuth: false },
{ name: 'nocert', shouldReject: false, shouldAuth: false }
]
},
{ title: 'Allow only authed connections with CA1',
requestCert: true,
rejectUnauthorized: true,
renegotiate: false,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
]
},
{ title: 'Allow only authed connections with CA1',
requestCert: true,
rejectUnauthorized: true,
renegotiate: false,
CAs: ['ca1-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
{ name: 'agent2', shouldReject: true },
{ name: 'agent3', shouldReject: true },
{ name: 'nocert', shouldReject: true }
]
},
{ title: 'Allow only authed connections with CA1 and CA2',
requestCert: true,
rejectUnauthorized: true,
renegotiate: false,
CAs: ['ca1-cert', 'ca2-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
]
},
{ title: 'Allow only authed connections with CA1 and CA2',
requestCert: true,
rejectUnauthorized: true,
renegotiate: false,
CAs: ['ca1-cert', 'ca2-cert'],
clients:
[{ name: 'agent1', shouldReject: false, shouldAuth: true },
{ name: 'agent2', shouldReject: true },
{ name: 'agent3', shouldReject: false, shouldAuth: true },
{ name: 'nocert', shouldReject: true }
]
},
]
},
{ title: 'Allow only certs signed by CA2 but not in the CRL',
requestCert: true,
rejectUnauthorized: true,
renegotiate: false,
CAs: ['ca2-cert'],
crl: 'ca2-crl',
clients: [
{ title: 'Allow only certs signed by CA2 but not in the CRL',
requestCert: true,
rejectUnauthorized: true,
renegotiate: false,
CAs: ['ca2-cert'],
crl: 'ca2-crl',
clients: [
{ name: 'agent1', shouldReject: true, shouldAuth: false },
{ name: 'agent2', shouldReject: true, shouldAuth: false },
{ name: 'agent3', shouldReject: false, shouldAuth: true },
// Agent4 has a cert in the CRL.
{ name: 'agent4', shouldReject: true, shouldAuth: false },
{ name: 'nocert', shouldReject: true }
]
}
];
]
}
];
if (!common.hasCrypto) {
common.skip('missing crypto');

2
test/parallel/test-tls-socket-failed-handshake-emits-error.js

@ -23,7 +23,7 @@ const server = net.createServer(function(c) {
'Instance of Error should be passed to error handler');
assert.ok(e.message.match(
/SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol/),
'Expecting SSL unknown protocol');
'Expecting SSL unknown protocol');
}));
s.on('close', function() {

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

@ -42,7 +42,7 @@ assert.strictEqual(util.inspect({'a': {'b': { 'c': 2}}}, false, 1),
'{ a: { b: [Object] } }');
assert.strictEqual(util.inspect(Object.create({},
{visible: {value: 1, enumerable: true}, hidden: {value: 2}})),
'{ visible: 1 }'
'{ visible: 1 }'
);
{
@ -206,8 +206,9 @@ for (const showHidden of [true, false]) {
// Objects without prototype
{
const out = util.inspect(Object.create(null,
{ name: {value: 'Tim', enumerable: true},
hidden: {value: 'secret'}}), true);
{ name: {value: 'Tim',
enumerable: true},
hidden: {value: 'secret'}}), true);
if (out !== "{ [hidden]: 'secret', name: 'Tim' }" &&
out !== "{ name: 'Tim', [hidden]: 'secret' }") {
common.fail(`unexpected value for out ${out}`);
@ -216,8 +217,8 @@ for (const showHidden of [true, false]) {
assert.strictEqual(
util.inspect(Object.create(null,
{name: {value: 'Tim', enumerable: true},
hidden: {value: 'secret'}})),
{name: {value: 'Tim', enumerable: true},
hidden: {value: 'secret'}})),
'{ name: \'Tim\' }'
);

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

@ -16,41 +16,41 @@ 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');
waitForPendingSignal(common.mustCall(() => {
const hadPendingSignals = binding.stopSigintWatchdog();
assert.strictEqual(hadPendingSignals, true);
next();
}));
},
(next) => {
binding.startSigintWatchdog();
process.kill(process.pid, 'SIGINT');
waitForPendingSignal(common.mustCall(() => {
const hadPendingSignals = binding.stopSigintWatchdog();
assert.strictEqual(hadPendingSignals, true);
next();
}));
},
(next) => {
// Nested calls are okay.
binding.startSigintWatchdog();
binding.startSigintWatchdog();
process.kill(process.pid, 'SIGINT');
waitForPendingSignal(common.mustCall(() => {
const hadPendingSignals1 = binding.stopSigintWatchdog();
const hadPendingSignals2 = binding.stopSigintWatchdog();
assert.strictEqual(hadPendingSignals1, true);
assert.strictEqual(hadPendingSignals2, false);
next();
}));
},
() => {
binding.startSigintWatchdog();
binding.startSigintWatchdog();
process.kill(process.pid, 'SIGINT');
waitForPendingSignal(common.mustCall(() => {
const hadPendingSignals1 = binding.stopSigintWatchdog();
const hadPendingSignals2 = binding.stopSigintWatchdog();
assert.strictEqual(hadPendingSignals1, true);
assert.strictEqual(hadPendingSignals2, false);
next();
}));
},
() => {
// Signal comes in after first call to stop.
binding.startSigintWatchdog();
binding.startSigintWatchdog();
const hadPendingSignals1 = binding.stopSigintWatchdog();
process.kill(process.pid, 'SIGINT');
waitForPendingSignal(common.mustCall(() => {
const hadPendingSignals2 = binding.stopSigintWatchdog();
assert.strictEqual(hadPendingSignals1, false);
assert.strictEqual(hadPendingSignals2, true);
}));
}].reduceRight((a, b) => common.mustCall(b).bind(null, a))();
binding.startSigintWatchdog();
binding.startSigintWatchdog();
const hadPendingSignals1 = binding.stopSigintWatchdog();
process.kill(process.pid, 'SIGINT');
waitForPendingSignal(common.mustCall(() => {
const hadPendingSignals2 = binding.stopSigintWatchdog();
assert.strictEqual(hadPendingSignals1, false);
assert.strictEqual(hadPendingSignals2, true);
}));
}].reduceRight((a, b) => common.mustCall(b).bind(null, a))();
function waitForPendingSignal(cb) {
if (binding.watchdogHasPendingSigint())

6
test/parallel/test-whatwg-url-properties.js

@ -19,9 +19,9 @@ for (const prop in url) {
// https://heycam.github.io/webidl/#es-attributes
// https://heycam.github.io/webidl/#es-stringifier
const expected = ['toString',
'href', 'origin', 'protocol',
'username', 'password', 'host', 'hostname', 'port',
'pathname', 'search', 'searchParams', 'hash'];
'href', 'origin', 'protocol',
'username', 'password', 'host', 'hostname', 'port',
'pathname', 'search', 'searchParams', 'hash'];
assert.deepStrictEqual(props, expected);

2
test/parallel/test-zerolengthbufferbug.js

@ -8,7 +8,7 @@ var server = http.createServer(function(req, res) {
var buffer = Buffer.alloc(0);
// FIXME: WTF gjslint want this?
res.writeHead(200, {'Content-Type': 'text/html',
'Content-Length': buffer.length});
'Content-Length': buffer.length});
res.end(buffer);
});

6
test/parallel/test-zlib-invalid-input.js

@ -21,9 +21,9 @@ nonStringInputs.forEach(function(input) {
console.error('Doing the unzips');
// zlib.Unzip classes need to get valid data, or else they'll throw.
const unzips = [ zlib.Unzip(),
zlib.Gunzip(),
zlib.Inflate(),
zlib.InflateRaw() ];
zlib.Gunzip(),
zlib.Inflate(),
zlib.InflateRaw() ];
var hadError = [];
unzips.forEach(function(uz, i) {
console.error('Error for ' + uz.constructor.name);

6
test/parallel/test-zlib.js

@ -150,9 +150,9 @@ Object.keys(tests).forEach(function(file) {
var Def = pair[0];
var Inf = pair[1];
var opts = { level: level,
windowBits: windowBits,
memLevel: memLevel,
strategy: strategy };
windowBits: windowBits,
memLevel: memLevel,
strategy: strategy };
total++;

6
test/sequential/test-crypto-timing-safe-equal.js

@ -24,14 +24,14 @@ assert.strictEqual(
assert.throws(function() {
crypto.timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2]));
}, /^TypeError: Input buffers must have the same length$/,
'should throw when given buffers with different lengths');
'should throw when given buffers with different lengths');
assert.throws(function() {
crypto.timingSafeEqual('not a buffer', Buffer.from([1, 2]));
}, /^TypeError: First argument must be a buffer$/,
'should throw if the first argument is not a buffer');
'should throw if the first argument is not a buffer');
assert.throws(function() {
crypto.timingSafeEqual(Buffer.from([1, 2]), 'not a buffer');
}, /^TypeError: Second argument must be a buffer$/,
'should throw if the second argument is not a buffer');
'should throw if the second argument is not a buffer');

Loading…
Cancel
Save