|
2 | 2 | 'use strict';
|
3 | 3 |
|
4 | 4 | const common = require('../common');
|
| 5 | +const { isDisturbed } = require('stream'); |
5 | 6 | const assert = require('assert');
|
6 | 7 | const {
|
7 | 8 | isPromise,
|
@@ -1520,3 +1521,52 @@ class Source {
|
1520 | 1521 | readableByteStreamControllerClose(controller);
|
1521 | 1522 | readableByteStreamControllerEnqueue(controller);
|
1522 | 1523 | }
|
| 1524 | + |
| 1525 | +{ |
| 1526 | + const stream = new ReadableStream({ |
| 1527 | + start(controller) { |
| 1528 | + controller.enqueue('a'); |
| 1529 | + controller.close(); |
| 1530 | + }, |
| 1531 | + pull: common.mustNotCall(), |
| 1532 | + }); |
| 1533 | + |
| 1534 | + const reader = stream.getReader(); |
| 1535 | + (async () => { |
| 1536 | + isDisturbed(stream, false); |
| 1537 | + await reader.read(); |
| 1538 | + isDisturbed(stream, true); |
| 1539 | + })().then(common.mustCall()); |
| 1540 | +} |
| 1541 | + |
| 1542 | +{ |
| 1543 | + const stream = new ReadableStream({ |
| 1544 | + start(controller) { |
| 1545 | + controller.close(); |
| 1546 | + }, |
| 1547 | + pull: common.mustNotCall(), |
| 1548 | + }); |
| 1549 | + |
| 1550 | + const reader = stream.getReader(); |
| 1551 | + (async () => { |
| 1552 | + isDisturbed(stream, false); |
| 1553 | + await reader.read(); |
| 1554 | + isDisturbed(stream, true); |
| 1555 | + })().then(common.mustCall()); |
| 1556 | +} |
| 1557 | + |
| 1558 | +{ |
| 1559 | + const stream = new ReadableStream({ |
| 1560 | + start(controller) { |
| 1561 | + }, |
| 1562 | + pull: common.mustNotCall(), |
| 1563 | + }); |
| 1564 | + stream.cancel(); |
| 1565 | + |
| 1566 | + const reader = stream.getReader(); |
| 1567 | + (async () => { |
| 1568 | + isDisturbed(stream, false); |
| 1569 | + await reader.read(); |
| 1570 | + isDisturbed(stream, true); |
| 1571 | + })().then(common.mustCall()); |
| 1572 | +} |
0 commit comments