Browse Source

test,lib: align arguments in multiline calls

An upcoming custom lint rule will provide slightly more strict
enforcement of argument alignment for multiline function calls. Adjust
existing code to conform.

PR-URL: https://github.com/nodejs/node/pull/8642
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
v7.x
Rich Trott 9 years ago
parent
commit
4316f4df31
  1. 2
      lib/repl.js
  2. 10
      test/parallel/test-assert.js
  3. 5
      test/parallel/test-buffer-alloc.js
  4. 5
      test/parallel/test-buffer-bytelength.js
  5. 2
      test/parallel/test-buffer-inheritance.js
  6. 2
      test/parallel/test-debugger-util-regression.js
  7. 6
      test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js
  8. 2
      test/parallel/test-domain-with-abort-on-uncaught-exception.js
  9. 36
      test/parallel/test-fs-write.js
  10. 8
      test/parallel/test-http-invalidheaderfield2.js
  11. 36
      test/parallel/test-timers-throw-when-cb-not-function.js
  12. 130
      test/parallel/test-util-inspect.js
  13. 4
      test/parallel/test-vm-symbols.js
  14. 21
      test/parallel/test-zlib-from-concatenated-gzip.js
  15. 2
      test/parallel/test-zlib-unzip-one-byte-chunks.js

2
lib/repl.js

@ -696,7 +696,7 @@ REPLServer.prototype.createContext = function() {
return GLOBAL_OBJECT_PROPERTY_MAP[name] === undefined; return GLOBAL_OBJECT_PROPERTY_MAP[name] === undefined;
}).forEach((name) => { }).forEach((name) => {
Object.defineProperty(context, name, Object.defineProperty(context, name,
Object.getOwnPropertyDescriptor(global, name)); Object.getOwnPropertyDescriptor(global, name));
}); });
} }

10
test/parallel/test-assert.js

@ -28,7 +28,7 @@ assert.doesNotThrow(makeBlock(a.ok, true),
assert.doesNotThrow(makeBlock(a.ok, 'test'), 'ok(\'test\')'); assert.doesNotThrow(makeBlock(a.ok, 'test'), 'ok(\'test\')');
assert.throws(makeBlock(a.equal, true, false), assert.throws(makeBlock(a.equal, true, false),
a.AssertionError, 'equal(true, false)'); a.AssertionError, 'equal(true, false)');
assert.doesNotThrow(makeBlock(a.equal, null, null), assert.doesNotThrow(makeBlock(a.equal, null, null),
'equal(null, null)'); 'equal(null, null)');
@ -71,10 +71,8 @@ assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000, 3, 14)),
a.AssertionError, a.AssertionError,
'deepEqual(new Date(), new Date(2000, 3, 14))'); 'deepEqual(new Date(), new Date(2000, 3, 14))');
assert.throws(makeBlock( assert.throws(
a.notDeepEqual, makeBlock(a.notDeepEqual, new Date(2000, 3, 14), new Date(2000, 3, 14)),
new Date(2000, 3, 14),
new Date(2000, 3, 14)),
a.AssertionError, a.AssertionError,
'notDeepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))' 'notDeepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))'
); );
@ -465,7 +463,7 @@ function testAssertionMessage(actual, expected) {
assert.equal(actual, ''); assert.equal(actual, '');
} catch (e) { } catch (e) {
assert.equal(e.toString(), assert.equal(e.toString(),
['AssertionError:', expected, '==', '\'\''].join(' ')); ['AssertionError:', expected, '==', '\'\''].join(' '));
assert.ok(e.generatedMessage, 'Message not marked as generated'); assert.ok(e.generatedMessage, 'Message not marked as generated');
} }
} }

5
test/parallel/test-buffer-alloc.js

@ -243,8 +243,9 @@ assert.doesNotThrow(() => Buffer.alloc(1).write('', 1, 0));
{ {
// Length should be 12 // Length should be 12
const f = Buffer.from('привет', encoding); const f = Buffer.from('привет', encoding);
assert.deepStrictEqual(f, assert.deepStrictEqual(
Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])); f, Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])
);
assert.strictEqual(f.toString(encoding), 'привет'); assert.strictEqual(f.toString(encoding), 'привет');
} }

5
test/parallel/test-buffer-bytelength.js

@ -74,8 +74,9 @@ assert.strictEqual(Buffer.byteLength('ßœ∑≈', 'unkn0wn enc0ding'), 10);
assert.strictEqual(Buffer.byteLength('aGVsbG8gd29ybGQ=', 'base64'), 11); assert.strictEqual(Buffer.byteLength('aGVsbG8gd29ybGQ=', 'base64'), 11);
assert.strictEqual(Buffer.byteLength('bm9kZS5qcyByb2NrcyE=', 'base64'), 14); assert.strictEqual(Buffer.byteLength('bm9kZS5qcyByb2NrcyE=', 'base64'), 14);
assert.strictEqual(Buffer.byteLength('aGkk', 'base64'), 3); assert.strictEqual(Buffer.byteLength('aGkk', 'base64'), 3);
assert.strictEqual(Buffer.byteLength('bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==', assert.strictEqual(
'base64'), 25); Buffer.byteLength('bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==', 'base64'), 25
);
// special padding // special padding
assert.strictEqual(Buffer.byteLength('aaa=', 'base64'), 2); assert.strictEqual(Buffer.byteLength('aaa=', 'base64'), 2);
assert.strictEqual(Buffer.byteLength('aaaa==', 'base64'), 3); assert.strictEqual(Buffer.byteLength('aaaa==', 'base64'), 3);

2
test/parallel/test-buffer-inheritance.js

@ -26,7 +26,7 @@ vals.forEach(function(t) {
assert.strictEqual(t.constructor, T); assert.strictEqual(t.constructor, T);
assert.strictEqual(Object.getPrototypeOf(t), T.prototype); assert.strictEqual(Object.getPrototypeOf(t), T.prototype);
assert.strictEqual(Object.getPrototypeOf(Object.getPrototypeOf(t)), assert.strictEqual(Object.getPrototypeOf(Object.getPrototypeOf(t)),
Buffer.prototype); Buffer.prototype);
t.fill(5); t.fill(5);
let cntr = 0; let cntr = 0;

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

@ -62,6 +62,6 @@ proc.stdin.on('error', (err) => {
process.on('exit', (code) => { process.on('exit', (code) => {
assert.equal(code, 0, 'the program should exit cleanly'); assert.equal(code, 0, 'the program should exit cleanly');
assert.equal(stdout.includes('{ a: \'b\' }'), true, assert.equal(stdout.includes('{ a: \'b\' }'), true,
'the debugger should print the result of util.inspect'); 'the debugger should print the result of util.inspect');
assert.equal(stderr, '', 'stderr should be empty'); assert.equal(stderr, '', 'stderr should be empty');
}); });

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

@ -56,8 +56,8 @@ function runTestWithoutAbortOnUncaughtException() {
// message must include only the message of the error thrown from the // message must include only the message of the error thrown from the
// process' uncaughtException handler. // process' uncaughtException handler.
assert(stderr.includes(uncaughtExceptionHandlerErrMsg), assert(stderr.includes(uncaughtExceptionHandlerErrMsg),
'stderr output must include proper uncaughtException handler\'s ' + 'stderr output must include proper uncaughtException ' +
'error\'s message'); 'handler\'s error\'s message');
assert(!stderr.includes(domainErrMsg), 'stderr output must not ' + assert(!stderr.includes(domainErrMsg), 'stderr output must not ' +
'include domain\'s error\'s message'); 'include domain\'s error\'s message');
@ -75,7 +75,7 @@ function runTestWithAbortOnUncaughtException() {
'child process should not have run its uncaughtException ' + 'child process should not have run its uncaughtException ' +
'event handler'); 'event handler');
assert(common.nodeProcessAborted(err.code, err.signal), assert(common.nodeProcessAborted(err.code, err.signal),
'process should have aborted, but did not'); 'process should have aborted, but did not');
}); });
} }

2
test/parallel/test-domain-with-abort-on-uncaught-exception.js

@ -121,7 +121,7 @@ if (process.argv[2] === 'child') {
if (!options.useTryCatch && options.throwInDomainErrHandler) { if (!options.useTryCatch && options.throwInDomainErrHandler) {
if (cmdLineOption === '--abort_on_uncaught_exception') { if (cmdLineOption === '--abort_on_uncaught_exception') {
assert(common.nodeProcessAborted(exitCode, signal), assert(common.nodeProcessAborted(exitCode, signal),
'process should have aborted, but did not'); 'process should have aborted, but did not');
} else { } else {
// By default, uncaught exceptions make node exit with an exit // By default, uncaught exceptions make node exit with an exit
// code of 7. // code of 7.

36
test/parallel/test-fs-write.js

@ -32,21 +32,21 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644, fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644,
common.mustCall(function(err, fd) { common.mustCall((err, fd) => {
if (err) throw err; if (err) throw err;
console.log('open done'); console.log('open done');
fs.write(fd, '', 0, 'utf8', function(err, written) { fs.write(fd, '', 0, 'utf8', (err, written) => {
assert.equal(0, written); assert.equal(0, written);
}); });
fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) { fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => {
console.log('write done'); console.log('write done');
if (err) throw err; if (err) throw err;
assert.equal(Buffer.byteLength(expected), written); assert.equal(Buffer.byteLength(expected), written);
fs.closeSync(fd); fs.closeSync(fd);
const found = fs.readFileSync(fn2, 'utf8'); const found = fs.readFileSync(fn2, 'utf8');
console.log('expected: "%s"', expected); console.log('expected: "%s"', expected);
console.log('found: "%s"', found); console.log('found: "%s"', found);
fs.unlinkSync(fn2); fs.unlinkSync(fn2);
assert.strictEqual(expected, found); assert.strictEqual(expected, found);
})); }));
})); }));

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

@ -90,8 +90,8 @@ const checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar;
'Ding!\x07' 'Ding!\x07'
].forEach(function(str) { ].forEach(function(str) {
assert.strictEqual(checkInvalidHeaderChar(str), assert.strictEqual(checkInvalidHeaderChar(str),
true, true,
'checkInvalidHeaderChar(' + 'checkInvalidHeaderChar(' +
inspect(str) + inspect(str) +
') unexpectedly succeeded'); ') unexpectedly succeeded');
}); });

36
test/parallel/test-timers-throw-when-cb-not-function.js

@ -9,17 +9,17 @@ function doSetTimeout(callback, after) {
} }
assert.throws(doSetTimeout('foo'), assert.throws(doSetTimeout('foo'),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetTimeout({foo: 'bar'}), assert.throws(doSetTimeout({foo: 'bar'}),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetTimeout(), assert.throws(doSetTimeout(),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetTimeout(undefined, 0), assert.throws(doSetTimeout(undefined, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetTimeout(null, 0), assert.throws(doSetTimeout(null, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetTimeout(false, 0), assert.throws(doSetTimeout(false, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
function doSetInterval(callback, after) { function doSetInterval(callback, after) {
@ -29,17 +29,17 @@ function doSetInterval(callback, after) {
} }
assert.throws(doSetInterval('foo'), assert.throws(doSetInterval('foo'),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetInterval({foo: 'bar'}), assert.throws(doSetInterval({foo: 'bar'}),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetInterval(), assert.throws(doSetInterval(),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetInterval(undefined, 0), assert.throws(doSetInterval(undefined, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetInterval(null, 0), assert.throws(doSetInterval(null, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetInterval(false, 0), assert.throws(doSetInterval(false, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
function doSetImmediate(callback, after) { function doSetImmediate(callback, after) {
@ -49,14 +49,14 @@ function doSetImmediate(callback, after) {
} }
assert.throws(doSetImmediate('foo'), assert.throws(doSetImmediate('foo'),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetImmediate({foo: 'bar'}), assert.throws(doSetImmediate({foo: 'bar'}),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetImmediate(), assert.throws(doSetImmediate(),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetImmediate(undefined, 0), assert.throws(doSetImmediate(undefined, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetImmediate(null, 0), assert.throws(doSetImmediate(null, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);
assert.throws(doSetImmediate(false, 0), assert.throws(doSetImmediate(false, 0),
/"callback" argument must be a function/); /"callback" argument must be a function/);

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

@ -12,8 +12,10 @@ assert.strictEqual(util.inspect(function() {}), '[Function]');
assert.strictEqual(util.inspect(undefined), 'undefined'); assert.strictEqual(util.inspect(undefined), 'undefined');
assert.strictEqual(util.inspect(null), 'null'); assert.strictEqual(util.inspect(null), 'null');
assert.strictEqual(util.inspect(/foo(bar\n)?/gi), '/foo(bar\\n)?/gi'); assert.strictEqual(util.inspect(/foo(bar\n)?/gi), '/foo(bar\\n)?/gi');
assert.strictEqual(util.inspect(new Date('Sun, 14 Feb 2010 11:48:40 GMT')), assert.strictEqual(
new Date('2010-02-14T12:48:40+01:00').toISOString()); util.inspect(new Date('Sun, 14 Feb 2010 11:48:40 GMT')),
new Date('2010-02-14T12:48:40+01:00').toISOString()
);
assert.strictEqual(util.inspect(new Date('')), (new Date('')).toString()); assert.strictEqual(util.inspect(new Date('')), (new Date('')).toString());
assert.strictEqual(util.inspect('\n\u0001'), "'\\n\\u0001'"); assert.strictEqual(util.inspect('\n\u0001'), "'\\n\\u0001'");
@ -30,14 +32,14 @@ assert.strictEqual(util.inspect({a: 1, b: 2}), '{ a: 1, b: 2 }');
assert.strictEqual(util.inspect({'a': {}}), '{ a: {} }'); assert.strictEqual(util.inspect({'a': {}}), '{ a: {} }');
assert.strictEqual(util.inspect({'a': {'b': 2}}), '{ a: { b: 2 } }'); assert.strictEqual(util.inspect({'a': {'b': 2}}), '{ a: { b: 2 } }');
assert.strictEqual(util.inspect({'a': {'b': { 'c': { 'd': 2 }}}}), assert.strictEqual(util.inspect({'a': {'b': { 'c': { 'd': 2 }}}}),
'{ a: { b: { c: [Object] } } }'); '{ a: { b: { c: [Object] } } }');
assert.strictEqual(util.inspect({'a': {'b': { 'c': { 'd': 2 }}}}, false, null), assert.strictEqual(util.inspect({'a': {'b': { 'c': { 'd': 2 }}}}, false, null),
'{ a: { b: { c: { d: 2 } } } }'); '{ a: { b: { c: { d: 2 } } } }');
assert.strictEqual(util.inspect([1, 2, 3], true), '[ 1, 2, 3, [length]: 3 ]'); assert.strictEqual(util.inspect([1, 2, 3], true), '[ 1, 2, 3, [length]: 3 ]');
assert.strictEqual(util.inspect({'a': {'b': { 'c': 2}}}, false, 0), assert.strictEqual(util.inspect({'a': {'b': { 'c': 2}}}, false, 0),
'{ a: [Object] }'); '{ a: [Object] }');
assert.strictEqual(util.inspect({'a': {'b': { 'c': 2}}}, false, 1), assert.strictEqual(util.inspect({'a': {'b': { 'c': 2}}}, false, 1),
'{ a: { b: [Object] } }'); '{ a: { b: [Object] } }');
assert.strictEqual(util.inspect(Object.create({}, assert.strictEqual(util.inspect(Object.create({},
{visible: {value: 1, enumerable: true}, hidden: {value: 2}})), {visible: {value: 1, enumerable: true}, hidden: {value: 2}})),
'{ visible: 1 }' '{ visible: 1 }'
@ -64,29 +66,29 @@ for (const showHidden of [true, false]) {
'ArrayBuffer { byteLength: 4 }' 'ArrayBuffer { byteLength: 4 }'
); );
assert.strictEqual(util.inspect(new DataView(ab, 1, 2), showHidden), assert.strictEqual(util.inspect(new DataView(ab, 1, 2), showHidden),
'DataView {\n' + 'DataView {\n' +
' byteLength: 2,\n' + ' byteLength: 2,\n' +
' byteOffset: 1,\n' + ' byteOffset: 1,\n' +
' buffer: ArrayBuffer { byteLength: 4 } }'); ' buffer: ArrayBuffer { byteLength: 4 } }');
assert.strictEqual( assert.strictEqual(
util.inspect(ab, showHidden), util.inspect(ab, showHidden),
'ArrayBuffer { byteLength: 4 }' 'ArrayBuffer { byteLength: 4 }'
); );
assert.strictEqual(util.inspect(dv, showHidden), assert.strictEqual(util.inspect(dv, showHidden),
'DataView {\n' + 'DataView {\n' +
' byteLength: 2,\n' + ' byteLength: 2,\n' +
' byteOffset: 1,\n' + ' byteOffset: 1,\n' +
' buffer: ArrayBuffer { byteLength: 4 } }'); ' buffer: ArrayBuffer { byteLength: 4 } }');
ab.x = 42; ab.x = 42;
dv.y = 1337; dv.y = 1337;
assert.strictEqual(util.inspect(ab, showHidden), assert.strictEqual(util.inspect(ab, showHidden),
'ArrayBuffer { byteLength: 4, x: 42 }'); 'ArrayBuffer { byteLength: 4, x: 42 }');
assert.strictEqual(util.inspect(dv, showHidden), assert.strictEqual(util.inspect(dv, showHidden),
'DataView {\n' + 'DataView {\n' +
' byteLength: 2,\n' + ' byteLength: 2,\n' +
' byteOffset: 1,\n' + ' byteOffset: 1,\n' +
' buffer: ArrayBuffer { byteLength: 4, x: 42 },\n' + ' buffer: ArrayBuffer { byteLength: 4, x: 42 },\n' +
' y: 1337 }'); ' y: 1337 }');
} }
// Now do the same checks but from a different context // Now do the same checks but from a different context
@ -98,29 +100,29 @@ for (const showHidden of [true, false]) {
'ArrayBuffer { byteLength: 4 }' 'ArrayBuffer { byteLength: 4 }'
); );
assert.strictEqual(util.inspect(new DataView(ab, 1, 2), showHidden), assert.strictEqual(util.inspect(new DataView(ab, 1, 2), showHidden),
'DataView {\n' + 'DataView {\n' +
' byteLength: 2,\n' + ' byteLength: 2,\n' +
' byteOffset: 1,\n' + ' byteOffset: 1,\n' +
' buffer: ArrayBuffer { byteLength: 4 } }'); ' buffer: ArrayBuffer { byteLength: 4 } }');
assert.strictEqual( assert.strictEqual(
util.inspect(ab, showHidden), util.inspect(ab, showHidden),
'ArrayBuffer { byteLength: 4 }' 'ArrayBuffer { byteLength: 4 }'
); );
assert.strictEqual(util.inspect(dv, showHidden), assert.strictEqual(util.inspect(dv, showHidden),
'DataView {\n' + 'DataView {\n' +
' byteLength: 2,\n' + ' byteLength: 2,\n' +
' byteOffset: 1,\n' + ' byteOffset: 1,\n' +
' buffer: ArrayBuffer { byteLength: 4 } }'); ' buffer: ArrayBuffer { byteLength: 4 } }');
ab.x = 42; ab.x = 42;
dv.y = 1337; dv.y = 1337;
assert.strictEqual(util.inspect(ab, showHidden), assert.strictEqual(util.inspect(ab, showHidden),
'ArrayBuffer { byteLength: 4, x: 42 }'); 'ArrayBuffer { byteLength: 4, x: 42 }');
assert.strictEqual(util.inspect(dv, showHidden), assert.strictEqual(util.inspect(dv, showHidden),
'DataView {\n' + 'DataView {\n' +
' byteLength: 2,\n' + ' byteLength: 2,\n' +
' byteOffset: 1,\n' + ' byteOffset: 1,\n' +
' buffer: ArrayBuffer { byteLength: 4, x: 42 },\n' + ' buffer: ArrayBuffer { byteLength: 4, x: 42 },\n' +
' y: 1337 }'); ' y: 1337 }');
} }
@ -138,15 +140,16 @@ for (const showHidden of [true, false]) {
const array = new constructor(new ArrayBuffer(byteLength), 0, length); const array = new constructor(new ArrayBuffer(byteLength), 0, length);
array[0] = 65; array[0] = 65;
array[1] = 97; array[1] = 97;
assert.strictEqual(util.inspect(array, true), assert.strictEqual(
`${constructor.name} [\n` + util.inspect(array, true),
` 65,\n` + `${constructor.name} [\n` +
` 97,\n` + ` 65,\n` +
` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` + ` 97,\n` +
` [length]: ${length},\n` + ` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` +
` [byteLength]: ${byteLength},\n` + ` [length]: ${length},\n` +
` [byteOffset]: 0,\n` + ` [byteLength]: ${byteLength},\n` +
` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`); ` [byteOffset]: 0,\n` +
` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`);
assert.strictEqual( assert.strictEqual(
util.inspect(array, false), util.inspect(array, false),
`${constructor.name} [ 65, 97 ]` `${constructor.name} [ 65, 97 ]`
@ -173,15 +176,16 @@ for (const showHidden of [true, false]) {
}); });
array[0] = 65; array[0] = 65;
array[1] = 97; array[1] = 97;
assert.strictEqual(util.inspect(array, true), assert.strictEqual(
`${constructor.name} [\n` + util.inspect(array, true),
` 65,\n` + `${constructor.name} [\n` +
` 97,\n` + ` 65,\n` +
` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` + ` 97,\n` +
` [length]: ${length},\n` + ` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` +
` [byteLength]: ${byteLength},\n` + ` [length]: ${length},\n` +
` [byteOffset]: 0,\n` + ` [byteLength]: ${byteLength},\n` +
` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`); ` [byteOffset]: 0,\n` +
` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`);
assert.strictEqual( assert.strictEqual(
util.inspect(array, false), util.inspect(array, false),
`${constructor.name} [ 65, 97 ]` `${constructor.name} [ 65, 97 ]`
@ -222,13 +226,13 @@ assert.strictEqual(
// Dynamic properties // Dynamic properties
assert.strictEqual(util.inspect({get readonly() {}}), assert.strictEqual(util.inspect({get readonly() {}}),
'{ readonly: [Getter] }'); '{ readonly: [Getter] }');
assert.strictEqual(util.inspect({get readwrite() {}, set readwrite(val) {}}), assert.strictEqual(util.inspect({get readwrite() {}, set readwrite(val) {}}),
'{ readwrite: [Getter/Setter] }'); '{ readwrite: [Getter/Setter] }');
assert.strictEqual(util.inspect({set writeonly(val) {}}), assert.strictEqual(util.inspect({set writeonly(val) {}}),
'{ writeonly: [Setter] }'); '{ writeonly: [Setter] }');
var value = {}; var value = {};
value['a'] = value; value['a'] = value;
@ -666,7 +670,7 @@ if (typeof Symbol !== 'undefined') {
assert.strictEqual(util.inspect(subject), '[ 1, 2, 3 ]'); assert.strictEqual(util.inspect(subject), '[ 1, 2, 3 ]');
assert.strictEqual(util.inspect(subject, options), assert.strictEqual(util.inspect(subject, options),
'[ 1, 2, 3, [length]: 3, [Symbol(symbol)]: 42 ]'); '[ 1, 2, 3, [length]: 3, [Symbol(symbol)]: 42 ]');
} }
// test Set // test Set
@ -683,11 +687,11 @@ assert.strictEqual(
{ {
assert.strictEqual(util.inspect(new Map()), 'Map {}'); assert.strictEqual(util.inspect(new Map()), 'Map {}');
assert.strictEqual(util.inspect(new Map([[1, 'a'], [2, 'b'], [3, 'c']])), assert.strictEqual(util.inspect(new Map([[1, 'a'], [2, 'b'], [3, 'c']])),
'Map { 1 => \'a\', 2 => \'b\', 3 => \'c\' }'); 'Map { 1 => \'a\', 2 => \'b\', 3 => \'c\' }');
const map = new Map([['foo', null]]); const map = new Map([['foo', null]]);
map.bar = 42; map.bar = 42;
assert.strictEqual(util.inspect(map, true), assert.strictEqual(util.inspect(map, true),
'Map { \'foo\' => null, [size]: 1, bar: 42 }'); 'Map { \'foo\' => null, [size]: 1, bar: 42 }');
} }
// test Promise // test Promise
@ -774,15 +778,15 @@ checkAlignment(new Map(big_array.map(function(y) { return [y, null]; })));
const x = new ObjectSubclass(); const x = new ObjectSubclass();
x.foo = 42; x.foo = 42;
assert.strictEqual(util.inspect(x), assert.strictEqual(util.inspect(x),
'ObjectSubclass { foo: 42 }'); 'ObjectSubclass { foo: 42 }');
assert.strictEqual(util.inspect(new ArraySubclass(1, 2, 3)), assert.strictEqual(util.inspect(new ArraySubclass(1, 2, 3)),
'ArraySubclass [ 1, 2, 3 ]'); 'ArraySubclass [ 1, 2, 3 ]');
assert.strictEqual(util.inspect(new SetSubclass([1, 2, 3])), assert.strictEqual(util.inspect(new SetSubclass([1, 2, 3])),
'SetSubclass { 1, 2, 3 }'); 'SetSubclass { 1, 2, 3 }');
assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])), assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])),
'MapSubclass { \'foo\' => 42 }'); 'MapSubclass { \'foo\' => 42 }');
assert.strictEqual(util.inspect(new PromiseSubclass(function() {})), assert.strictEqual(util.inspect(new PromiseSubclass(function() {})),
'PromiseSubclass { <pending> }'); 'PromiseSubclass { <pending> }');
} }
// Corner cases. // Corner cases.

4
test/parallel/test-vm-symbols.js

@ -19,7 +19,7 @@ var context = new Document();
vm.createContext(context); vm.createContext(context);
assert.equal(context.getSymbolValue(), 'foo', assert.equal(context.getSymbolValue(), 'foo',
'should return symbol-keyed value from the outside'); 'should return symbol-keyed value from the outside');
assert.equal(vm.runInContext('this.getSymbolValue()', context), 'foo', assert.equal(vm.runInContext('this.getSymbolValue()', context), 'foo',
'should return symbol-keyed value from the inside'); 'should return symbol-keyed value from the inside');

21
test/parallel/test-zlib-from-concatenated-gzip.js

@ -53,7 +53,7 @@ fs.createReadStream(pmmFileGz)
.on('data', (data) => pmmResultBuffers.push(data)) .on('data', (data) => pmmResultBuffers.push(data))
.on('finish', common.mustCall(() => { .on('finish', common.mustCall(() => {
assert.deepStrictEqual(Buffer.concat(pmmResultBuffers), pmmExpected, assert.deepStrictEqual(Buffer.concat(pmmResultBuffers), pmmExpected,
'result should match original random garbage'); 'result should match original random garbage');
})); }));
// test that the next gzip member can wrap around the input buffer boundary // test that the next gzip member can wrap around the input buffer boundary
@ -61,14 +61,17 @@ fs.createReadStream(pmmFileGz)
const resultBuffers = []; const resultBuffers = [];
const unzip = zlib.createGunzip() const unzip = zlib.createGunzip()
.on('error', (err) => { .on('error', (err) => {
assert.ifError(err); assert.ifError(err);
}) })
.on('data', (data) => resultBuffers.push(data)) .on('data', (data) => resultBuffers.push(data))
.on('finish', common.mustCall(() => { .on('finish', common.mustCall(() => {
assert.strictEqual(Buffer.concat(resultBuffers).toString(), 'abcdef', assert.strictEqual(
`result should match original input (offset = ${offset})`); Buffer.concat(resultBuffers).toString(),
})); 'abcdef',
`result should match original input (offset = ${offset})`
);
}));
// first write: write "abc" + the first bytes of "def" // first write: write "abc" + the first bytes of "def"
unzip.write(Buffer.concat([ unzip.write(Buffer.concat([

2
test/parallel/test-zlib-unzip-one-byte-chunks.js

@ -17,7 +17,7 @@ const unzip = zlib.createUnzip()
.on('data', (data) => resultBuffers.push(data)) .on('data', (data) => resultBuffers.push(data))
.on('finish', common.mustCall(() => { .on('finish', common.mustCall(() => {
assert.deepStrictEqual(Buffer.concat(resultBuffers).toString(), 'abcdef', assert.deepStrictEqual(Buffer.concat(resultBuffers).toString(), 'abcdef',
'result should match original string'); 'result should match original string');
})); }));
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {

Loading…
Cancel
Save