mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

Make changes so that tests will pass when the comma-dangle settings applied to the rest of the code base are also applied to tests. PR-URL: https://github.com/nodejs/node/pull/37930 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const zlib = require('zlib');
|
|
const assert = require('assert');
|
|
|
|
const input = '0123456789'.repeat(4);
|
|
|
|
for (const [ compress, decompressor ] of [
|
|
[ zlib.deflateRawSync, zlib.createInflateRaw ],
|
|
[ zlib.deflateSync, zlib.createInflate ],
|
|
[ zlib.brotliCompressSync, zlib.createBrotliDecompress ],
|
|
]) {
|
|
const compressed = compress(input);
|
|
const trailingData = Buffer.from('not valid compressed data');
|
|
|
|
for (const variant of [
|
|
(stream) => { stream.end(compressed); },
|
|
(stream) => { stream.write(compressed); stream.write(trailingData); },
|
|
(stream) => { stream.write(compressed); stream.end(trailingData); },
|
|
(stream) => { stream.write(Buffer.concat([compressed, trailingData])); },
|
|
(stream) => { stream.end(Buffer.concat([compressed, trailingData])); },
|
|
]) {
|
|
let output = '';
|
|
const stream = decompressor();
|
|
stream.setEncoding('utf8');
|
|
stream.on('data', (chunk) => output += chunk);
|
|
stream.on('end', common.mustCall(() => {
|
|
assert.strictEqual(output, input);
|
|
assert.strictEqual(stream.bytesWritten, compressed.length);
|
|
}));
|
|
variant(stream);
|
|
}
|
|
}
|