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-buffer-compare-offset.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-buffer-compare-offset.js')
-rw-r--r-- | cli/tests/node_compat/test/parallel/test-buffer-compare-offset.js | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-buffer-compare-offset.js b/cli/tests/node_compat/test/parallel/test-buffer-compare-offset.js deleted file mode 100644 index bb7ba2998..000000000 --- a/cli/tests/node_compat/test/parallel/test-buffer-compare-offset.js +++ /dev/null @@ -1,101 +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'; - -require('../common'); -const assert = require('assert'); - -const a = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]); -const b = Buffer.from([5, 6, 7, 8, 9, 0, 1, 2, 3, 4]); - -assert.strictEqual(a.compare(b), -1); - -// Equivalent to a.compare(b). -assert.strictEqual(a.compare(b, 0), -1); -assert.throws(() => a.compare(b, '0'), { code: 'ERR_INVALID_ARG_TYPE' }); -assert.strictEqual(a.compare(b, undefined), -1); - -// Equivalent to a.compare(b). -assert.strictEqual(a.compare(b, 0, undefined, 0), -1); - -// Zero-length target, return 1 -assert.strictEqual(a.compare(b, 0, 0, 0), 1); -assert.throws( - () => a.compare(b, 0, '0', '0'), - { code: 'ERR_INVALID_ARG_TYPE' } -); - -// Equivalent to Buffer.compare(a, b.slice(6, 10)) -assert.strictEqual(a.compare(b, 6, 10), 1); - -// Zero-length source, return -1 -assert.strictEqual(a.compare(b, 6, 10, 0, 0), -1); - -// Zero-length source and target, return 0 -assert.strictEqual(a.compare(b, 0, 0, 0, 0), 0); -assert.strictEqual(a.compare(b, 1, 1, 2, 2), 0); - -// Equivalent to Buffer.compare(a.slice(4), b.slice(0, 5)) -assert.strictEqual(a.compare(b, 0, 5, 4), 1); - -// Equivalent to Buffer.compare(a.slice(1), b.slice(5)) -assert.strictEqual(a.compare(b, 5, undefined, 1), 1); - -// Equivalent to Buffer.compare(a.slice(2), b.slice(2, 4)) -assert.strictEqual(a.compare(b, 2, 4, 2), -1); - -// Equivalent to Buffer.compare(a.slice(4), b.slice(0, 7)) -assert.strictEqual(a.compare(b, 0, 7, 4), -1); - -// Equivalent to Buffer.compare(a.slice(4, 6), b.slice(0, 7)); -assert.strictEqual(a.compare(b, 0, 7, 4, 6), -1); - -// Null is ambiguous. -assert.throws( - () => a.compare(b, 0, null), - { code: 'ERR_INVALID_ARG_TYPE' } -); - -// Values do not get coerced. -assert.throws( - () => a.compare(b, 0, { valueOf: () => 5 }), - { code: 'ERR_INVALID_ARG_TYPE' } -); - -// Infinity should not be coerced. -assert.throws( - () => a.compare(b, Infinity, -Infinity), - { code: 'ERR_OUT_OF_RANGE' } -); - -// Zero length target because default for targetEnd <= targetSource -assert.strictEqual(a.compare(b, 0xff), 1); - -assert.throws( - () => a.compare(b, '0xff'), - { code: 'ERR_INVALID_ARG_TYPE' } -); -assert.throws( - () => a.compare(b, 0, '0xff'), - { code: 'ERR_INVALID_ARG_TYPE' } -); - -const oor = { code: 'ERR_OUT_OF_RANGE' }; - -assert.throws(() => a.compare(b, 0, 100, 0), oor); -assert.throws(() => a.compare(b, 0, 1, 0, 100), oor); -assert.throws(() => a.compare(b, -1), oor); -assert.throws(() => a.compare(b, 0, Infinity), oor); -assert.throws(() => a.compare(b, 0, 1, -1), oor); -assert.throws(() => a.compare(b, -Infinity, Infinity), oor); -assert.throws(() => a.compare(), { - code: 'ERR_INVALID_ARG_TYPE', - name: 'TypeError', - message: 'The "target" argument must be an instance of ' + - 'Buffer or Uint8Array. Received undefined' -}); |