diff options
Diffstat (limited to 'tools/eslint/node_modules/concat-stream/test')
8 files changed, 237 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/concat-stream/test/array.js b/tools/eslint/node_modules/concat-stream/test/array.js new file mode 100644 index 0000000000..86e7dd43bf --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/array.js @@ -0,0 +1,12 @@ +var concat = require('../') +var test = require('tape') + +test('array stream', function (t) { + t.plan(1) + var arrays = concat({ encoding: 'array' }, function(out) { + t.deepEqual(out, [1,2,3,4,5,6]) + }) + arrays.write([1,2,3]) + arrays.write([4,5,6]) + arrays.end() +}) diff --git a/tools/eslint/node_modules/concat-stream/test/buffer.js b/tools/eslint/node_modules/concat-stream/test/buffer.js new file mode 100644 index 0000000000..d28f5f9c1e --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/buffer.js @@ -0,0 +1,31 @@ +var concat = require('../') +var test = require('tape') +var TA = require('typedarray') +var U8 = typeof Uint8Array !== 'undefined' ? Uint8Array : TA.Uint8Array + +test('buffer stream', function (t) { + t.plan(2) + var buffers = concat(function(out) { + t.ok(Buffer.isBuffer(out)) + t.equal(out.toString('utf8'), 'pizza Array is not a stringy cat') + }) + buffers.write(new Buffer('pizza Array is not a ', 'utf8')) + buffers.write(new Buffer('stringy cat')) + buffers.end() +}) + +test('buffer mixed writes', function (t) { + t.plan(2) + var buffers = concat(function(out) { + t.ok(Buffer.isBuffer(out)) + t.equal(out.toString('utf8'), 'pizza Array is not a stringy cat555') + }) + buffers.write(new Buffer('pizza')) + buffers.write(' Array is not a ') + buffers.write([ 115, 116, 114, 105, 110, 103, 121 ]) + var u8 = new U8(4) + u8[0] = 32; u8[1] = 99; u8[2] = 97; u8[3] = 116 + buffers.write(u8) + buffers.write(555) + buffers.end() +}) diff --git a/tools/eslint/node_modules/concat-stream/test/infer.js b/tools/eslint/node_modules/concat-stream/test/infer.js new file mode 100644 index 0000000000..91ab933f45 --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/infer.js @@ -0,0 +1,15 @@ +var concat = require('../') +var test = require('tape') + +test('type inference works as expected', function(t) { + var stream = concat() + t.equal(stream.inferEncoding(['hello']), 'array', 'array') + t.equal(stream.inferEncoding(new Buffer('hello')), 'buffer', 'buffer') + t.equal(stream.inferEncoding(undefined), 'buffer', 'buffer') + t.equal(stream.inferEncoding(new Uint8Array(1)), 'uint8array', 'uint8array') + t.equal(stream.inferEncoding('hello'), 'string', 'string') + t.equal(stream.inferEncoding(''), 'string', 'string') + t.equal(stream.inferEncoding({hello: "world"}), 'object', 'object') + t.equal(stream.inferEncoding(1), 'buffer', 'buffer') + t.end() +}) diff --git a/tools/eslint/node_modules/concat-stream/test/nothing.js b/tools/eslint/node_modules/concat-stream/test/nothing.js new file mode 100644 index 0000000000..6ac6049658 --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/nothing.js @@ -0,0 +1,25 @@ +var concat = require('../') +var test = require('tape') + +test('no callback stream', function (t) { + var stream = concat() + stream.write('space') + stream.end(' cats') + t.end() +}) + +test('no encoding set, no data', function (t) { + var stream = concat(function(data) { + t.deepEqual(data, []) + t.end() + }) + stream.end() +}) + +test('encoding set to string, no data', function (t) { + var stream = concat({ encoding: 'string' }, function(data) { + t.deepEqual(data, '') + t.end() + }) + stream.end() +}) diff --git a/tools/eslint/node_modules/concat-stream/test/objects.js b/tools/eslint/node_modules/concat-stream/test/objects.js new file mode 100644 index 0000000000..ad921ed25b --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/objects.js @@ -0,0 +1,29 @@ +var concat = require('../') +var test = require('tape') + +test('writing objects', function (t) { + var stream = concat({encoding: "objects"}, concatted) + function concatted(objs) { + t.equal(objs.length, 2) + t.deepEqual(objs[0], {"foo": "bar"}) + t.deepEqual(objs[1], {"baz": "taco"}) + } + stream.write({"foo": "bar"}) + stream.write({"baz": "taco"}) + stream.end() + t.end() +}) + + +test('switch to objects encoding if no encoding specified and objects are written', function (t) { + var stream = concat(concatted) + function concatted(objs) { + t.equal(objs.length, 2) + t.deepEqual(objs[0], {"foo": "bar"}) + t.deepEqual(objs[1], {"baz": "taco"}) + } + stream.write({"foo": "bar"}) + stream.write({"baz": "taco"}) + stream.end() + t.end() +}) diff --git a/tools/eslint/node_modules/concat-stream/test/server/ls.js b/tools/eslint/node_modules/concat-stream/test/server/ls.js new file mode 100644 index 0000000000..3258d8ddcb --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/server/ls.js @@ -0,0 +1,16 @@ +var concat = require('../../') +var spawn = require('child_process').spawn +var exec = require('child_process').exec +var test = require('tape') + +test('ls command', function (t) { + t.plan(1) + var cmd = spawn('ls', [ __dirname ]) + cmd.stdout.pipe( + concat(function(out) { + exec('ls ' + __dirname, function (err, body) { + t.equal(out.toString('utf8'), body.toString('utf8')) + }) + }) + ) +}) diff --git a/tools/eslint/node_modules/concat-stream/test/string.js b/tools/eslint/node_modules/concat-stream/test/string.js new file mode 100644 index 0000000000..218c522063 --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/string.js @@ -0,0 +1,76 @@ +var concat = require('../') +var test = require('tape') +var TA = require('typedarray') +var U8 = typeof Uint8Array !== 'undefined' ? Uint8Array : TA.Uint8Array + +test('string -> buffer stream', function (t) { + t.plan(2) + var strings = concat({ encoding: 'buffer'}, function(out) { + t.ok(Buffer.isBuffer(out)) + t.equal(out.toString('utf8'), 'nacho dogs') + }) + strings.write("nacho ") + strings.write("dogs") + strings.end() +}) + +test('string stream', function (t) { + t.plan(2) + var strings = concat({ encoding: 'string' }, function(out) { + t.equal(typeof out, 'string') + t.equal(out, 'nacho dogs') + }) + strings.write("nacho ") + strings.write("dogs") + strings.end() +}) + +test('end chunk', function (t) { + t.plan(1) + var endchunk = concat({ encoding: 'string' }, function(out) { + t.equal(out, 'this is the end') + }) + endchunk.write("this ") + endchunk.write("is the ") + endchunk.end("end") +}) + +test('string from mixed write encodings', function (t) { + t.plan(2) + var strings = concat({ encoding: 'string' }, function(out) { + t.equal(typeof out, 'string') + t.equal(out, 'nacho dogs') + }) + strings.write('na') + strings.write(Buffer('cho')) + strings.write([ 32, 100 ]) + var u8 = new U8(3) + u8[0] = 111; u8[1] = 103; u8[2] = 115; + strings.end(u8) +}) + +test('string from buffers with multibyte characters', function (t) { + t.plan(2) + var strings = concat({ encoding: 'string' }, function(out) { + t.equal(typeof out, 'string') + t.equal(out, '☃☃☃☃☃☃☃☃') + }) + var snowman = new Buffer('☃') + for (var i = 0; i < 8; i++) { + strings.write(snowman.slice(0, 1)) + strings.write(snowman.slice(1)) + } + strings.end() +}) + +test('string infer encoding with empty string chunk', function (t) { + t.plan(2) + var strings = concat(function(out) { + t.equal(typeof out, 'string') + t.equal(out, 'nacho dogs') + }) + strings.write("") + strings.write("nacho ") + strings.write("dogs") + strings.end() +}) diff --git a/tools/eslint/node_modules/concat-stream/test/typedarray.js b/tools/eslint/node_modules/concat-stream/test/typedarray.js new file mode 100644 index 0000000000..ee07110828 --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/typedarray.js @@ -0,0 +1,33 @@ +var concat = require('../') +var test = require('tape') +var TA = require('typedarray') +var U8 = typeof Uint8Array !== 'undefined' ? Uint8Array : TA.Uint8Array + +test('typed array stream', function (t) { + t.plan(2) + var a = new U8(5) + a[0] = 97; a[1] = 98; a[2] = 99; a[3] = 100; a[4] = 101; + var b = new U8(3) + b[0] = 32; b[1] = 102; b[2] = 103; + var c = new U8(4) + c[0] = 32; c[1] = 120; c[2] = 121; c[3] = 122; + + var arrays = concat({ encoding: 'Uint8Array' }, function(out) { + t.equal(typeof out.subarray, 'function') + t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz') + }) + arrays.write(a) + arrays.write(b) + arrays.end(c) +}) + +test('typed array from strings, buffers, and arrays', function (t) { + t.plan(2) + var arrays = concat({ encoding: 'Uint8Array' }, function(out) { + t.equal(typeof out.subarray, 'function') + t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz') + }) + arrays.write('abcde') + arrays.write(Buffer(' fg ')) + arrays.end([ 120, 121, 122 ]) +}) |