-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matteo Collina <hello@matteocollina.com>
- Loading branch information
Showing
9 changed files
with
166 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const silentConsole = { | ||
log() {}, | ||
error() {} | ||
} | ||
const common = require('../common') | ||
const { Readable, Writable } = require('../../lib/ours/index') | ||
|
||
// https://github.com/nodejs/node/issues/48666 | ||
;(async () => { | ||
// Prepare src that is internally ended, with buffered data pending | ||
const src = new Readable({ | ||
read() {} | ||
}) | ||
src.push(Buffer.alloc(100)) | ||
src.push(null) | ||
src.pause() | ||
|
||
// Give it time to settle | ||
await new Promise((resolve) => setImmediate(resolve)) | ||
const dst = new Writable({ | ||
highWaterMark: 1000, | ||
write(buf, enc, cb) { | ||
process.nextTick(cb) | ||
} | ||
}) | ||
dst.write(Buffer.alloc(1000)) // Fill write buffer | ||
dst.on('finish', common.mustCall()) | ||
src.pipe(dst) | ||
})().then(common.mustCall()) | ||
|
||
/* replacement start */ | ||
process.on('beforeExit', (code) => { | ||
if (code === 0) { | ||
tap.pass('test succeeded') | ||
} else { | ||
tap.fail(`test failed - exited code ${code}`) | ||
} | ||
}) | ||
/* replacement end */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const silentConsole = { | ||
log() {}, | ||
error() {} | ||
} | ||
const common = require('../common') | ||
const { Readable } = require('../../lib/ours/index') | ||
const assert = require('assert') | ||
{ | ||
const read = new Readable({ | ||
read() {} | ||
}) | ||
read.resume() | ||
read.on('end', common.mustNotCall('no end event')) | ||
read.on('close', common.mustCall()) | ||
read.on( | ||
'error', | ||
common.mustCall((err) => { | ||
assert.strictEqual(err.name, 'AbortError') | ||
}) | ||
) | ||
read[require('../../lib/ours/primordials').SymbolAsyncDispose]().then( | ||
common.mustCall(() => { | ||
assert.strictEqual(read.errored.name, 'AbortError') | ||
assert.strictEqual(read.destroyed, true) | ||
}) | ||
) | ||
} | ||
|
||
/* replacement start */ | ||
process.on('beforeExit', (code) => { | ||
if (code === 0) { | ||
tap.pass('test succeeded') | ||
} else { | ||
tap.fail(`test failed - exited code ${code}`) | ||
} | ||
}) | ||
/* replacement end */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const silentConsole = { | ||
log() {}, | ||
error() {} | ||
} | ||
require('../common') | ||
const assert = require('node:assert') | ||
const { | ||
setDefaultHighWaterMark, | ||
getDefaultHighWaterMark, | ||
Writable, | ||
Readable, | ||
Transform | ||
} = require('../../lib/ours/index') | ||
assert.notStrictEqual(getDefaultHighWaterMark(false), 32 * 1000) | ||
setDefaultHighWaterMark(false, 32 * 1000) | ||
assert.strictEqual(getDefaultHighWaterMark(false), 32 * 1000) | ||
assert.notStrictEqual(getDefaultHighWaterMark(true), 32) | ||
setDefaultHighWaterMark(true, 32) | ||
assert.strictEqual(getDefaultHighWaterMark(true), 32) | ||
const w = new Writable({ | ||
write() {} | ||
}) | ||
assert.strictEqual(w.writableHighWaterMark, 32 * 1000) | ||
const r = new Readable({ | ||
read() {} | ||
}) | ||
assert.strictEqual(r.readableHighWaterMark, 32 * 1000) | ||
const t = new Transform({ | ||
transform() {} | ||
}) | ||
assert.strictEqual(t.writableHighWaterMark, 32 * 1000) | ||
assert.strictEqual(t.readableHighWaterMark, 32 * 1000) | ||
|
||
/* replacement start */ | ||
process.on('beforeExit', (code) => { | ||
if (code === 0) { | ||
tap.pass('test succeeded') | ||
} else { | ||
tap.fail(`test failed - exited code ${code}`) | ||
} | ||
}) | ||
/* replacement end */ |