From 613315ead31f3451aa4974e214f259a83da33375 Mon Sep 17 00:00:00 2001 From: Calvin Metcalf Date: Wed, 17 Aug 2016 16:30:30 -0400 Subject: [PATCH] fix tests --- build/test-replacements.js | 10 ++++++++++ package.json | 1 + test/fixtures/file-to-read-with-bom.txt | 3 +++ test/fixtures/file-to-read-without-bom.txt | 3 +++ test/parallel/test-stream-writev.js | 4 ++-- test/parallel/test-stream2-writable.js | 4 ++-- 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/file-to-read-with-bom.txt create mode 100644 test/fixtures/file-to-read-without-bom.txt diff --git a/build/test-replacements.js b/build/test-replacements.js index 33246f3a92..d6ec87c430 100644 --- a/build/test-replacements.js +++ b/build/test-replacements.js @@ -60,6 +60,10 @@ module.exports['test-stream2-transform.js'] = [ module.exports['test-stream2-writable.js'] = [ altForEachImplReplacement , altForEachUseReplacement + , [ + /'latin1',/g, + '\'binary\',' + ] ] module.exports['test-stream-big-packet.js'] = [ @@ -274,3 +278,9 @@ module.exports['test-stream2-readable-from-list.js'] = [ 'require(\'../../lib/internal/streams/BufferList\')' ] ] +module.exports['test-stream-writev.js'] = [ + [ + /'latin1'/g, + `'binary'` + ] +] diff --git a/package.json b/package.json index 42930904e9..a5d2a0bdd7 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "devDependencies": { "assert": "~1.4.0", "babel-polyfill": "^6.9.1", + "buffer": "^4.9.0", "nyc": "^6.4.0", "tap": "~0.7.1", "tape": "~4.5.1", diff --git a/test/fixtures/file-to-read-with-bom.txt b/test/fixtures/file-to-read-with-bom.txt new file mode 100644 index 0000000000..d46c8708d9 --- /dev/null +++ b/test/fixtures/file-to-read-with-bom.txt @@ -0,0 +1,3 @@ +abc +def +ghi diff --git a/test/fixtures/file-to-read-without-bom.txt b/test/fixtures/file-to-read-without-bom.txt new file mode 100644 index 0000000000..8edb37e36d --- /dev/null +++ b/test/fixtures/file-to-read-without-bom.txt @@ -0,0 +1,3 @@ +abc +def +ghi diff --git a/test/parallel/test-stream-writev.js b/test/parallel/test-stream-writev.js index 034ccfb14b..2088479189 100644 --- a/test/parallel/test-stream-writev.js +++ b/test/parallel/test-stream-writev.js @@ -46,7 +46,7 @@ function test(decode, uncork, multi, next) { chunk: [119, 111, 114, 108, 100] }, { encoding: 'buffer', chunk: [33] }, { encoding: 'buffer', chunk: [10, 97, 110, 100, 32, 116, 104, 101, 110, 46, 46, 46] }, { encoding: 'buffer', - chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173] }] : [{ encoding: 'ascii', chunk: 'hello, ' }, { encoding: 'utf8', chunk: 'world' }, { encoding: 'buffer', chunk: [33] }, { encoding: 'latin1', chunk: '\nand then...' }, { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }]; + chunk: [250, 206, 190, 167, 222, 173, 190, 239, 222, 202, 251, 173] }] : [{ encoding: 'ascii', chunk: 'hello, ' }, { encoding: 'utf8', chunk: 'world' }, { encoding: 'buffer', chunk: [33] }, { encoding: 'binary', chunk: '\nand then...' }, { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' }]; var actualChunks; w._writev = function (chunks, cb) { @@ -66,7 +66,7 @@ function test(decode, uncork, multi, next) { if (multi) w.cork(); w.write(bufferShim.from('!'), 'buffer', cnt('!')); - w.write('\nand then...', 'latin1', cnt('and then')); + w.write('\nand then...', 'binary', cnt('and then')); if (multi) w.uncork(); diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index 531e97bc64..d695254646 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -133,7 +133,7 @@ test('write bufferize', function (t) { highWaterMark: 100 }); - var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'latin1', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined]; + var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined]; tw.on('finish', function () { t.same(tw.buffer, chunks, 'got the expected chunks'); @@ -159,7 +159,7 @@ test('write no bufferize', function (t) { return TestWriter.prototype._write.call(this, chunk, encoding, cb); }; - var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'latin1', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined]; + var encodings = ['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', undefined]; tw.on('finish', function () { t.same(tw.buffer, chunks, 'got the expected chunks');