Browse Source

test: var variables to const in zlib

Changes in test-zlib-from-string is because var->const
pushed us over the max char limit per line.

PR-URL: https://github.com/nodejs/node/pull/8627
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v7.x
Ishan Aditya 8 years ago
committed by Michael Dawson
parent
commit
7a46554dcf
  1. 4
      test/parallel/test-zlib-close-after-write.js
  2. 4
      test/parallel/test-zlib-const.js
  3. 8
      test/parallel/test-zlib-convenience-methods.js
  4. 6
      test/parallel/test-zlib-dictionary-fail.js
  5. 10
      test/parallel/test-zlib-flush.js
  6. 26
      test/parallel/test-zlib-from-gzip.js
  7. 57
      test/parallel/test-zlib-from-string.js
  8. 4
      test/parallel/test-zlib-invalid-input.js
  9. 13
      test/parallel/test-zlib-params.js
  10. 18
      test/parallel/test-zlib-random-byte-pipes.js
  11. 6
      test/parallel/test-zlib-write-after-close.js
  12. 10
      test/parallel/test-zlib-write-after-flush.js
  13. 8
      test/parallel/test-zlib-zero-byte.js
  14. 8
      test/parallel/test-zlib.js

4
test/parallel/test-zlib-close-after-write.js

@ -1,9 +1,9 @@
'use strict'; 'use strict';
const common = require('../common'); const common = require('../common');
var zlib = require('zlib'); const zlib = require('zlib');
zlib.gzip('hello', common.mustCall(function(err, out) { zlib.gzip('hello', common.mustCall(function(err, out) {
var unzip = zlib.createGunzip(); const unzip = zlib.createGunzip();
unzip.write(out); unzip.write(out);
unzip.close(common.mustCall(function() {})); unzip.close(common.mustCall(function() {}));
})); }));

4
test/parallel/test-zlib-const.js

@ -1,8 +1,8 @@
/* eslint-disable strict */ /* eslint-disable strict */
require('../common'); require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
assert.equal(zlib.constants.Z_OK, 0, 'Z_OK should be 0'); assert.equal(zlib.constants.Z_OK, 0, 'Z_OK should be 0');
zlib.constants.Z_OK = 1; zlib.constants.Z_OK = 1;

8
test/parallel/test-zlib-convenience-methods.js

@ -2,13 +2,13 @@
// test convenience methods with and without options supplied // test convenience methods with and without options supplied
require('../common'); require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var hadRun = 0; var hadRun = 0;
var expect = 'blahblahblahblahblahblah'; const expect = 'blahblahblahblahblahblah';
var opts = { const opts = {
level: 9, level: 9,
chunkSize: 1024, chunkSize: 1024,
}; };

6
test/parallel/test-zlib-dictionary-fail.js

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
// Should raise an error, not trigger an assertion in src/node_zlib.cc // Should raise an error, not trigger an assertion in src/node_zlib.cc
{ {

10
test/parallel/test-zlib-flush.js

@ -1,9 +1,9 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var path = require('path'); const path = require('path');
var fs = require('fs'); const fs = require('fs');
const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')); const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg'));
const chunkSize = 16; const chunkSize = 16;

26
test/parallel/test-zlib-from-gzip.js

@ -2,27 +2,27 @@
// test unzipping a file that was created with a non-node gzip lib, // test unzipping a file that was created with a non-node gzip lib,
// piped in as fast as possible. // piped in as fast as possible.
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var path = require('path'); const path = require('path');
common.refreshTmpDir(); common.refreshTmpDir();
var gunzip = zlib.createGunzip(); const gunzip = zlib.createGunzip();
var fs = require('fs'); const fs = require('fs');
var fixture = path.resolve(common.fixturesDir, 'person.jpg.gz'); const fixture = path.resolve(common.fixturesDir, 'person.jpg.gz');
var unzippedFixture = path.resolve(common.fixturesDir, 'person.jpg'); const unzippedFixture = path.resolve(common.fixturesDir, 'person.jpg');
var outputFile = path.resolve(common.tmpDir, 'person.jpg'); const outputFile = path.resolve(common.tmpDir, 'person.jpg');
var expect = fs.readFileSync(unzippedFixture); const expect = fs.readFileSync(unzippedFixture);
var inp = fs.createReadStream(fixture); const inp = fs.createReadStream(fixture);
var out = fs.createWriteStream(outputFile); const out = fs.createWriteStream(outputFile);
inp.pipe(gunzip).pipe(out); inp.pipe(gunzip).pipe(out);
out.on('close', function() { out.on('close', function() {
var actual = fs.readFileSync(outputFile); const actual = fs.readFileSync(outputFile);
assert.equal(actual.length, expect.length, 'length should match'); assert.equal(actual.length, expect.length, 'length should match');
for (var i = 0, l = actual.length; i < l; i++) { for (var i = 0, l = actual.length; i < l; i++) {
assert.equal(actual[i], expect[i], 'byte[' + i + ']'); assert.equal(actual[i], expect[i], 'byte[' + i + ']');

57
test/parallel/test-zlib-from-string.js

@ -2,35 +2,36 @@
// test compressing and uncompressing a string with zlib // test compressing and uncompressing a string with zlib
require('../common'); require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing elit.' + const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' +
' Morbi faucibus, purus at gravida dictum, libero arcu conv' + 't. Morbi faucibus, purus at gravida dictum, libero arcu ' +
'allis lacus, in commodo libero metus eu nisi. Nullam commo' + 'convallis lacus, in commodo libero metus eu nisi. Nullam' +
'do, neque nec porta placerat, nisi est fermentum augue, vi' + ' commodo, neque nec porta placerat, nisi est fermentum a' +
'tae gravida tellus sapien sit amet tellus. Aenean non diam' + 'ugue, vitae gravida tellus sapien sit amet tellus. Aenea' +
' orci. Proin quis elit turpis. Suspendisse non diam ipsum.' + 'n non diam orci. Proin quis elit turpis. Suspendisse non' +
' Suspendisse nec ullamcorper odio. Vestibulum arcu mi, sod' + ' diam ipsum. Suspendisse nec ullamcorper odio. Vestibulu' +
'ales non suscipit id, ultrices ut massa. Sed ac sem sit am' + 'm arcu mi, sodales non suscipit id, ultrices ut massa. S' +
'et arcu malesuada fermentum. Nunc sed. '; 'ed ac sem sit amet arcu malesuada fermentum. Nunc sed. ';
var expectedBase64Deflate = 'eJxdUUtOQzEMvMoc4OndgT0gJCT2buJWlpI4jePeqZfpmXAK' + const expectedBase64Deflate = 'eJxdUUtOQzEMvMoc4OndgT0gJCT2buJWlpI4jePeqZfpmX' +
'LRKbLOzx/HK73q6vOrhCunlF1qIDJhNUeW5I2ozT5OkDlKWL' + 'AKLRKbLOzx/HK73q6vOrhCunlF1qIDJhNUeW5I2ozT5OkD' +
'JWkncJG5403HQXAkT3Jw29B9uIEmToMukglZ0vS6ociBh4JG' + 'lKWLJWkncJG5403HQXAkT3Jw29B9uIEmToMukglZ0vS6oc' +
'8sV4oVLEUCitK2kxq1WzPnChHDzsaGKy491LofoAbWh8do43' + 'iBh4JG8sV4oVLEUCitK2kxq1WzPnChHDzsaGKy491LofoA' +
'oeuYhB5EPCjcLjzYJo48KrfQBvnJecNFJvHT1+RSQsGoC7dn' + 'bWh8do43oeuYhB5EPCjcLjzYJo48KrfQBvnJecNFJvHT1+' +
'2t/xjhduTA1NWyQIZR0pbHwMDatnD+crPqKSqGPHp1vnlsWM' + 'RSQsGoC7dn2t/xjhduTA1NWyQIZR0pbHwMDatnD+crPqKS' +
'/07ubf7bheF7kqSj84Bm0R1fYTfaK8vqqqfKBtNMhe3OZh6N' + 'qGPHp1vnlsWM/07ubf7bheF7kqSj84Bm0R1fYTfaK8vqqq' +
'95CTvMX5HJJi4xOVzCgUOIMSLH7wmeOHaFE4RdpnGavKtrB5' + 'fKBtNMhe3OZh6N95CTvMX5HJJi4xOVzCgUOIMSLH7wmeOH' +
'xzfO/Ll9'; 'aFE4RdpnGavKtrB5xzfO/Ll9';
var expectedBase64Gzip = 'H4sIAAAAAAAAA11RS05DMQy8yhzg6d2BPSAkJPZu4laWkjiN496' + const expectedBase64Gzip = 'H4sIAAAAAAAAA11RS05DMQy8yhzg6d2BPSAkJPZu4laWkjiN4' +
'pl+mZcAotEpss7PH8crverq86uEK6eUXWogMmE1R5bkjajNPk6Q' + '96pl+mZcAotEpss7PH8crverq86uEK6eUXWogMmE1R5bkjajN' +
'OUpYslaSdwkbnjTcdBcCRPcnDb0H24gSZOgy6SCVnS9LqhyIGHg' + 'Pk6QOUpYslaSdwkbnjTcdBcCRPcnDb0H24gSZOgy6SCVnS9Lq' +
'kbyxXihUsRQKK0raTGrVbM+cKEcPOxoYrLj3Uuh+gBtaHx2jjeh' + 'hyIGHgkbyxXihUsRQKK0raTGrVbM+cKEcPOxoYrLj3Uuh+gBt' +
'65iEHkQ8KNwuPNgmjjwqt9AG+cl5w0Um8dPX5FJCwagLt2fa3/G' + 'aHx2jjeh65iEHkQ8KNwuPNgmjjwqt9AG+cl5w0Um8dPX5FJCw' +
'OF25MDU1bJAhlHSlsfAwNq2cP5ys+opKoY8enW+eWxYz/Tu5t/t' + 'agLt2fa3/GOF25MDU1bJAhlHSlsfAwNq2cP5ys+opKoY8enW+' +
'uF4XuSpKPzgGbRHV9hN9ory+qqp8oG00yF7c5mHo33kJO8xfkck' + 'eWxYz/Tu5t/tuF4XuSpKPzgGbRHV9hN9ory+qqp8oG00yF7c5' +
'mLjE5XMKBQ4gxIsfvCZ44doUThF2mcZq8q2sHnHNzRtagj5AQAA'; 'mHo33kJO8xfkckmLjE5XMKBQ4gxIsfvCZ44doUThF2mcZq8q2' +
'sHnHNzRtagj5AQAA';
zlib.deflate(inputString, function(err, buffer) { zlib.deflate(inputString, function(err, buffer) {
assert.equal(buffer.toString('base64'), expectedBase64Deflate, assert.equal(buffer.toString('base64'), expectedBase64Deflate,

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

@ -5,7 +5,7 @@ require('../common');
const assert = require('assert'); const assert = require('assert');
const zlib = require('zlib'); const zlib = require('zlib');
var nonStringInputs = [1, true, {a: 1}, ['a']]; const nonStringInputs = [1, true, {a: 1}, ['a']];
console.error('Doing the non-strings'); console.error('Doing the non-strings');
nonStringInputs.forEach(function(input) { nonStringInputs.forEach(function(input) {
@ -20,7 +20,7 @@ nonStringInputs.forEach(function(input) {
console.error('Doing the unzips'); console.error('Doing the unzips');
// zlib.Unzip classes need to get valid data, or else they'll throw. // zlib.Unzip classes need to get valid data, or else they'll throw.
var unzips = [ zlib.Unzip(), const unzips = [ zlib.Unzip(),
zlib.Gunzip(), zlib.Gunzip(),
zlib.Inflate(), zlib.Inflate(),
zlib.InflateRaw() ]; zlib.InflateRaw() ];

13
test/parallel/test-zlib-params.js

@ -1,9 +1,9 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var path = require('path'); const path = require('path');
var fs = require('fs'); const fs = require('fs');
const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')); const file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg'));
const chunkSize = 12 * 1024; const chunkSize = 12 * 1024;
@ -20,7 +20,8 @@ deflater.write(chunk1, function() {
deflater.params(0, zlib.constants.Z_DEFAULT_STRATEGY, function() { deflater.params(0, zlib.constants.Z_DEFAULT_STRATEGY, function() {
while (deflater.read()); while (deflater.read());
deflater.end(chunk2, function() { deflater.end(chunk2, function() {
var bufs = [], buf; const bufs = [];
var buf;
while (buf = deflater.read()) while (buf = deflater.read())
bufs.push(buf); bufs.push(buf);
actual = Buffer.concat(bufs); actual = Buffer.concat(bufs);

18
test/parallel/test-zlib-random-byte-pipes.js

@ -1,17 +1,17 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
if (!common.hasCrypto) { if (!common.hasCrypto) {
common.skip('missing crypto'); common.skip('missing crypto');
return; return;
} }
var crypto = require('crypto'); const crypto = require('crypto');
var stream = require('stream'); const stream = require('stream');
var Stream = stream.Stream; const Stream = stream.Stream;
var util = require('util'); const util = require('util');
var zlib = require('zlib'); const zlib = require('zlib');
// emit random bytes, and keep a shasum // emit random bytes, and keep a shasum
@ -73,12 +73,12 @@ RandomReadStream.prototype._process = function() {
// figure out how many bytes to output // figure out how many bytes to output
// if finished, then just emit end. // if finished, then just emit end.
var block = this._opt.block; var block = this._opt.block;
var jitter = this._opt.jitter; const jitter = this._opt.jitter;
if (jitter) { if (jitter) {
block += Math.ceil(Math.random() * jitter - (jitter / 2)); block += Math.ceil(Math.random() * jitter - (jitter / 2));
} }
block = Math.min(block, this._remaining); block = Math.min(block, this._remaining);
var buf = Buffer.allocUnsafe(block); const buf = Buffer.allocUnsafe(block);
for (var i = 0; i < block; i++) { for (var i = 0; i < block; i++) {
buf[i] = Math.random() * 256; buf[i] = Math.random() * 256;
} }

6
test/parallel/test-zlib-write-after-close.js

@ -1,10 +1,10 @@
'use strict'; 'use strict';
const common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
zlib.gzip('hello', common.mustCall(function(err, out) { zlib.gzip('hello', common.mustCall(function(err, out) {
var unzip = zlib.createGunzip(); const unzip = zlib.createGunzip();
unzip.close(common.mustCall(function() {})); unzip.close(common.mustCall(function() {}));
assert.throws(function() { assert.throws(function() {
unzip.write(out); unzip.write(out);

10
test/parallel/test-zlib-write-after-flush.js

@ -1,15 +1,15 @@
'use strict'; 'use strict';
require('../common'); require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var gzip = zlib.createGzip(); const gzip = zlib.createGzip();
var gunz = zlib.createUnzip(); const gunz = zlib.createUnzip();
gzip.pipe(gunz); gzip.pipe(gunz);
var output = ''; var output = '';
var input = 'A line of data\n'; const input = 'A line of data\n';
gunz.setEncoding('utf8'); gunz.setEncoding('utf8');
gunz.on('data', function(c) { gunz.on('data', function(c) {
output += c; output += c;

8
test/parallel/test-zlib-zero-byte.js

@ -1,10 +1,10 @@
'use strict'; 'use strict';
const common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var gz = zlib.Gzip(); const gz = zlib.Gzip();
var emptyBuffer = Buffer.alloc(0); const emptyBuffer = Buffer.alloc(0);
var received = 0; var received = 0;
gz.on('data', function(c) { gz.on('data', function(c) {
received += c.length; received += c.length;

8
test/parallel/test-zlib.js

@ -1,8 +1,8 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var zlib = require('zlib'); const zlib = require('zlib');
var path = require('path'); const path = require('path');
var zlibPairs = var zlibPairs =
[[zlib.Deflate, zlib.Inflate], [[zlib.Deflate, zlib.Inflate],

Loading…
Cancel
Save