| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3fb1e26 commit 4f7cc74
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const Readable = require('_stream_readable'); | |
| 5 | 5 | const Writable = require('_stream_writable'); | |
@@ -13,7 +13,7 @@ function TestReadable(opt) { | |||
| 13 | 13 | this._ended = false; | |
| 14 | 14 | } | |
| 15 | 15 | ||
| 16 | - TestReadable.prototype._read = function(n) { | ||
| 16 | + TestReadable.prototype._read = function() { | ||
| 17 | 17 | if (this._ended) | |
| 18 | 18 | this.emit('error', new Error('_read called twice')); | |
| 19 | 19 | this._ended = true; | |
@@ -35,31 +35,18 @@ TestWritable.prototype._write = function(chunk, encoding, cb) { | |||
| 35 | 35 | ||
| 36 | 36 | // this one should not emit 'end' until we read() from it later. | |
| 37 | 37 | const ender = new TestReadable(); | |
| 38 | - let enderEnded = false; | ||
| 39 | 38 | ||
| 40 | 39 | // what happens when you pipe() a Readable that's already ended? | |
| 41 | 40 | const piper = new TestReadable(); | |
| 42 | 41 | // pushes EOF null, and length=0, so this will trigger 'end' | |
| 43 | 42 | piper.read(); | |
| 44 | 43 | ||
| 45 | - setTimeout(function() { | ||
| 46 | - ender.on('end', function() { | ||
| 47 | - enderEnded = true; | ||
| 48 | - }); | ||
| 49 | - assert(!enderEnded); | ||
| 44 | + setTimeout(common.mustCall(function() { | ||
| 45 | + ender.on('end', common.mustCall(function() {})); | ||
| 50 | 46 | const c = ender.read(); | |
| 51 | - assert.equal(c, null); | ||
| 47 | + assert.strictEqual(c, null); | ||
| 52 | 48 | ||
| 53 | 49 | const w = new TestWritable(); | |
| 54 | - let writableFinished = false; | ||
| 55 | - w.on('finish', function() { | ||
| 56 | - writableFinished = true; | ||
| 57 | - }); | ||
| 50 | + w.on('finish', common.mustCall(function() {})); | ||
| 58 | 51 | piper.pipe(w); | |
| 59 | - | ||
| 60 | - process.on('exit', function() { | ||
| 61 | - assert(enderEnded); | ||
| 62 | - assert(writableFinished); | ||
| 63 | - console.log('ok'); | ||
| 64 | - }); | ||
| 65 | - }); | ||
| 52 | + }), 1); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments