diff options
author | Rich Trott <rtrott@gmail.com> | 2016-12-10 21:43:39 -0800 |
---|---|---|
committer | Italo A. Casas <me@italoacasas.com> | 2016-12-14 10:14:39 -0500 |
commit | b79e83e7f6458fe5bb180731a2fdb9341a22514e (patch) | |
tree | 5229988c79c13426008f06acea5fe4455fc05b3e /test/parallel/test-stream-big-push.js | |
parent | 9f6f0f748c03b41f5ba55d57ad0d3bed49fac888 (diff) | |
download | android-node-v8-b79e83e7f6458fe5bb180731a2fdb9341a22514e.tar.gz android-node-v8-b79e83e7f6458fe5bb180731a2fdb9341a22514e.tar.bz2 android-node-v8-b79e83e7f6458fe5bb180731a2fdb9341a22514e.zip |
test: refactor test-stream-big-push
* use common.mustCall()
* specify setTimeout() duration of 1ms
* remove unused `n` function argument
PR-URL: https://github.com/nodejs/node/pull/10226
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test/parallel/test-stream-big-push.js')
-rw-r--r-- | test/parallel/test-stream-big-push.js | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/test/parallel/test-stream-big-push.js b/test/parallel/test-stream-big-push.js index d9b79ebafc..27feef35ef 100644 --- a/test/parallel/test-stream-big-push.js +++ b/test/parallel/test-stream-big-push.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const stream = require('stream'); const str = 'asdfasdfasdfasdfasdf'; @@ -10,29 +10,25 @@ const r = new stream.Readable({ }); let reads = 0; -let eofed = false; -let ended = false; -r._read = function(n) { +function _read() { if (reads === 0) { setTimeout(function() { r.push(str); - }); + }, 1); reads++; } else if (reads === 1) { var ret = r.push(str); assert.strictEqual(ret, false); reads++; } else { - assert(!eofed); - eofed = true; r.push(null); } -}; +} -r.on('end', function() { - ended = true; -}); +r._read = common.mustCall(_read, 3); + +r.on('end', common.mustCall(function() {})); // push some data in to start. // we've never gotten any read event at this point. @@ -55,10 +51,3 @@ r.once('readable', function() { chunk = r.read(); assert.strictEqual(chunk, null); }); - -process.on('exit', function() { - assert(eofed); - assert(ended); - assert.strictEqual(reads, 2); - console.log('ok'); -}); |