added coverage generation & improved tests

master
Vitaly Puzrin 2014-02-21 19:06:31 +04:00
rodzic a131622863
commit 5cabad0d48
9 zmienionych plików z 27 dodań i 8 usunięć

2
.gitignore vendored
Wyświetl plik

@ -1,2 +1,4 @@
/doc
/node_modules/
/coverage

Wyświetl plik

@ -1,3 +1,4 @@
.git/
node_modules/
benchmark/implementations
coverage/

Wyświetl plik

@ -1,5 +1,6 @@
/banchmark/
/benchmark/
/test/
/coverage/
/.*
/Makefile

Wyświetl plik

@ -35,6 +35,9 @@ test: lint
fi
mocha
cover:
rm -rf cover
istanbul cover node_modules/.bin/_mocha -- -t 30000 -R spec
doc:
@if test ! `which ndoc` ; then \

Wyświetl plik

@ -93,7 +93,7 @@ function sliceBuf(buf, size) {
var Deflate = function(options) {
this.options = utils.assign({
level: 6,
level: c.Z_DEFAULT_COMPRESSION,
method: c.Z_DEFLATED,
chunkSize: 16384,
windowBits: 15,

Wyświetl plik

@ -1206,14 +1206,16 @@ function DeflateState() {
}
function deflateResetKeep(strm) {
strm.total_in = strm.total_out = 0;
strm.data_type = c.Z_UNKNOWN;
var s;
if (!strm || !strm.state) {
return c.Z_STREAM_ERROR;
}
var s = strm.state;
strm.total_in = strm.total_out = 0;
strm.data_type = c.Z_UNKNOWN;
s = strm.state;
s.pending = 0;
s.pending_out = 0;

Wyświetl plik

@ -19,7 +19,7 @@ function ZStream() {
/* not visible by applications */
this.state = null;
/* best guess about the data type: binary or text */
this.data_type = 2;
this.data_type = 2/*Z_UNKNOWN*/;
/* adler32 value of the uncompressed data */
this.adler = 0;
}

Wyświetl plik

@ -64,7 +64,9 @@ describe('Deflate levels', function () {
it('level 0', function(done) {
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
});
it('level -1 (implicit default)', function(done) {
testDeflate(zlib.createDeflate, pako.deflate, samples, { level: 0 }, done);
});
});
@ -94,6 +96,9 @@ describe('Deflate windowBits', function () {
it('windowBits 8', function(done) {
testDeflate(zlib.createDeflate, pako.deflate, samples, { windowBits: 8 }, done);
});
it('windowBits -15 (implicit raw)', function(done) {
testDeflate(zlib.createDeflateRaw, pako.deflate, samples, { windowBits: -15 }, done);
});
});

Wyświetl plik

@ -54,7 +54,12 @@ function cmpBuf(a, b) {
//
function testDeflateSingle(zlib_factory, pako_deflate, data, options, callback) {
var zlibStream = zlib_factory(options);
var zlib_options = _.clone(options);
// hack for testing negative windowBits
if (zlib_options.windowBits < 0) { zlib_options.windowBits = -zlib_options.windowBits; }
var zlibStream = zlib_factory(zlib_options);
var buffers = [], nread = 0;