From 4dc7862d5913d538093f15a1f077b464a8e19ed0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 21 May 2017 14:36:12 -0700 Subject: [PATCH 1/3] test: check noop function invocations In test/pummel/test-stream2-basic.js, check that noop functions are called the expected number of times. --- test/pummel/test-stream2-basic.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/pummel/test-stream2-basic.js b/test/pummel/test-stream2-basic.js index 717c11b07e4abb..8a1d940ce77211 100644 --- a/test/pummel/test-stream2-basic.js +++ b/test/pummel/test-stream2-basic.js @@ -147,7 +147,7 @@ test('a most basic test', function(t) { 'xxxxxxxxxxxxxxxxxxxxx' ]; r.on('end', function() { - t.same(reads, expect); + assert.strict(reads, expect); t.end(); }); @@ -180,7 +180,7 @@ test('pipe', function(t) { const w = new TestWriter(); w.on('end', function(received) { - t.same(received, expect); + assert.strict(received, expect); t.end(); }); @@ -226,7 +226,7 @@ test('pipe', function(t) { t.equal(ended0, false); ended0 = true; ended++; - t.same(results, expect[0]); + assert.strict(results, expect[0]); }); w[1].on('end', function(results) { @@ -234,7 +234,7 @@ test('pipe', function(t) { ended1 = true; ended++; t.equal(ended, 2); - t.same(results, expect[1]); + assert.strict(results, expect[1]); t.end(); }); @@ -261,11 +261,11 @@ test('multipipe', function(t) { let c = 2; w[0].on('end', function(received) { - t.same(received, expect, 'first'); + assert.strict(received, expect, 'first'); if (--c === 0) t.end(); }); w[1].on('end', function(received) { - t.same(received, expect, 'second'); + assert.strict(received, expect, 'second'); if (--c === 0) t.end(); }); @@ -306,13 +306,13 @@ test('multipipe', function(t) { w[0].on('end', function(results) { ended++; - t.same(results, expect[0]); + assert.strict(results, expect[0]); }); w[1].on('end', function(results) { ended++; t.equal(ended, 2); - t.same(results, expect[1]); + assert.strict(results, expect[1]); t.end(); }); @@ -323,7 +323,7 @@ test('multipipe', function(t) { test('back pressure respected', function(t) { const r = new R({ objectMode: true }); - r._read = common.noop; + r._read = common.mustNotCall(); let counter = 0; r.push(['one']); r.push(['two']); @@ -341,7 +341,7 @@ test('back pressure respected', function(t) { r.pipe(w3); }); }; - w1.end = common.noop; + w1.end = common.mustNotCall(); r.pipe(w1); @@ -367,7 +367,7 @@ test('back pressure respected', function(t) { return false; }; - w2.end = common.noop; + w2.end = common.mustCall(); const w3 = new R(); w3.write = function(chunk) { @@ -400,7 +400,7 @@ test('read(0) for ended streams', function(t) { const r = new R(); let written = false; let ended = false; - r._read = common.noop; + r._read = common.mustNotCall(); r.push(Buffer.from('foo')); r.push(null); @@ -471,7 +471,7 @@ test('adding readable triggers data flow', function(t) { test('chainable', function(t) { const r = new R(); - r._read = common.noop; + r._read = common.mustCall(); const r2 = r.setEncoding('utf8').pause().resume().pause(); t.equal(r, r2); t.end(); From 0b26f3a1d0706aaa3a13973e9737004c2c989aa4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 21 May 2017 14:40:17 -0700 Subject: [PATCH 2/3] test: simplify assert usage in test-stream2-basic --- test/pummel/test-stream2-basic.js | 37 ++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/test/pummel/test-stream2-basic.js b/test/pummel/test-stream2-basic.js index 8a1d940ce77211..cb017a17065e27 100644 --- a/test/pummel/test-stream2-basic.js +++ b/test/pummel/test-stream2-basic.js @@ -107,9 +107,6 @@ function run() { const fn = next[1]; console.log('# %s', name); fn({ - same: assert.deepStrictEqual, - ok: assert, - equal: assert.strictEqual, end: function() { count--; run(); @@ -147,7 +144,7 @@ test('a most basic test', function(t) { 'xxxxxxxxxxxxxxxxxxxxx' ]; r.on('end', function() { - assert.strict(reads, expect); + assert.deepStrictEqual(reads, expect); t.end(); }); @@ -180,7 +177,7 @@ test('pipe', function(t) { const w = new TestWriter(); w.on('end', function(received) { - assert.strict(received, expect); + assert.deepStrictEqual(received, expect); t.end(); }); @@ -211,10 +208,10 @@ test('pipe', function(t) { w[0].on('write', function() { if (--writes === 0) { r.unpipe(); - t.equal(r._readableState.pipes, null); + assert.strictEqual(r._readableState.pipes, null); w[0].end(); r.pipe(w[1]); - t.equal(r._readableState.pipes, w[1]); + assert.strictEqual(r._readableState.pipes, w[1]); } }); @@ -223,18 +220,18 @@ test('pipe', function(t) { let ended0 = false; let ended1 = false; w[0].on('end', function(results) { - t.equal(ended0, false); + assert.strictEqual(ended0, false); ended0 = true; ended++; - assert.strict(results, expect[0]); + assert.deepStrictEqual(results, expect[0]); }); w[1].on('end', function(results) { - t.equal(ended1, false); + assert.strictEqual(ended1, false); ended1 = true; ended++; - t.equal(ended, 2); - assert.strict(results, expect[1]); + assert.strictEqual(ended, 2); + assert.deepStrictEqual(results, expect[1]); t.end(); }); @@ -261,11 +258,11 @@ test('multipipe', function(t) { let c = 2; w[0].on('end', function(received) { - assert.strict(received, expect, 'first'); + assert.deepStrictEqual(received, expect, 'first'); if (--c === 0) t.end(); }); w[1].on('end', function(received) { - assert.strict(received, expect, 'second'); + assert.deepStrictEqual(received, expect, 'second'); if (--c === 0) t.end(); }); @@ -306,13 +303,13 @@ test('multipipe', function(t) { w[0].on('end', function(results) { ended++; - assert.strict(results, expect[0]); + assert.deepStrictEqual(results, expect[0]); }); w[1].on('end', function(results) { ended++; - t.equal(ended, 2); - assert.strict(results, expect[1]); + assert.strictEqual(ended, 2); + assert.deepStrictEqual(results, expect[1]); t.end(); }); @@ -463,8 +460,8 @@ test('adding readable triggers data flow', function(t) { }); r.on('end', function() { - t.equal(readCalled, 3); - t.ok(onReadable); + assert.strictEqual(readCalled, 3); + assert.ok(onReadable); t.end(); }); }); @@ -473,6 +470,6 @@ test('chainable', function(t) { const r = new R(); r._read = common.mustCall(); const r2 = r.setEncoding('utf8').pause().resume().pause(); - t.equal(r, r2); + assert.strictEqual(r, r2); t.end(); }); From fd82e914cbad3cd5162dad72ef52144126a7e53b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 21 May 2017 14:43:09 -0700 Subject: [PATCH 3/3] test: move stream2 test from pummel to parallel test-stream2-basic runs in a few seconds. It can be moved to parallel. --- test/{pummel => parallel}/test-stream2-basic.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{pummel => parallel}/test-stream2-basic.js (100%) diff --git a/test/pummel/test-stream2-basic.js b/test/parallel/test-stream2-basic.js similarity index 100% rename from test/pummel/test-stream2-basic.js rename to test/parallel/test-stream2-basic.js