summaryrefslogtreecommitdiff
path: root/cli/tests/node_compat/test/parallel/test-stream-readable-reading-readingMore.js
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-02-10 13:22:13 -0700
committerGitHub <noreply@github.com>2024-02-10 20:22:13 +0000
commitf5e46c9bf2f50d66a953fa133161fc829cecff06 (patch)
tree8faf2f5831c1c7b11d842cd9908d141082c869a5 /cli/tests/node_compat/test/parallel/test-stream-readable-reading-readingMore.js
parentd2477f780630a812bfd65e3987b70c0d309385bb (diff)
chore: move cli/tests/ -> tests/ (#22369)
This looks like a massive PR, but it's only a move from cli/tests -> tests, and updates of relative paths for files. This is the first step towards aggregate all of the integration test files under tests/, which will lead to a set of integration tests that can run without the CLI binary being built. While we could leave these tests under `cli`, it would require us to keep a more complex directory structure for the various test runners. In addition, we have a lot of complexity to ignore various test files in the `cli` project itself (cargo publish exclusion rules, autotests = false, etc). And finally, the `tests/` folder will eventually house the `test_ffi`, `test_napi` and other testing code, reducing the size of the root repo directory. For easier review, the extremely large and noisy "move" is in the first commit (with no changes -- just a move), while the remainder of the changes to actual files is in the second commit.
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-stream-readable-reading-readingMore.js')
-rw-r--r--cli/tests/node_compat/test/parallel/test-stream-readable-reading-readingMore.js178
1 files changed, 0 insertions, 178 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-stream-readable-reading-readingMore.js b/cli/tests/node_compat/test/parallel/test-stream-readable-reading-readingMore.js
deleted file mode 100644
index 26663b88b..000000000
--- a/cli/tests/node_compat/test/parallel/test-stream-readable-reading-readingMore.js
+++ /dev/null
@@ -1,178 +0,0 @@
-// deno-fmt-ignore-file
-// deno-lint-ignore-file
-
-// Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 18.12.1
-// This file is automatically generated by `tools/node_compat/setup.ts`. Do not modify this file manually.
-
-'use strict';
-const common = require('../common');
-const assert = require('assert');
-const Readable = require('stream').Readable;
-
-{
- const readable = new Readable({
- read(size) {}
- });
-
- const state = readable._readableState;
-
- // Starting off with false initially.
- assert.strictEqual(state.reading, false);
- assert.strictEqual(state.readingMore, false);
-
- readable.on('data', common.mustCall((data) => {
- // While in a flowing state with a 'readable' listener
- // we should not be reading more
- if (readable.readableFlowing)
- assert.strictEqual(state.readingMore, true);
-
- // Reading as long as we've not ended
- assert.strictEqual(state.reading, !state.ended);
- }, 2));
-
- function onStreamEnd() {
- // End of stream; state.reading is false
- // And so should be readingMore.
- assert.strictEqual(state.readingMore, false);
- assert.strictEqual(state.reading, false);
- }
-
- const expectedReadingMore = [true, true, false];
- readable.on('readable', common.mustCall(() => {
- // There is only one readingMore scheduled from on('data'),
- // after which everything is governed by the .read() call
- assert.strictEqual(state.readingMore, expectedReadingMore.shift());
-
- // If the stream has ended, we shouldn't be reading
- assert.strictEqual(state.ended, !state.reading);
-
- // Consume all the data
- while (readable.read() !== null);
-
- if (expectedReadingMore.length === 0) // Reached end of stream
- process.nextTick(common.mustCall(onStreamEnd, 1));
- }, 3));
-
- readable.on('end', common.mustCall(onStreamEnd));
- readable.push('pushed');
-
- readable.read(6);
-
- // reading
- assert.strictEqual(state.reading, true);
- assert.strictEqual(state.readingMore, true);
-
- // add chunk to front
- readable.unshift('unshifted');
-
- // end
- readable.push(null);
-}
-
-{
- const readable = new Readable({
- read(size) {}
- });
-
- const state = readable._readableState;
-
- // Starting off with false initially.
- assert.strictEqual(state.reading, false);
- assert.strictEqual(state.readingMore, false);
-
- readable.on('data', common.mustCall((data) => {
- // While in a flowing state without a 'readable' listener
- // we should be reading more
- if (readable.readableFlowing)
- assert.strictEqual(state.readingMore, true);
-
- // Reading as long as we've not ended
- assert.strictEqual(state.reading, !state.ended);
- }, 2));
-
- function onStreamEnd() {
- // End of stream; state.reading is false
- // And so should be readingMore.
- assert.strictEqual(state.readingMore, false);
- assert.strictEqual(state.reading, false);
- }
-
- readable.on('end', common.mustCall(onStreamEnd));
- readable.push('pushed');
-
- // Stop emitting 'data' events
- assert.strictEqual(state.flowing, true);
- readable.pause();
-
- // paused
- assert.strictEqual(state.reading, false);
- assert.strictEqual(state.flowing, false);
-
- readable.resume();
- assert.strictEqual(state.reading, false);
- assert.strictEqual(state.flowing, true);
-
- // add chunk to front
- readable.unshift('unshifted');
-
- // end
- readable.push(null);
-}
-
-{
- const readable = new Readable({
- read(size) {}
- });
-
- const state = readable._readableState;
-
- // Starting off with false initially.
- assert.strictEqual(state.reading, false);
- assert.strictEqual(state.readingMore, false);
-
- const onReadable = common.mustNotCall();
-
- readable.on('readable', onReadable);
-
- readable.on('data', common.mustCall((data) => {
- // Reading as long as we've not ended
- assert.strictEqual(state.reading, !state.ended);
- }, 2));
-
- readable.removeListener('readable', onReadable);
-
- function onStreamEnd() {
- // End of stream; state.reading is false
- // And so should be readingMore.
- assert.strictEqual(state.readingMore, false);
- assert.strictEqual(state.reading, false);
- }
-
- readable.on('end', common.mustCall(onStreamEnd));
- readable.push('pushed');
-
- // We are still not flowing, we will be resuming in the next tick
- assert.strictEqual(state.flowing, false);
-
- // Wait for nextTick, so the readableListener flag resets
- process.nextTick(function() {
- readable.resume();
-
- // Stop emitting 'data' events
- assert.strictEqual(state.flowing, true);
- readable.pause();
-
- // paused
- assert.strictEqual(state.flowing, false);
-
- readable.resume();
- assert.strictEqual(state.flowing, true);
-
- // add chunk to front
- readable.unshift('unshifted');
-
- // end
- readable.push(null);
- });
-}