forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-stream-readable-dispose.js
More file actions
38 lines (32 loc) · 985 Bytes
/
Copy pathtest-stream-readable-dispose.js
File metadata and controls
38 lines (32 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const common = require('../common');
const { Readable } = require('stream');
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[Symbol.asyncDispose]().then(common.mustCall(() => {
assert.strictEqual(read.errored.name, 'AbortError');
assert.strictEqual(read.destroyed, true);
}));
}
(async () => {
await using read = new Readable({
read() {}
});
read.resume();
read.on('end', common.mustNotCall('no end event'));
read.on('close', common.mustCall());
read.on('error', common.mustCall(function(err) {
assert.strictEqual(err.name, 'AbortError');
assert.strictEqual(this.errored.name, 'AbortError');
assert.strictEqual(this.destroyed, true);
}));
})().then(common.mustCall());