aboutsummaryrefslogtreecommitdiff
path: root/node_modules/browserify-zlib/test
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/browserify-zlib/test
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
node_modules
Diffstat (limited to 'node_modules/browserify-zlib/test')
-rw-r--r--node_modules/browserify-zlib/test/fixtures/elipses.txt1
-rw-r--r--node_modules/browserify-zlib/test/fixtures/empty.txt1
-rw-r--r--node_modules/browserify-zlib/test/fixtures/person.jpgbin0 -> 57928 bytes
-rwxr-xr-xnode_modules/browserify-zlib/test/ignored/test-zlib-dictionary-fail.js48
-rwxr-xr-xnode_modules/browserify-zlib/test/ignored/test-zlib-dictionary.js95
-rwxr-xr-xnode_modules/browserify-zlib/test/ignored/test-zlib-params.js33
-rw-r--r--node_modules/browserify-zlib/test/package.json7
-rwxr-xr-xnode_modules/browserify-zlib/test/test-zlib-close-after-write.js35
-rwxr-xr-xnode_modules/browserify-zlib/test/test-zlib-convenience-methods.js70
-rwxr-xr-xnode_modules/browserify-zlib/test/test-zlib-from-string.js89
-rwxr-xr-xnode_modules/browserify-zlib/test/test-zlib-invalid-input.js62
-rwxr-xr-xnode_modules/browserify-zlib/test/test-zlib-random-byte-pipes.js176
-rwxr-xr-xnode_modules/browserify-zlib/test/test-zlib-write-after-flush.js55
-rwxr-xr-xnode_modules/browserify-zlib/test/test-zlib-zero-byte.js41
-rw-r--r--node_modules/browserify-zlib/test/test-zlib.js206
15 files changed, 919 insertions, 0 deletions
diff --git a/node_modules/browserify-zlib/test/fixtures/elipses.txt b/node_modules/browserify-zlib/test/fixtures/elipses.txt
new file mode 100644
index 000000000..610560050
--- /dev/null
+++ b/node_modules/browserify-zlib/test/fixtures/elipses.txt
@@ -0,0 +1 @@
+………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………… \ No newline at end of file
diff --git a/node_modules/browserify-zlib/test/fixtures/empty.txt b/node_modules/browserify-zlib/test/fixtures/empty.txt
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/node_modules/browserify-zlib/test/fixtures/empty.txt
@@ -0,0 +1 @@
+
diff --git a/node_modules/browserify-zlib/test/fixtures/person.jpg b/node_modules/browserify-zlib/test/fixtures/person.jpg
new file mode 100644
index 000000000..4f71881c5
--- /dev/null
+++ b/node_modules/browserify-zlib/test/fixtures/person.jpg
Binary files differ
diff --git a/node_modules/browserify-zlib/test/ignored/test-zlib-dictionary-fail.js b/node_modules/browserify-zlib/test/ignored/test-zlib-dictionary-fail.js
new file mode 100755
index 000000000..fd35a0192
--- /dev/null
+++ b/node_modules/browserify-zlib/test/ignored/test-zlib-dictionary-fail.js
@@ -0,0 +1,48 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var common = require('../common.js');
+var assert = require('assert');
+var zlib = require('zlib');
+
+// Should raise an error, not trigger an assertion in src/node_zlib.cc
+(function() {
+ var stream = zlib.createInflate();
+
+ stream.on('error', common.mustCall(function(err) {
+ assert(/Missing dictionary/.test(err.message));
+ }));
+
+ // String "test" encoded with dictionary "dict".
+ stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5]));
+})();
+
+// Should raise an error, not trigger an assertion in src/node_zlib.cc
+(function() {
+ var stream = zlib.createInflate({ dictionary: Buffer('fail') });
+
+ stream.on('error', common.mustCall(function(err) {
+ assert(/Bad dictionary/.test(err.message));
+ }));
+
+ // String "test" encoded with dictionary "dict".
+ stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5]));
+})();
diff --git a/node_modules/browserify-zlib/test/ignored/test-zlib-dictionary.js b/node_modules/browserify-zlib/test/ignored/test-zlib-dictionary.js
new file mode 100755
index 000000000..58da810cc
--- /dev/null
+++ b/node_modules/browserify-zlib/test/ignored/test-zlib-dictionary.js
@@ -0,0 +1,95 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// test compression/decompression with dictionary
+
+var common = require('../common.js');
+var assert = require('assert');
+var zlib = require('zlib');
+var path = require('path');
+
+var spdyDict = new Buffer([
+ 'optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-',
+ 'languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi',
+ 'f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser',
+ '-agent10010120020120220320420520630030130230330430530630740040140240340440',
+ '5406407408409410411412413414415416417500501502503504505accept-rangesageeta',
+ 'glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic',
+ 'ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran',
+ 'sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati',
+ 'oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo',
+ 'ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe',
+ 'pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic',
+ 'ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1',
+ '.1statusversionurl\0'
+].join(''));
+
+var deflate = zlib.createDeflate({ dictionary: spdyDict });
+
+var input = [
+ 'HTTP/1.1 200 Ok',
+ 'Server: node.js',
+ 'Content-Length: 0',
+ ''
+].join('\r\n');
+
+var called = 0;
+
+//
+// We'll use clean-new inflate stream each time
+// and .reset() old dirty deflate one
+//
+function run(num) {
+ var inflate = zlib.createInflate({ dictionary: spdyDict });
+
+ if (num === 2) {
+ deflate.reset();
+ deflate.removeAllListeners('data');
+ }
+
+ // Put data into deflate stream
+ deflate.on('data', function(chunk) {
+ inflate.write(chunk);
+ });
+
+ // Get data from inflate stream
+ var output = [];
+ inflate.on('data', function(chunk) {
+ output.push(chunk);
+ });
+ inflate.on('end', function() {
+ called++;
+
+ assert.equal(output.join(''), input);
+
+ if (num < 2) run(num + 1);
+ });
+
+ deflate.write(input);
+ deflate.flush(function() {
+ inflate.end();
+ });
+}
+run(1);
+
+process.on('exit', function() {
+ assert.equal(called, 2);
+});
diff --git a/node_modules/browserify-zlib/test/ignored/test-zlib-params.js b/node_modules/browserify-zlib/test/ignored/test-zlib-params.js
new file mode 100755
index 000000000..006f1ea8e
--- /dev/null
+++ b/node_modules/browserify-zlib/test/ignored/test-zlib-params.js
@@ -0,0 +1,33 @@
+var common = require('../common.js');
+var assert = require('assert');
+var zlib = require('zlib');
+var path = require('path');
+var fs = require('fs');
+
+var file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')),
+ chunkSize = 24 * 1024,
+ opts = { level: 9, strategy: zlib.Z_DEFAULT_STRATEGY },
+ deflater = zlib.createDeflate(opts);
+
+var chunk1 = file.slice(0, chunkSize),
+ chunk2 = file.slice(chunkSize),
+ blkhdr = new Buffer([0x00, 0x48, 0x82, 0xb7, 0x7d]),
+ expected = Buffer.concat([blkhdr, chunk2]),
+ actual;
+
+deflater.write(chunk1, function() {
+ deflater.params(0, zlib.Z_DEFAULT_STRATEGY, function() {
+ while (deflater.read());
+ deflater.end(chunk2, function() {
+ var bufs = [], buf;
+ while (buf = deflater.read())
+ bufs.push(buf);
+ actual = Buffer.concat(bufs);
+ });
+ });
+ while (deflater.read());
+});
+
+process.once('exit', function() {
+ assert.deepEqual(actual, expected);
+});
diff --git a/node_modules/browserify-zlib/test/package.json b/node_modules/browserify-zlib/test/package.json
new file mode 100644
index 000000000..189e12024
--- /dev/null
+++ b/node_modules/browserify-zlib/test/package.json
@@ -0,0 +1,7 @@
+{
+ "browserify": {
+ "transform": [
+ "brfs"
+ ]
+ }
+} \ No newline at end of file
diff --git a/node_modules/browserify-zlib/test/test-zlib-close-after-write.js b/node_modules/browserify-zlib/test/test-zlib-close-after-write.js
new file mode 100755
index 000000000..6d5a08360
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib-close-after-write.js
@@ -0,0 +1,35 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var tape = require('tape');
+var zlib = require('../');
+
+tape(function(t) {
+ t.plan(1);
+
+ zlib.gzip('hello', function(err, out) {
+ var unzip = zlib.createGunzip();
+ unzip.write(out);
+ unzip.close(function() {
+ t.ok(true);
+ });
+ });
+});
diff --git a/node_modules/browserify-zlib/test/test-zlib-convenience-methods.js b/node_modules/browserify-zlib/test/test-zlib-convenience-methods.js
new file mode 100755
index 000000000..223160b84
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib-convenience-methods.js
@@ -0,0 +1,70 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// test convenience methods with and without options supplied
+
+var tape = require('tape');
+var zlib = require('../');
+
+var expect = 'blahblahblahblahblahblah';
+var opts = {
+ level: 9,
+ chunkSize: 1024,
+};
+
+[
+ ['gzip', 'gunzip'],
+ ['gzip', 'unzip'],
+ ['deflate', 'inflate'],
+ ['deflateRaw', 'inflateRaw'],
+].forEach(function(method) {
+ tape(method.join(' '), function(t) {
+ t.plan(4);
+
+ zlib[method[0]](expect, opts, function(err, result) {
+ zlib[method[1]](result, opts, function(err, result) {
+ t.deepEqual(result, new Buffer(expect),
+ 'Should get original string after ' +
+ method[0] + '/' + method[1] + ' with options.');
+ });
+ });
+
+ zlib[method[0]](expect, function(err, result) {
+ zlib[method[1]](result, function(err, result) {
+ t.deepEqual(result, new Buffer(expect),
+ 'Should get original string after ' +
+ method[0] + '/' + method[1] + ' without options.');
+ });
+ });
+
+ var result = zlib[method[0] + 'Sync'](expect, opts);
+ result = zlib[method[1] + 'Sync'](result, opts);
+ t.deepEqual(result, new Buffer(expect),
+ 'Should get original string after ' +
+ method[0] + '/' + method[1] + ' with options.');
+
+ result = zlib[method[0] + 'Sync'](expect);
+ result = zlib[method[1] + 'Sync'](result);
+ t.deepEqual(result, new Buffer(expect),
+ 'Should get original string after ' +
+ method[0] + '/' + method[1] + ' without options.');
+ });
+});
diff --git a/node_modules/browserify-zlib/test/test-zlib-from-string.js b/node_modules/browserify-zlib/test/test-zlib-from-string.js
new file mode 100755
index 000000000..0376c557b
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib-from-string.js
@@ -0,0 +1,89 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// test compressing and uncompressing a string with zlib
+
+var tape = require('tape');
+var zlib = require('../');
+
+var inputString = '\u03A9\u03A9Lorem ipsum dolor sit amet, consectetur adipiscing el' +
+ 'it. Morbi faucibus, purus at gravida dictum, libero arcu convallis la' +
+ 'cus, in commodo libero metus eu nisi. Nullam commodo, neque nec porta' +
+ ' placerat, nisi est fermentum augue, vitae gravida tellus sapien sit ' +
+ 'amet tellus. Aenean non diam orci. Proin quis elit turpis. Suspendiss' +
+ 'e non diam ipsum. Suspendisse nec ullamcorper odio. Vestibulum arcu m' +
+ 'i, sodales non suscipit id, ultrices ut massa. Sed ac sem sit amet ar' +
+ 'cu malesuada fermentum. Nunc sed. ';
+var expectedBase64Deflate = 'eJxdUUtOQzEMvMoc4OndgT0gJCT2buJWlpI4jePeqZfpm' +
+ 'XAKLRKbLOzx/HK73q6vOrhCunlF1qIDJhNUeW5I2ozT5OkDlKWLJWkncJG5403HQXAkT3' +
+ 'Jw29B9uIEmToMukglZ0vS6ociBh4JG8sV4oVLEUCitK2kxq1WzPnChHDzsaGKy491Lofo' +
+ 'AbWh8do43oeuYhB5EPCjcLjzYJo48KrfQBvnJecNFJvHT1+RSQsGoC7dn2t/xjhduTA1N' +
+ 'WyQIZR0pbHwMDatnD+crPqKSqGPHp1vnlsWM/07ubf7bheF7kqSj84Bm0R1fYTfaK8vqq' +
+ 'qfKBtNMhe3OZh6N95CTvMX5HJJi4xOVzCgUOIMSLH7wmeOHaFE4RdpnGavKtrB5xzfO/Ll9';
+var expectedBase64Gzip = 'H4sIAAAAAAAAA11RS05DMQy8yhzg6d2BPSAkJPZu4laWkjiN' +
+ '496pl+mZcAotEpss7PH8crverq86uEK6eUXWogMmE1R5bkjajNPk6QOUpYslaSdwkbnjT' +
+ 'cdBcCRPcnDb0H24gSZOgy6SCVnS9LqhyIGHgkbyxXihUsRQKK0raTGrVbM+cKEcPOxoYr' +
+ 'Lj3Uuh+gBtaHx2jjeh65iEHkQ8KNwuPNgmjjwqt9AG+cl5w0Um8dPX5FJCwagLt2fa3/G' +
+ 'OF25MDU1bJAhlHSlsfAwNq2cP5ys+opKoY8enW+eWxYz/Tu5t/tuF4XuSpKPzgGbRHV9h' +
+ 'N9ory+qqp8oG00yF7c5mHo33kJO8xfkckmLjE5XMKBQ4gxIsfvCZ44doUThF2mcZq8q2s' +
+ 'HnHNzRtagj5AQAA';
+
+tape('deflate', function(t) {
+ t.plan(1);
+ zlib.deflate(inputString, function(err, buffer) {
+ t.equal(buffer.toString('base64'), expectedBase64Deflate,
+ 'deflate encoded string should match');
+ });
+});
+
+tape('gzip', function(t) {
+ t.plan(1);
+ zlib.gzip(inputString, function(err, buffer) {
+ // Can't actually guarantee that we'll get exactly the same
+ // deflated bytes when we compress a string, since the header
+ // depends on stuff other than the input string itself.
+ // However, decrypting it should definitely yield the same
+ // result that we're expecting, and this should match what we get
+ // from inflating the known valid deflate data.
+ zlib.gunzip(buffer, function(err, gunzipped) {
+ t.equal(gunzipped.toString(), inputString,
+ 'Should get original string after gzip/gunzip');
+ });
+ });
+});
+
+tape('unzip deflate', function(t) {
+ t.plan(1);
+ var buffer = new Buffer(expectedBase64Deflate, 'base64');
+ zlib.unzip(buffer, function(err, buffer) {
+ t.equal(buffer.toString(), inputString,
+ 'decoded inflated string should match');
+ });
+});
+
+tape('unzip gzip', function(t) {
+ t.plan(1);
+ buffer = new Buffer(expectedBase64Gzip, 'base64');
+ zlib.unzip(buffer, function(err, buffer) {
+ t.equal(buffer.toString(), inputString,
+ 'decoded gunzipped string should match');
+ });
+});
diff --git a/node_modules/browserify-zlib/test/test-zlib-invalid-input.js b/node_modules/browserify-zlib/test/test-zlib-invalid-input.js
new file mode 100755
index 000000000..5ac08c3e9
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib-invalid-input.js
@@ -0,0 +1,62 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// test uncompressing invalid input
+
+var tape = require('tape'),
+ zlib = require('../');
+
+tape('non-strings', function(t) {
+ var nonStringInputs = [1, true, {a: 1}, ['a']];
+ t.plan(12);
+
+ nonStringInputs.forEach(function(input) {
+ // zlib.gunzip should not throw an error when called with bad input.
+ t.doesNotThrow(function() {
+ zlib.gunzip(input, function(err, buffer) {
+ // zlib.gunzip should pass the error to the callback.
+ t.ok(err);
+ });
+ });
+ });
+});
+
+tape('unzips', function(t) {
+ // zlib.Unzip classes need to get valid data, or else they'll throw.
+ var unzips = [ zlib.Unzip(),
+ zlib.Gunzip(),
+ zlib.Inflate(),
+ zlib.InflateRaw() ];
+
+ t.plan(4);
+ unzips.forEach(function (uz, i) {
+ uz.on('error', function(er) {
+ t.ok(er);
+ });
+
+ uz.on('end', function(er) {
+ throw new Error('end event should not be emitted '+uz.constructor.name);
+ });
+
+ // this will trigger error event
+ uz.write('this is not valid compressed data.');
+ });
+});
diff --git a/node_modules/browserify-zlib/test/test-zlib-random-byte-pipes.js b/node_modules/browserify-zlib/test/test-zlib-random-byte-pipes.js
new file mode 100755
index 000000000..6dba4c2b6
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib-random-byte-pipes.js
@@ -0,0 +1,176 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var crypto = require('crypto');
+var stream = require('stream');
+var Stream = stream.Stream;
+var util = require('util');
+var tape = require('tape');
+var zlib = require('../');
+
+
+
+// emit random bytes, and keep a shasum
+function RandomReadStream(opt) {
+ Stream.call(this);
+
+ this.readable = true;
+ this._paused = false;
+ this._processing = false;
+
+ this._hasher = crypto.createHash('sha1');
+ opt = opt || {};
+
+ // base block size.
+ opt.block = opt.block || 256 * 1024;
+
+ // total number of bytes to emit
+ opt.total = opt.total || 256 * 1024 * 1024;
+ this._remaining = opt.total;
+
+ // how variable to make the block sizes
+ opt.jitter = opt.jitter || 1024;
+
+ this._opt = opt;
+
+ this._process = this._process.bind(this);
+
+ process.nextTick(this._process);
+}
+
+util.inherits(RandomReadStream, Stream);
+
+RandomReadStream.prototype.pause = function() {
+ this._paused = true;
+ this.emit('pause');
+};
+
+RandomReadStream.prototype.resume = function() {
+ this._paused = false;
+ this.emit('resume');
+ this._process();
+};
+
+RandomReadStream.prototype._process = function() {
+ if (this._processing) return;
+ if (this._paused) return;
+
+ this._processing = true;
+
+ if (!this._remaining) {
+ this._hash = this._hasher.digest('hex').toLowerCase().trim();
+ this._processing = false;
+
+ this.emit('end');
+ return;
+ }
+
+ // figure out how many bytes to output
+ // if finished, then just emit end.
+ var block = this._opt.block;
+ var jitter = this._opt.jitter;
+ if (jitter) {
+ block += Math.ceil(Math.random() * jitter - (jitter / 2));
+ }
+ block = Math.min(block, this._remaining);
+ var buf = new Buffer(block);
+ for (var i = 0; i < block; i++) {
+ buf[i] = Math.random() * 256;
+ }
+
+ this._hasher.update(buf);
+
+ this._remaining -= block;
+
+ this._processing = false;
+
+ this.emit('data', buf);
+ process.nextTick(this._process);
+};
+
+
+// a filter that just verifies a shasum
+function HashStream() {
+ Stream.call(this);
+
+ this.readable = this.writable = true;
+ this._hasher = crypto.createHash('sha1');
+}
+
+util.inherits(HashStream, Stream);
+
+HashStream.prototype.write = function(c) {
+ // Simulate the way that an fs.ReadStream returns false
+ // on *every* write like a jerk, only to resume a
+ // moment later.
+ this._hasher.update(c);
+ process.nextTick(this.resume.bind(this));
+ return false;
+};
+
+HashStream.prototype.resume = function() {
+ this.emit('resume');
+ process.nextTick(this.emit.bind(this, 'drain'));
+};
+
+HashStream.prototype.end = function(c) {
+ if (c) {
+ this.write(c);
+ }
+ this._hash = this._hasher.digest('hex').toLowerCase().trim();
+ this.emit('data', this._hash);
+ this.emit('end');
+};
+
+tape('random byte pipes', function(t) {
+ var inp = new RandomReadStream({ total: 1024, block: 256, jitter: 16 });
+ var out = new HashStream();
+ var gzip = zlib.createGzip();
+ var gunz = zlib.createGunzip();
+
+ inp.pipe(gzip).pipe(gunz).pipe(out);
+
+ inp.on('data', function(c) {
+ t.ok(c.length);
+ });
+
+ gzip.on('data', function(c) {
+ t.ok(c.length);
+ });
+
+ gunz.on('data', function(c) {
+ t.ok(c.length);
+ });
+
+ out.on('data', function(c) {
+ t.ok(c.length);
+ });
+
+ out.on('data', function(c) {
+ t.ok(c.length);
+ t.equal(c, inp._hash, 'hashes should match');
+ });
+
+ out.on('end', function() {
+ t.end();
+ })
+});
+
diff --git a/node_modules/browserify-zlib/test/test-zlib-write-after-flush.js b/node_modules/browserify-zlib/test/test-zlib-write-after-flush.js
new file mode 100755
index 000000000..5841ef813
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib-write-after-flush.js
@@ -0,0 +1,55 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var tape = require('tape');
+var zlib = require('../');
+var fs = require('fs');
+
+tape('write after flush', function(t) {
+ t.plan(2);
+
+ var gzip = zlib.createGzip();
+ var gunz = zlib.createUnzip();
+
+ gzip.pipe(gunz);
+
+ var output = '';
+ var input = 'A line of data\n';
+ gunz.setEncoding('utf8');
+ gunz.on('data', function(c) {
+ output += c;
+ });
+
+ gunz.on('end', function() {
+ t.equal(output, input);
+
+ // Make sure that the flush flag was set back to normal
+ t.equal(gzip._flushFlag, zlib.Z_NO_FLUSH);
+ });
+
+ // make sure that flush/write doesn't trigger an assert failure
+ gzip.flush(); write();
+ function write() {
+ gzip.write(input);
+ gzip.end();
+ gunz.read(0);
+ }
+});
diff --git a/node_modules/browserify-zlib/test/test-zlib-zero-byte.js b/node_modules/browserify-zlib/test/test-zlib-zero-byte.js
new file mode 100755
index 000000000..88bdd8cb0
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib-zero-byte.js
@@ -0,0 +1,41 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var tape = require('tape');
+var zlib = require('../');
+
+tape('zero byte', function(t) {
+ t.plan(2);
+ var gz = zlib.Gzip()
+ var emptyBuffer = new Buffer(0);
+ var received = 0;
+ gz.on('data', function(c) {
+ received += c.length;
+ });
+ gz.on('end', function() {
+ t.equal(received, 20);
+ });
+ gz.on('finish', function() {
+ t.ok(true);
+ });
+ gz.write(emptyBuffer);
+ gz.end();
+});
diff --git a/node_modules/browserify-zlib/test/test-zlib.js b/node_modules/browserify-zlib/test/test-zlib.js
new file mode 100644
index 000000000..64c02c5dc
--- /dev/null
+++ b/node_modules/browserify-zlib/test/test-zlib.js
@@ -0,0 +1,206 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var assert = require('assert');
+var zlib = require('../');
+var 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]];
+
+// how fast to trickle through the slowstream
+var trickle = [128, 1024, 1024 * 1024];
+
+// tunable options for zlib classes.
+
+// several different chunk sizes
+var chunkSize = [128, 1024, 1024 * 16, 1024 * 1024];
+
+// this is every possible value.
+var level = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+var windowBits = [8, 9, 10, 11, 12, 13, 14, 15];
+var memLevel = [1, 2, 3, 4, 5, 6, 7, 8, 9];
+var strategy = [0, 1, 2, 3, 4];
+
+// it's nice in theory to test every combination, but it
+// takes WAY too long. Maybe a pummel test could do this?
+if (!process.env.PUMMEL) {
+ trickle = [1024];
+ chunkSize = [1024 * 16];
+ level = [6];
+ memLevel = [8];
+ windowBits = [15];
+ strategy = [0];
+}
+
+var fs = require('fs');
+
+if (process.env.FAST) {
+ zlibPairs = [[zlib.Gzip, zlib.Unzip]];
+}
+
+var tests = {
+ 'person.jpg': fs.readFileSync(__dirname + '/fixtures/person.jpg'),
+ 'elipses.txt': fs.readFileSync(__dirname + '/fixtures/elipses.txt'),
+ 'empty.txt': fs.readFileSync(__dirname + '/fixtures/empty.txt')
+};
+
+var util = require('util');
+var stream = require('stream');
+
+
+// stream that saves everything
+function BufferStream() {
+ this.chunks = [];
+ this.length = 0;
+ this.writable = true;
+ this.readable = true;
+}
+
+util.inherits(BufferStream, stream.Stream);
+
+BufferStream.prototype.write = function(c) {
+ this.chunks.push(c);
+ this.length += c.length;
+ return true;
+};
+
+BufferStream.prototype.end = function(c) {
+ if (c) this.write(c);
+ // flatten
+ var buf = new Buffer(this.length);
+ var i = 0;
+ this.chunks.forEach(function(c) {
+ c.copy(buf, i);
+ i += c.length;
+ });
+ this.emit('data', buf);
+ this.emit('end');
+ return true;
+};
+
+
+function SlowStream(trickle) {
+ this.trickle = trickle;
+ this.offset = 0;
+ this.readable = this.writable = true;
+}
+
+util.inherits(SlowStream, stream.Stream);
+
+SlowStream.prototype.write = function() {
+ throw new Error('not implemented, just call ss.end(chunk)');
+};
+
+SlowStream.prototype.pause = function() {
+ this.paused = true;
+ this.emit('pause');
+};
+
+SlowStream.prototype.resume = function() {
+ var self = this;
+ if (self.ended) return;
+ self.emit('resume');
+ if (!self.chunk) return;
+ self.paused = false;
+ emit();
+ function emit() {
+ if (self.paused) return;
+ if (self.offset >= self.length) {
+ self.ended = true;
+ return self.emit('end');
+ }
+ var end = Math.min(self.offset + self.trickle, self.length);
+ var c = self.chunk.slice(self.offset, end);
+ self.offset += c.length;
+ self.emit('data', c);
+ process.nextTick(emit);
+ }
+};
+
+SlowStream.prototype.end = function(chunk) {
+ // walk over the chunk in blocks.
+ var self = this;
+ self.chunk = chunk;
+ self.length = chunk.length;
+ self.resume();
+ return self.ended;
+};
+
+
+
+// for each of the files, make sure that compressing and
+// decompressing results in the same data, for every combination
+// of the options set above.
+var tape = require('tape');
+
+Object.keys(tests).forEach(function(file) {
+ var test = tests[file];
+ chunkSize.forEach(function(chunkSize) {
+ trickle.forEach(function(trickle) {
+ windowBits.forEach(function(windowBits) {
+ level.forEach(function(level) {
+ memLevel.forEach(function(memLevel) {
+ strategy.forEach(function(strategy) {
+ zlibPairs.forEach(function(pair) {
+ var Def = pair[0];
+ var Inf = pair[1];
+ var opts = {
+ level: level,
+ windowBits: windowBits,
+ memLevel: memLevel,
+ strategy: strategy
+ };
+
+ var msg = file + ' ' +
+ chunkSize + ' ' +
+ JSON.stringify(opts) + ' ' +
+ Def.name + ' -> ' + Inf.name;
+
+ tape('zlib ' + msg, function(t) {
+ t.plan(1);
+
+ var def = new Def(opts);
+ var inf = new Inf(opts);
+ var ss = new SlowStream(trickle);
+ var buf = new BufferStream();
+
+ // verify that the same exact buffer comes out the other end.
+ buf.on('data', function(c) {
+ t.deepEqual(c, test);
+ });
+
+ // the magic happens here.
+ ss.pipe(def).pipe(inf).pipe(buf);
+ ss.end(test);
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+});