diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-02-10 13:22:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-10 20:22:13 +0000 |
commit | f5e46c9bf2f50d66a953fa133161fc829cecff06 (patch) | |
tree | 8faf2f5831c1c7b11d842cd9908d141082c869a5 /cli/tests/node_compat/test/parallel/test-stream-uint8array.js | |
parent | d2477f780630a812bfd65e3987b70c0d309385bb (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-uint8array.js')
-rw-r--r-- | cli/tests/node_compat/test/parallel/test-stream-uint8array.js | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-stream-uint8array.js b/cli/tests/node_compat/test/parallel/test-stream-uint8array.js deleted file mode 100644 index c8de2dfe6..000000000 --- a/cli/tests/node_compat/test/parallel/test-stream-uint8array.js +++ /dev/null @@ -1,108 +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, Writable } = require('stream'); - -const ABC = new Uint8Array([0x41, 0x42, 0x43]); -const DEF = new Uint8Array([0x44, 0x45, 0x46]); -const GHI = new Uint8Array([0x47, 0x48, 0x49]); - -{ - // Simple Writable test. - - let n = 0; - const writable = new Writable({ - write: common.mustCall((chunk, encoding, cb) => { - assert(chunk instanceof Buffer); - if (n++ === 0) { - assert.strictEqual(String(chunk), 'ABC'); - } else { - assert.strictEqual(String(chunk), 'DEF'); - } - - cb(); - }, 2) - }); - - writable.write(ABC); - writable.end(DEF); -} - -{ - // Writable test, pass in Uint8Array in object mode. - - const writable = new Writable({ - objectMode: true, - write: common.mustCall((chunk, encoding, cb) => { - assert(!(chunk instanceof Buffer)); - assert(chunk instanceof Uint8Array); - assert.strictEqual(chunk, ABC); - assert.strictEqual(encoding, 'utf8'); - cb(); - }) - }); - - writable.end(ABC); -} - -{ - // Writable test, multiple writes carried out via writev. - let callback; - - const writable = new Writable({ - write: common.mustCall((chunk, encoding, cb) => { - assert(chunk instanceof Buffer); - assert.strictEqual(encoding, 'buffer'); - assert.strictEqual(String(chunk), 'ABC'); - callback = cb; - }), - writev: common.mustCall((chunks, cb) => { - assert.strictEqual(chunks.length, 2); - assert.strictEqual(chunks[0].encoding, 'buffer'); - assert.strictEqual(chunks[1].encoding, 'buffer'); - assert.strictEqual(chunks[0].chunk + chunks[1].chunk, 'DEFGHI'); - }) - }); - - writable.write(ABC); - writable.write(DEF); - writable.end(GHI); - callback(); -} - -{ - // Simple Readable test. - const readable = new Readable({ - read() {} - }); - - readable.push(DEF); - readable.unshift(ABC); - - const buf = readable.read(); - assert(buf instanceof Buffer); - assert.deepStrictEqual([...buf], [...ABC, ...DEF]); -} - -{ - // Readable test, setEncoding. - const readable = new Readable({ - read() {} - }); - - readable.setEncoding('utf8'); - - readable.push(DEF); - readable.unshift(ABC); - - const out = readable.read(); - assert.strictEqual(out, 'ABCDEF'); -} |