|
|
@@ -7,15 +7,16 @@ const {streamFromArray, streamToArray} = require('./helpers');
|
|
|
const {Transform} = require('stream');
|
|
|
|
|
|
unit.add(module, [
|
|
|
- function test_simple(t) {
|
|
|
- const async = t.startAsync('test_simple');
|
|
|
+ function test_simpleGeneric(t) {
|
|
|
+ const async = t.startAsync('test_simpleGeneric');
|
|
|
|
|
|
const chain = new Chain([x => x * x]),
|
|
|
output1 = [],
|
|
|
output2 = [];
|
|
|
|
|
|
- streamFromArray([1, 2, 3]).pipe(chain.input);
|
|
|
- chain.output.pipe(streamToArray(output1));
|
|
|
+ streamFromArray([1, 2, 3])
|
|
|
+ .pipe(chain)
|
|
|
+ .pipe(streamToArray(output1));
|
|
|
|
|
|
chain.on('data', value => output2.push(value));
|
|
|
chain.on('end', () => {
|
|
|
@@ -24,8 +25,8 @@ unit.add(module, [
|
|
|
async.done();
|
|
|
});
|
|
|
},
|
|
|
- function test_gen(t) {
|
|
|
- const async = t.startAsync('test_gen');
|
|
|
+ function test_simpleGenerator(t) {
|
|
|
+ const async = t.startAsync('test_simpleGenerator');
|
|
|
|
|
|
const chain = new Chain([
|
|
|
function*(x) {
|
|
|
@@ -36,7 +37,7 @@ unit.add(module, [
|
|
|
]),
|
|
|
output = [];
|
|
|
|
|
|
- streamFromArray([1, 2, 3]).pipe(chain.input);
|
|
|
+ streamFromArray([1, 2, 3]).pipe(chain);
|
|
|
|
|
|
chain.on('data', value => output.push(value));
|
|
|
chain.on('end', () => {
|
|
|
@@ -44,8 +45,8 @@ unit.add(module, [
|
|
|
async.done();
|
|
|
});
|
|
|
},
|
|
|
- function test_async(t) {
|
|
|
- const async = t.startAsync('test_async');
|
|
|
+ function test_simpleAsync(t) {
|
|
|
+ const async = t.startAsync('test_simpleAsync');
|
|
|
|
|
|
const chain = new Chain([
|
|
|
async x =>
|
|
|
@@ -55,7 +56,7 @@ unit.add(module, [
|
|
|
]),
|
|
|
output = [];
|
|
|
|
|
|
- streamFromArray([1, 2, 3]).pipe(chain.input);
|
|
|
+ streamFromArray([1, 2, 3]).pipe(chain);
|
|
|
|
|
|
chain.on('data', value => output.push(value));
|
|
|
chain.on('end', () => {
|
|
|
@@ -63,13 +64,13 @@ unit.add(module, [
|
|
|
async.done();
|
|
|
});
|
|
|
},
|
|
|
- function test_array(t) {
|
|
|
- const async = t.startAsync('test_array');
|
|
|
+ function test_simpleArray(t) {
|
|
|
+ const async = t.startAsync('test_simpleArray');
|
|
|
|
|
|
const chain = new Chain([x => [x * x, x * x * x, 2 * x]]),
|
|
|
output = [];
|
|
|
|
|
|
- streamFromArray([1, 2, 3]).pipe(chain.input);
|
|
|
+ streamFromArray([1, 2, 3]).pipe(chain);
|
|
|
|
|
|
chain.on('data', value => output.push(value));
|
|
|
chain.on('end', () => {
|
|
|
@@ -77,13 +78,13 @@ unit.add(module, [
|
|
|
async.done();
|
|
|
});
|
|
|
},
|
|
|
- function test_chain(t) {
|
|
|
- const async = t.startAsync('test_chain');
|
|
|
+ function test_simpleChain(t) {
|
|
|
+ const async = t.startAsync('test_simpleChain');
|
|
|
|
|
|
const chain = new Chain([x => x * x, x => 2 * x + 1]),
|
|
|
output = [];
|
|
|
|
|
|
- streamFromArray([1, 2, 3]).pipe(chain.input);
|
|
|
+ streamFromArray([1, 2, 3]).pipe(chain);
|
|
|
|
|
|
chain.on('data', value => output.push(value));
|
|
|
chain.on('end', () => {
|
|
|
@@ -91,8 +92,8 @@ unit.add(module, [
|
|
|
async.done();
|
|
|
});
|
|
|
},
|
|
|
- function test_stream(t) {
|
|
|
- const async = t.startAsync('test_stream');
|
|
|
+ function test_simpleStream(t) {
|
|
|
+ const async = t.startAsync('test_simpleStream');
|
|
|
|
|
|
const chain = new Chain([
|
|
|
new Transform({
|
|
|
@@ -105,7 +106,21 @@ unit.add(module, [
|
|
|
]),
|
|
|
output = [];
|
|
|
|
|
|
- streamFromArray([1, 2, 3]).pipe(chain.input);
|
|
|
+ streamFromArray([1, 2, 3]).pipe(chain);
|
|
|
+
|
|
|
+ chain.on('data', value => output.push(value));
|
|
|
+ chain.on('end', () => {
|
|
|
+ eval(t.TEST('t.unify(output, [3, 9, 19])'));
|
|
|
+ async.done();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ function test_simpleFactory(t) {
|
|
|
+ const async = t.startAsync('test_simpleChain');
|
|
|
+
|
|
|
+ const chain = Chain.chain([x => x * x, x => 2 * x + 1]),
|
|
|
+ output = [];
|
|
|
+
|
|
|
+ streamFromArray([1, 2, 3]).pipe(chain);
|
|
|
|
|
|
chain.on('data', value => output.push(value));
|
|
|
chain.on('end', () => {
|