float.patch 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js
  2. index c5a741c..a2e0d8e 100644
  3. --- a/lib/_stream_duplex.js
  4. +++ b/lib/_stream_duplex.js
  5. @@ -26,8 +26,8 @@
  6. module.exports = Duplex;
  7. var util = require('util');
  8. -var Readable = require('_stream_readable');
  9. -var Writable = require('_stream_writable');
  10. +var Readable = require('./_stream_readable');
  11. +var Writable = require('./_stream_writable');
  12. util.inherits(Duplex, Readable);
  13. diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js
  14. index a5e9864..330c247 100644
  15. --- a/lib/_stream_passthrough.js
  16. +++ b/lib/_stream_passthrough.js
  17. @@ -25,7 +25,7 @@
  18. module.exports = PassThrough;
  19. -var Transform = require('_stream_transform');
  20. +var Transform = require('./_stream_transform');
  21. var util = require('util');
  22. util.inherits(PassThrough, Transform);
  23. diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
  24. index 0c3fe3e..90a8298 100644
  25. --- a/lib/_stream_readable.js
  26. +++ b/lib/_stream_readable.js
  27. @@ -23,10 +23,34 @@ module.exports = Readable;
  28. Readable.ReadableState = ReadableState;
  29. var EE = require('events').EventEmitter;
  30. +if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
  31. + return emitter.listeners(type).length;
  32. +};
  33. +
  34. +if (!global.setImmediate) global.setImmediate = function setImmediate(fn) {
  35. + return setTimeout(fn, 0);
  36. +};
  37. +if (!global.clearImmediate) global.clearImmediate = function clearImmediate(i) {
  38. + return clearTimeout(i);
  39. +};
  40. +
  41. var Stream = require('stream');
  42. var util = require('util');
  43. +if (!util.isUndefined) {
  44. + var utilIs = require('core-util-is');
  45. + for (var f in utilIs) {
  46. + util[f] = utilIs[f];
  47. + }
  48. +}
  49. var StringDecoder;
  50. -var debug = util.debuglog('stream');
  51. +var debug;
  52. +if (util.debuglog)
  53. + debug = util.debuglog('stream');
  54. +else try {
  55. + debug = require('debuglog')('stream');
  56. +} catch (er) {
  57. + debug = function() {};
  58. +}
  59. util.inherits(Readable, Stream);
  60. @@ -380,7 +404,7 @@ function chunkInvalid(state, chunk) {
  61. function onEofChunk(stream, state) {
  62. - if (state.decoder && !state.ended) {
  63. + if (state.decoder && !state.ended && state.decoder.end) {
  64. var chunk = state.decoder.end();
  65. if (chunk && chunk.length) {
  66. state.buffer.push(chunk);
  67. diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js
  68. index b1f9fcc..b0caf57 100644
  69. --- a/lib/_stream_transform.js
  70. +++ b/lib/_stream_transform.js
  71. @@ -64,8 +64,14 @@
  72. module.exports = Transform;
  73. -var Duplex = require('_stream_duplex');
  74. +var Duplex = require('./_stream_duplex');
  75. var util = require('util');
  76. +if (!util.isUndefined) {
  77. + var utilIs = require('core-util-is');
  78. + for (var f in utilIs) {
  79. + util[f] = utilIs[f];
  80. + }
  81. +}
  82. util.inherits(Transform, Duplex);
  83. diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
  84. index ba2e920..f49288b 100644
  85. --- a/lib/_stream_writable.js
  86. +++ b/lib/_stream_writable.js
  87. @@ -27,6 +27,12 @@ module.exports = Writable;
  88. Writable.WritableState = WritableState;
  89. var util = require('util');
  90. +if (!util.isUndefined) {
  91. + var utilIs = require('core-util-is');
  92. + for (var f in utilIs) {
  93. + util[f] = utilIs[f];
  94. + }
  95. +}
  96. var Stream = require('stream');
  97. util.inherits(Writable, Stream);
  98. @@ -119,7 +125,7 @@ function WritableState(options, stream) {
  99. function Writable(options) {
  100. // Writable ctor is applied to Duplexes, though they're not
  101. // instanceof Writable, they're instanceof Readable.
  102. - if (!(this instanceof Writable) && !(this instanceof Stream.Duplex))
  103. + if (!(this instanceof Writable) && !(this instanceof require('./_stream_duplex')))
  104. return new Writable(options);
  105. this._writableState = new WritableState(options, this);
  106. diff --git a/test/simple/test-stream-big-push.js b/test/simple/test-stream-big-push.js
  107. index e3787e4..8cd2127 100644
  108. --- a/test/simple/test-stream-big-push.js
  109. +++ b/test/simple/test-stream-big-push.js
  110. @@ -21,7 +21,7 @@
  111. var common = require('../common');
  112. var assert = require('assert');
  113. -var stream = require('stream');
  114. +var stream = require('../../');
  115. var str = 'asdfasdfasdfasdfasdf';
  116. var r = new stream.Readable({
  117. diff --git a/test/simple/test-stream-end-paused.js b/test/simple/test-stream-end-paused.js
  118. index bb73777..d40efc7 100644
  119. --- a/test/simple/test-stream-end-paused.js
  120. +++ b/test/simple/test-stream-end-paused.js
  121. @@ -25,7 +25,7 @@ var gotEnd = false;
  122. // Make sure we don't miss the end event for paused 0-length streams
  123. -var Readable = require('stream').Readable;
  124. +var Readable = require('../../').Readable;
  125. var stream = new Readable();
  126. var calledRead = false;
  127. stream._read = function() {
  128. diff --git a/test/simple/test-stream-pipe-after-end.js b/test/simple/test-stream-pipe-after-end.js
  129. index b46ee90..0be8366 100644
  130. --- a/test/simple/test-stream-pipe-after-end.js
  131. +++ b/test/simple/test-stream-pipe-after-end.js
  132. @@ -22,8 +22,8 @@
  133. var common = require('../common');
  134. var assert = require('assert');
  135. -var Readable = require('_stream_readable');
  136. -var Writable = require('_stream_writable');
  137. +var Readable = require('../../lib/_stream_readable');
  138. +var Writable = require('../../lib/_stream_writable');
  139. var util = require('util');
  140. util.inherits(TestReadable, Readable);
  141. diff --git a/test/simple/test-stream-pipe-cleanup.js b/test/simple/test-stream-pipe-cleanup.js
  142. deleted file mode 100644
  143. index f689358..0000000
  144. --- a/test/simple/test-stream-pipe-cleanup.js
  145. +++ /dev/null
  146. @@ -1,122 +0,0 @@
  147. -// Copyright Joyent, Inc. and other Node contributors.
  148. -//
  149. -// Permission is hereby granted, free of charge, to any person obtaining a
  150. -// copy of this software and associated documentation files (the
  151. -// "Software"), to deal in the Software without restriction, including
  152. -// without limitation the rights to use, copy, modify, merge, publish,
  153. -// distribute, sublicense, and/or sell copies of the Software, and to permit
  154. -// persons to whom the Software is furnished to do so, subject to the
  155. -// following conditions:
  156. -//
  157. -// The above copyright notice and this permission notice shall be included
  158. -// in all copies or substantial portions of the Software.
  159. -//
  160. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  161. -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  162. -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  163. -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  164. -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  165. -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  166. -// USE OR OTHER DEALINGS IN THE SOFTWARE.
  167. -
  168. -// This test asserts that Stream.prototype.pipe does not leave listeners
  169. -// hanging on the source or dest.
  170. -
  171. -var common = require('../common');
  172. -var stream = require('stream');
  173. -var assert = require('assert');
  174. -var util = require('util');
  175. -
  176. -function Writable() {
  177. - this.writable = true;
  178. - this.endCalls = 0;
  179. - stream.Stream.call(this);
  180. -}
  181. -util.inherits(Writable, stream.Stream);
  182. -Writable.prototype.end = function() {
  183. - this.endCalls++;
  184. -};
  185. -
  186. -Writable.prototype.destroy = function() {
  187. - this.endCalls++;
  188. -};
  189. -
  190. -function Readable() {
  191. - this.readable = true;
  192. - stream.Stream.call(this);
  193. -}
  194. -util.inherits(Readable, stream.Stream);
  195. -
  196. -function Duplex() {
  197. - this.readable = true;
  198. - Writable.call(this);
  199. -}
  200. -util.inherits(Duplex, Writable);
  201. -
  202. -var i = 0;
  203. -var limit = 100;
  204. -
  205. -var w = new Writable();
  206. -
  207. -var r;
  208. -
  209. -for (i = 0; i < limit; i++) {
  210. - r = new Readable();
  211. - r.pipe(w);
  212. - r.emit('end');
  213. -}
  214. -assert.equal(0, r.listeners('end').length);
  215. -assert.equal(limit, w.endCalls);
  216. -
  217. -w.endCalls = 0;
  218. -
  219. -for (i = 0; i < limit; i++) {
  220. - r = new Readable();
  221. - r.pipe(w);
  222. - r.emit('close');
  223. -}
  224. -assert.equal(0, r.listeners('close').length);
  225. -assert.equal(limit, w.endCalls);
  226. -
  227. -w.endCalls = 0;
  228. -
  229. -r = new Readable();
  230. -
  231. -for (i = 0; i < limit; i++) {
  232. - w = new Writable();
  233. - r.pipe(w);
  234. - w.emit('close');
  235. -}
  236. -assert.equal(0, w.listeners('close').length);
  237. -
  238. -r = new Readable();
  239. -w = new Writable();
  240. -var d = new Duplex();
  241. -r.pipe(d); // pipeline A
  242. -d.pipe(w); // pipeline B
  243. -assert.equal(r.listeners('end').length, 2); // A.onend, A.cleanup
  244. -assert.equal(r.listeners('close').length, 2); // A.onclose, A.cleanup
  245. -assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup
  246. -assert.equal(d.listeners('close').length, 3); // A.cleanup, B.onclose, B.cleanup
  247. -assert.equal(w.listeners('end').length, 0);
  248. -assert.equal(w.listeners('close').length, 1); // B.cleanup
  249. -
  250. -r.emit('end');
  251. -assert.equal(d.endCalls, 1);
  252. -assert.equal(w.endCalls, 0);
  253. -assert.equal(r.listeners('end').length, 0);
  254. -assert.equal(r.listeners('close').length, 0);
  255. -assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup
  256. -assert.equal(d.listeners('close').length, 2); // B.onclose, B.cleanup
  257. -assert.equal(w.listeners('end').length, 0);
  258. -assert.equal(w.listeners('close').length, 1); // B.cleanup
  259. -
  260. -d.emit('end');
  261. -assert.equal(d.endCalls, 1);
  262. -assert.equal(w.endCalls, 1);
  263. -assert.equal(r.listeners('end').length, 0);
  264. -assert.equal(r.listeners('close').length, 0);
  265. -assert.equal(d.listeners('end').length, 0);
  266. -assert.equal(d.listeners('close').length, 0);
  267. -assert.equal(w.listeners('end').length, 0);
  268. -assert.equal(w.listeners('close').length, 0);
  269. diff --git a/test/simple/test-stream-pipe-error-handling.js b/test/simple/test-stream-pipe-error-handling.js
  270. index c5d724b..c7d6b7d 100644
  271. --- a/test/simple/test-stream-pipe-error-handling.js
  272. +++ b/test/simple/test-stream-pipe-error-handling.js
  273. @@ -21,7 +21,7 @@
  274. var common = require('../common');
  275. var assert = require('assert');
  276. -var Stream = require('stream').Stream;
  277. +var Stream = require('../../').Stream;
  278. (function testErrorListenerCatches() {
  279. var source = new Stream();
  280. diff --git a/test/simple/test-stream-pipe-event.js b/test/simple/test-stream-pipe-event.js
  281. index cb9d5fe..56f8d61 100644
  282. --- a/test/simple/test-stream-pipe-event.js
  283. +++ b/test/simple/test-stream-pipe-event.js
  284. @@ -20,7 +20,7 @@
  285. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  286. var common = require('../common');
  287. -var stream = require('stream');
  288. +var stream = require('../../');
  289. var assert = require('assert');
  290. var util = require('util');
  291. diff --git a/test/simple/test-stream-push-order.js b/test/simple/test-stream-push-order.js
  292. index f2e6ec2..a5c9bf9 100644
  293. --- a/test/simple/test-stream-push-order.js
  294. +++ b/test/simple/test-stream-push-order.js
  295. @@ -20,7 +20,7 @@
  296. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  297. var common = require('../common.js');
  298. -var Readable = require('stream').Readable;
  299. +var Readable = require('../../').Readable;
  300. var assert = require('assert');
  301. var s = new Readable({
  302. diff --git a/test/simple/test-stream-push-strings.js b/test/simple/test-stream-push-strings.js
  303. index 06f43dc..1701a9a 100644
  304. --- a/test/simple/test-stream-push-strings.js
  305. +++ b/test/simple/test-stream-push-strings.js
  306. @@ -22,7 +22,7 @@
  307. var common = require('../common');
  308. var assert = require('assert');
  309. -var Readable = require('stream').Readable;
  310. +var Readable = require('../../').Readable;
  311. var util = require('util');
  312. util.inherits(MyStream, Readable);
  313. diff --git a/test/simple/test-stream-readable-event.js b/test/simple/test-stream-readable-event.js
  314. index ba6a577..a8e6f7b 100644
  315. --- a/test/simple/test-stream-readable-event.js
  316. +++ b/test/simple/test-stream-readable-event.js
  317. @@ -22,7 +22,7 @@
  318. var common = require('../common');
  319. var assert = require('assert');
  320. -var Readable = require('stream').Readable;
  321. +var Readable = require('../../').Readable;
  322. (function first() {
  323. // First test, not reading when the readable is added.
  324. diff --git a/test/simple/test-stream-readable-flow-recursion.js b/test/simple/test-stream-readable-flow-recursion.js
  325. index 2891ad6..11689ba 100644
  326. --- a/test/simple/test-stream-readable-flow-recursion.js
  327. +++ b/test/simple/test-stream-readable-flow-recursion.js
  328. @@ -27,7 +27,7 @@ var assert = require('assert');
  329. // more data continuously, but without triggering a nextTick
  330. // warning or RangeError.
  331. -var Readable = require('stream').Readable;
  332. +var Readable = require('../../').Readable;
  333. // throw an error if we trigger a nextTick warning.
  334. process.throwDeprecation = true;
  335. diff --git a/test/simple/test-stream-unshift-empty-chunk.js b/test/simple/test-stream-unshift-empty-chunk.js
  336. index 0c96476..7827538 100644
  337. --- a/test/simple/test-stream-unshift-empty-chunk.js
  338. +++ b/test/simple/test-stream-unshift-empty-chunk.js
  339. @@ -24,7 +24,7 @@ var assert = require('assert');
  340. // This test verifies that stream.unshift(Buffer(0)) or
  341. // stream.unshift('') does not set state.reading=false.
  342. -var Readable = require('stream').Readable;
  343. +var Readable = require('../../').Readable;
  344. var r = new Readable();
  345. var nChunks = 10;
  346. diff --git a/test/simple/test-stream-unshift-read-race.js b/test/simple/test-stream-unshift-read-race.js
  347. index 83fd9fa..17c18aa 100644
  348. --- a/test/simple/test-stream-unshift-read-race.js
  349. +++ b/test/simple/test-stream-unshift-read-race.js
  350. @@ -29,7 +29,7 @@ var assert = require('assert');
  351. // 3. push() after the EOF signaling null is an error.
  352. // 4. _read() is not called after pushing the EOF null chunk.
  353. -var stream = require('stream');
  354. +var stream = require('../../');
  355. var hwm = 10;
  356. var r = stream.Readable({ highWaterMark: hwm });
  357. var chunks = 10;
  358. @@ -51,7 +51,14 @@ r._read = function(n) {
  359. function push(fast) {
  360. assert(!pushedNull, 'push() after null push');
  361. - var c = pos >= data.length ? null : data.slice(pos, pos + n);
  362. + var c;
  363. + if (pos >= data.length)
  364. + c = null;
  365. + else {
  366. + if (n + pos > data.length)
  367. + n = data.length - pos;
  368. + c = data.slice(pos, pos + n);
  369. + }
  370. pushedNull = c === null;
  371. if (fast) {
  372. pos += n;
  373. diff --git a/test/simple/test-stream-writev.js b/test/simple/test-stream-writev.js
  374. index 5b49e6e..b5321f3 100644
  375. --- a/test/simple/test-stream-writev.js
  376. +++ b/test/simple/test-stream-writev.js
  377. @@ -22,7 +22,7 @@
  378. var common = require('../common');
  379. var assert = require('assert');
  380. -var stream = require('stream');
  381. +var stream = require('../../');
  382. var queue = [];
  383. for (var decode = 0; decode < 2; decode++) {
  384. diff --git a/test/simple/test-stream2-basic.js b/test/simple/test-stream2-basic.js
  385. index 3814bf0..248c1be 100644
  386. --- a/test/simple/test-stream2-basic.js
  387. +++ b/test/simple/test-stream2-basic.js
  388. @@ -21,7 +21,7 @@
  389. var common = require('../common.js');
  390. -var R = require('_stream_readable');
  391. +var R = require('../../lib/_stream_readable');
  392. var assert = require('assert');
  393. var util = require('util');
  394. diff --git a/test/simple/test-stream2-compatibility.js b/test/simple/test-stream2-compatibility.js
  395. index 6cdd4e9..f0fa84b 100644
  396. --- a/test/simple/test-stream2-compatibility.js
  397. +++ b/test/simple/test-stream2-compatibility.js
  398. @@ -21,7 +21,7 @@
  399. var common = require('../common.js');
  400. -var R = require('_stream_readable');
  401. +var R = require('../../lib/_stream_readable');
  402. var assert = require('assert');
  403. var util = require('util');
  404. diff --git a/test/simple/test-stream2-finish-pipe.js b/test/simple/test-stream2-finish-pipe.js
  405. index 39b274f..006a19b 100644
  406. --- a/test/simple/test-stream2-finish-pipe.js
  407. +++ b/test/simple/test-stream2-finish-pipe.js
  408. @@ -20,7 +20,7 @@
  409. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  410. var common = require('../common.js');
  411. -var stream = require('stream');
  412. +var stream = require('../../');
  413. var Buffer = require('buffer').Buffer;
  414. var r = new stream.Readable();
  415. diff --git a/test/simple/test-stream2-fs.js b/test/simple/test-stream2-fs.js
  416. deleted file mode 100644
  417. index e162406..0000000
  418. --- a/test/simple/test-stream2-fs.js
  419. +++ /dev/null
  420. @@ -1,72 +0,0 @@
  421. -// Copyright Joyent, Inc. and other Node contributors.
  422. -//
  423. -// Permission is hereby granted, free of charge, to any person obtaining a
  424. -// copy of this software and associated documentation files (the
  425. -// "Software"), to deal in the Software without restriction, including
  426. -// without limitation the rights to use, copy, modify, merge, publish,
  427. -// distribute, sublicense, and/or sell copies of the Software, and to permit
  428. -// persons to whom the Software is furnished to do so, subject to the
  429. -// following conditions:
  430. -//
  431. -// The above copyright notice and this permission notice shall be included
  432. -// in all copies or substantial portions of the Software.
  433. -//
  434. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  435. -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  436. -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  437. -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  438. -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  439. -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  440. -// USE OR OTHER DEALINGS IN THE SOFTWARE.
  441. -
  442. -
  443. -var common = require('../common.js');
  444. -var R = require('_stream_readable');
  445. -var assert = require('assert');
  446. -
  447. -var fs = require('fs');
  448. -var FSReadable = fs.ReadStream;
  449. -
  450. -var path = require('path');
  451. -var file = path.resolve(common.fixturesDir, 'x1024.txt');
  452. -
  453. -var size = fs.statSync(file).size;
  454. -
  455. -var expectLengths = [1024];
  456. -
  457. -var util = require('util');
  458. -var Stream = require('stream');
  459. -
  460. -util.inherits(TestWriter, Stream);
  461. -
  462. -function TestWriter() {
  463. - Stream.apply(this);
  464. - this.buffer = [];
  465. - this.length = 0;
  466. -}
  467. -
  468. -TestWriter.prototype.write = function(c) {
  469. - this.buffer.push(c.toString());
  470. - this.length += c.length;
  471. - return true;
  472. -};
  473. -
  474. -TestWriter.prototype.end = function(c) {
  475. - if (c) this.buffer.push(c.toString());
  476. - this.emit('results', this.buffer);
  477. -}
  478. -
  479. -var r = new FSReadable(file);
  480. -var w = new TestWriter();
  481. -
  482. -w.on('results', function(res) {
  483. - console.error(res, w.length);
  484. - assert.equal(w.length, size);
  485. - var l = 0;
  486. - assert.deepEqual(res.map(function (c) {
  487. - return c.length;
  488. - }), expectLengths);
  489. - console.log('ok');
  490. -});
  491. -
  492. -r.pipe(w);
  493. diff --git a/test/simple/test-stream2-httpclient-response-end.js b/test/simple/test-stream2-httpclient-response-end.js
  494. deleted file mode 100644
  495. index 15cffc2..0000000
  496. --- a/test/simple/test-stream2-httpclient-response-end.js
  497. +++ /dev/null
  498. @@ -1,52 +0,0 @@
  499. -// Copyright Joyent, Inc. and other Node contributors.
  500. -//
  501. -// Permission is hereby granted, free of charge, to any person obtaining a
  502. -// copy of this software and associated documentation files (the
  503. -// "Software"), to deal in the Software without restriction, including
  504. -// without limitation the rights to use, copy, modify, merge, publish,
  505. -// distribute, sublicense, and/or sell copies of the Software, and to permit
  506. -// persons to whom the Software is furnished to do so, subject to the
  507. -// following conditions:
  508. -//
  509. -// The above copyright notice and this permission notice shall be included
  510. -// in all copies or substantial portions of the Software.
  511. -//
  512. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  513. -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  514. -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  515. -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  516. -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  517. -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  518. -// USE OR OTHER DEALINGS IN THE SOFTWARE.
  519. -
  520. -var common = require('../common.js');
  521. -var assert = require('assert');
  522. -var http = require('http');
  523. -var msg = 'Hello';
  524. -var readable_event = false;
  525. -var end_event = false;
  526. -var server = http.createServer(function(req, res) {
  527. - res.writeHead(200, {'Content-Type': 'text/plain'});
  528. - res.end(msg);
  529. -}).listen(common.PORT, function() {
  530. - http.get({port: common.PORT}, function(res) {
  531. - var data = '';
  532. - res.on('readable', function() {
  533. - console.log('readable event');
  534. - readable_event = true;
  535. - data += res.read();
  536. - });
  537. - res.on('end', function() {
  538. - console.log('end event');
  539. - end_event = true;
  540. - assert.strictEqual(msg, data);
  541. - server.close();
  542. - });
  543. - });
  544. -});
  545. -
  546. -process.on('exit', function() {
  547. - assert(readable_event);
  548. - assert(end_event);
  549. -});
  550. -
  551. diff --git a/test/simple/test-stream2-large-read-stall.js b/test/simple/test-stream2-large-read-stall.js
  552. index 2fbfbca..667985b 100644
  553. --- a/test/simple/test-stream2-large-read-stall.js
  554. +++ b/test/simple/test-stream2-large-read-stall.js
  555. @@ -30,7 +30,7 @@ var PUSHSIZE = 20;
  556. var PUSHCOUNT = 1000;
  557. var HWM = 50;
  558. -var Readable = require('stream').Readable;
  559. +var Readable = require('../../').Readable;
  560. var r = new Readable({
  561. highWaterMark: HWM
  562. });
  563. @@ -39,23 +39,23 @@ var rs = r._readableState;
  564. r._read = push;
  565. r.on('readable', function() {
  566. - console.error('>> readable');
  567. + //console.error('>> readable');
  568. do {
  569. - console.error(' > read(%d)', READSIZE);
  570. + //console.error(' > read(%d)', READSIZE);
  571. var ret = r.read(READSIZE);
  572. - console.error(' < %j (%d remain)', ret && ret.length, rs.length);
  573. + //console.error(' < %j (%d remain)', ret && ret.length, rs.length);
  574. } while (ret && ret.length === READSIZE);
  575. - console.error('<< after read()',
  576. - ret && ret.length,
  577. - rs.needReadable,
  578. - rs.length);
  579. + //console.error('<< after read()',
  580. + // ret && ret.length,
  581. + // rs.needReadable,
  582. + // rs.length);
  583. });
  584. var endEmitted = false;
  585. r.on('end', function() {
  586. endEmitted = true;
  587. - console.error('end');
  588. + //console.error('end');
  589. });
  590. var pushes = 0;
  591. @@ -64,11 +64,11 @@ function push() {
  592. return;
  593. if (pushes++ === PUSHCOUNT) {
  594. - console.error(' push(EOF)');
  595. + //console.error(' push(EOF)');
  596. return r.push(null);
  597. }
  598. - console.error(' push #%d', pushes);
  599. + //console.error(' push #%d', pushes);
  600. if (r.push(new Buffer(PUSHSIZE)))
  601. setTimeout(push);
  602. }
  603. diff --git a/test/simple/test-stream2-objects.js b/test/simple/test-stream2-objects.js
  604. index 3e6931d..ff47d89 100644
  605. --- a/test/simple/test-stream2-objects.js
  606. +++ b/test/simple/test-stream2-objects.js
  607. @@ -21,8 +21,8 @@
  608. var common = require('../common.js');
  609. -var Readable = require('_stream_readable');
  610. -var Writable = require('_stream_writable');
  611. +var Readable = require('../../lib/_stream_readable');
  612. +var Writable = require('../../lib/_stream_writable');
  613. var assert = require('assert');
  614. // tiny node-tap lookalike.
  615. diff --git a/test/simple/test-stream2-pipe-error-handling.js b/test/simple/test-stream2-pipe-error-handling.js
  616. index cf7531c..e3f3e4e 100644
  617. --- a/test/simple/test-stream2-pipe-error-handling.js
  618. +++ b/test/simple/test-stream2-pipe-error-handling.js
  619. @@ -21,7 +21,7 @@
  620. var common = require('../common');
  621. var assert = require('assert');
  622. -var stream = require('stream');
  623. +var stream = require('../../');
  624. (function testErrorListenerCatches() {
  625. var count = 1000;
  626. diff --git a/test/simple/test-stream2-pipe-error-once-listener.js b/test/simple/test-stream2-pipe-error-once-listener.js
  627. index 5e8e3cb..53b2616 100755
  628. --- a/test/simple/test-stream2-pipe-error-once-listener.js
  629. +++ b/test/simple/test-stream2-pipe-error-once-listener.js
  630. @@ -24,7 +24,7 @@ var common = require('../common.js');
  631. var assert = require('assert');
  632. var util = require('util');
  633. -var stream = require('stream');
  634. +var stream = require('../../');
  635. var Read = function() {
  636. diff --git a/test/simple/test-stream2-push.js b/test/simple/test-stream2-push.js
  637. index b63edc3..eb2b0e9 100644
  638. --- a/test/simple/test-stream2-push.js
  639. +++ b/test/simple/test-stream2-push.js
  640. @@ -20,7 +20,7 @@
  641. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  642. var common = require('../common.js');
  643. -var stream = require('stream');
  644. +var stream = require('../../');
  645. var Readable = stream.Readable;
  646. var Writable = stream.Writable;
  647. var assert = require('assert');
  648. diff --git a/test/simple/test-stream2-read-sync-stack.js b/test/simple/test-stream2-read-sync-stack.js
  649. index e8a7305..9740a47 100644
  650. --- a/test/simple/test-stream2-read-sync-stack.js
  651. +++ b/test/simple/test-stream2-read-sync-stack.js
  652. @@ -21,7 +21,7 @@
  653. var common = require('../common');
  654. var assert = require('assert');
  655. -var Readable = require('stream').Readable;
  656. +var Readable = require('../../').Readable;
  657. var r = new Readable();
  658. var N = 256 * 1024;
  659. diff --git a/test/simple/test-stream2-readable-empty-buffer-no-eof.js b/test/simple/test-stream2-readable-empty-buffer-no-eof.js
  660. index cd30178..4b1659d 100644
  661. --- a/test/simple/test-stream2-readable-empty-buffer-no-eof.js
  662. +++ b/test/simple/test-stream2-readable-empty-buffer-no-eof.js
  663. @@ -22,10 +22,9 @@
  664. var common = require('../common');
  665. var assert = require('assert');
  666. -var Readable = require('stream').Readable;
  667. +var Readable = require('../../').Readable;
  668. test1();
  669. -test2();
  670. function test1() {
  671. var r = new Readable();
  672. @@ -88,31 +87,3 @@ function test1() {
  673. console.log('ok');
  674. });
  675. }
  676. -
  677. -function test2() {
  678. - var r = new Readable({ encoding: 'base64' });
  679. - var reads = 5;
  680. - r._read = function(n) {
  681. - if (!reads--)
  682. - return r.push(null); // EOF
  683. - else
  684. - return r.push(new Buffer('x'));
  685. - };
  686. -
  687. - var results = [];
  688. - function flow() {
  689. - var chunk;
  690. - while (null !== (chunk = r.read()))
  691. - results.push(chunk + '');
  692. - }
  693. - r.on('readable', flow);
  694. - r.on('end', function() {
  695. - results.push('EOF');
  696. - });
  697. - flow();
  698. -
  699. - process.on('exit', function() {
  700. - assert.deepEqual(results, [ 'eHh4', 'eHg=', 'EOF' ]);
  701. - console.log('ok');
  702. - });
  703. -}
  704. diff --git a/test/simple/test-stream2-readable-from-list.js b/test/simple/test-stream2-readable-from-list.js
  705. index 7c96ffe..04a96f5 100644
  706. --- a/test/simple/test-stream2-readable-from-list.js
  707. +++ b/test/simple/test-stream2-readable-from-list.js
  708. @@ -21,7 +21,7 @@
  709. var assert = require('assert');
  710. var common = require('../common.js');
  711. -var fromList = require('_stream_readable')._fromList;
  712. +var fromList = require('../../lib/_stream_readable')._fromList;
  713. // tiny node-tap lookalike.
  714. var tests = [];
  715. diff --git a/test/simple/test-stream2-readable-legacy-drain.js b/test/simple/test-stream2-readable-legacy-drain.js
  716. index 675da8e..51fd3d5 100644
  717. --- a/test/simple/test-stream2-readable-legacy-drain.js
  718. +++ b/test/simple/test-stream2-readable-legacy-drain.js
  719. @@ -22,7 +22,7 @@
  720. var common = require('../common');
  721. var assert = require('assert');
  722. -var Stream = require('stream');
  723. +var Stream = require('../../');
  724. var Readable = Stream.Readable;
  725. var r = new Readable();
  726. diff --git a/test/simple/test-stream2-readable-non-empty-end.js b/test/simple/test-stream2-readable-non-empty-end.js
  727. index 7314ae7..c971898 100644
  728. --- a/test/simple/test-stream2-readable-non-empty-end.js
  729. +++ b/test/simple/test-stream2-readable-non-empty-end.js
  730. @@ -21,7 +21,7 @@
  731. var assert = require('assert');
  732. var common = require('../common.js');
  733. -var Readable = require('_stream_readable');
  734. +var Readable = require('../../lib/_stream_readable');
  735. var len = 0;
  736. var chunks = new Array(10);
  737. diff --git a/test/simple/test-stream2-readable-wrap-empty.js b/test/simple/test-stream2-readable-wrap-empty.js
  738. index 2e5cf25..fd8a3dc 100644
  739. --- a/test/simple/test-stream2-readable-wrap-empty.js
  740. +++ b/test/simple/test-stream2-readable-wrap-empty.js
  741. @@ -22,7 +22,7 @@
  742. var common = require('../common');
  743. var assert = require('assert');
  744. -var Readable = require('_stream_readable');
  745. +var Readable = require('../../lib/_stream_readable');
  746. var EE = require('events').EventEmitter;
  747. var oldStream = new EE();
  748. diff --git a/test/simple/test-stream2-readable-wrap.js b/test/simple/test-stream2-readable-wrap.js
  749. index 90eea01..6b177f7 100644
  750. --- a/test/simple/test-stream2-readable-wrap.js
  751. +++ b/test/simple/test-stream2-readable-wrap.js
  752. @@ -22,8 +22,8 @@
  753. var common = require('../common');
  754. var assert = require('assert');
  755. -var Readable = require('_stream_readable');
  756. -var Writable = require('_stream_writable');
  757. +var Readable = require('../../lib/_stream_readable');
  758. +var Writable = require('../../lib/_stream_writable');
  759. var EE = require('events').EventEmitter;
  760. var testRuns = 0, completedRuns = 0;
  761. diff --git a/test/simple/test-stream2-set-encoding.js b/test/simple/test-stream2-set-encoding.js
  762. index 5d2c32a..685531b 100644
  763. --- a/test/simple/test-stream2-set-encoding.js
  764. +++ b/test/simple/test-stream2-set-encoding.js
  765. @@ -22,7 +22,7 @@
  766. var common = require('../common.js');
  767. var assert = require('assert');
  768. -var R = require('_stream_readable');
  769. +var R = require('../../lib/_stream_readable');
  770. var util = require('util');
  771. // tiny node-tap lookalike.
  772. diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js
  773. index 9c9ddd8..a0cacc6 100644
  774. --- a/test/simple/test-stream2-transform.js
  775. +++ b/test/simple/test-stream2-transform.js
  776. @@ -21,8 +21,8 @@
  777. var assert = require('assert');
  778. var common = require('../common.js');
  779. -var PassThrough = require('_stream_passthrough');
  780. -var Transform = require('_stream_transform');
  781. +var PassThrough = require('../../').PassThrough;
  782. +var Transform = require('../../').Transform;
  783. // tiny node-tap lookalike.
  784. var tests = [];
  785. diff --git a/test/simple/test-stream2-unpipe-drain.js b/test/simple/test-stream2-unpipe-drain.js
  786. index d66dc3c..365b327 100644
  787. --- a/test/simple/test-stream2-unpipe-drain.js
  788. +++ b/test/simple/test-stream2-unpipe-drain.js
  789. @@ -22,7 +22,7 @@
  790. var common = require('../common.js');
  791. var assert = require('assert');
  792. -var stream = require('stream');
  793. +var stream = require('../../');
  794. var crypto = require('crypto');
  795. var util = require('util');
  796. diff --git a/test/simple/test-stream2-unpipe-leak.js b/test/simple/test-stream2-unpipe-leak.js
  797. index 99f8746..17c92ae 100644
  798. --- a/test/simple/test-stream2-unpipe-leak.js
  799. +++ b/test/simple/test-stream2-unpipe-leak.js
  800. @@ -22,7 +22,7 @@
  801. var common = require('../common.js');
  802. var assert = require('assert');
  803. -var stream = require('stream');
  804. +var stream = require('../../');
  805. var chunk = new Buffer('hallo');
  806. diff --git a/test/simple/test-stream2-writable.js b/test/simple/test-stream2-writable.js
  807. index 704100c..209c3a6 100644
  808. --- a/test/simple/test-stream2-writable.js
  809. +++ b/test/simple/test-stream2-writable.js
  810. @@ -20,8 +20,8 @@
  811. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  812. var common = require('../common.js');
  813. -var W = require('_stream_writable');
  814. -var D = require('_stream_duplex');
  815. +var W = require('../../').Writable;
  816. +var D = require('../../').Duplex;
  817. var assert = require('assert');
  818. var util = require('util');
  819. diff --git a/test/simple/test-stream3-pause-then-read.js b/test/simple/test-stream3-pause-then-read.js
  820. index b91bde3..2f72c15 100644
  821. --- a/test/simple/test-stream3-pause-then-read.js
  822. +++ b/test/simple/test-stream3-pause-then-read.js
  823. @@ -22,7 +22,7 @@
  824. var common = require('../common');
  825. var assert = require('assert');
  826. -var stream = require('stream');
  827. +var stream = require('../../');
  828. var Readable = stream.Readable;
  829. var Writable = stream.Writable;