Skip to content

Commit

Permalink
test: refactor test-zlib.js
Browse files Browse the repository at this point in the history
* minor layout changes for clarity
* assert.equal() and assert.ok() swapped out for assert.strictEqual()
* var -> const for modules included via require()

PR-URL: #9544
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
Trott authored and addaleax committed Nov 22, 2016
1 parent 163397a commit f3db5e4
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions test/parallel/test-zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ const common = require('../common');
const assert = require('assert');
const zlib = require('zlib');
const path = require('path');

var zlibPairs =
[[zlib.Deflate, zlib.Inflate],
[zlib.Gzip, zlib.Gunzip],
[zlib.Deflate, zlib.Unzip],
[zlib.Gzip, zlib.Unzip],
[zlib.DeflateRaw, zlib.InflateRaw]];
const fs = require('fs');
const util = require('util');
const stream = require('stream');

var zlibPairs = [
[zlib.Deflate, zlib.Inflate],
[zlib.Gzip, zlib.Gunzip],
[zlib.Deflate, zlib.Unzip],
[zlib.Gzip, zlib.Unzip],
[zlib.DeflateRaw, zlib.InflateRaw]
];

// how fast to trickle through the slowstream
var trickle = [128, 1024, 1024 * 1024];
Expand All @@ -36,23 +40,18 @@ if (!process.env.PUMMEL) {
strategy = [0];
}

var fs = require('fs');

var testFiles = ['person.jpg', 'elipses.txt', 'empty.txt'];

if (process.env.FAST) {
zlibPairs = [[zlib.Gzip, zlib.Unzip]];
testFiles = ['person.jpg'];
}

var tests = {};
const tests = {};
testFiles.forEach(function(file) {
tests[file] = fs.readFileSync(path.resolve(common.fixturesDir, file));
});

var util = require('util');
var stream = require('stream');


// stream that saves everything
function BufferStream() {
Expand Down Expand Up @@ -197,11 +196,16 @@ Object.keys(tests).forEach(function(file) {
ss.pipe(def).pipe(inf).pipe(buf);
ss.end(test);
});
}); }); }); }); }); }); // sad stallman is sad.
});
});
});
});
});
});
});

process.on('exit', function(code) {
console.log('1..' + done);
assert.equal(done, total, (total - done) + ' tests left unfinished');
assert.ok(!failures, 'some test failures');
assert.strictEqual(done, total, (total - done) + ' tests left unfinished');
assert.strictEqual(failures, 0, 'some test failures');
});

0 comments on commit f3db5e4

Please sign in to comment.