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-writedouble.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-writedouble.js')
-rw-r--r-- | cli/tests/node_compat/test/parallel/test-buffer-writedouble.js | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-buffer-writedouble.js b/cli/tests/node_compat/test/parallel/test-buffer-writedouble.js deleted file mode 100644 index 3e4d4e676..000000000 --- a/cli/tests/node_compat/test/parallel/test-buffer-writedouble.js +++ /dev/null @@ -1,140 +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'; - -// Tests to verify doubles are correctly written - -require('../common'); -const assert = require('assert'); - -const buffer = Buffer.allocUnsafe(16); - -buffer.writeDoubleBE(2.225073858507201e-308, 0); -buffer.writeDoubleLE(2.225073858507201e-308, 8); -assert.ok(buffer.equals(new Uint8Array([ - 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, -]))); - -buffer.writeDoubleBE(1.0000000000000004, 0); -buffer.writeDoubleLE(1.0000000000000004, 8); -assert.ok(buffer.equals(new Uint8Array([ - 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, -]))); - -buffer.writeDoubleBE(-2, 0); -buffer.writeDoubleLE(-2, 8); -assert.ok(buffer.equals(new Uint8Array([ - 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, -]))); - -buffer.writeDoubleBE(1.7976931348623157e+308, 0); -buffer.writeDoubleLE(1.7976931348623157e+308, 8); -assert.ok(buffer.equals(new Uint8Array([ - 0x7f, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0x7f, -]))); - -buffer.writeDoubleBE(0 * -1, 0); -buffer.writeDoubleLE(0 * -1, 8); -assert.ok(buffer.equals(new Uint8Array([ - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, -]))); - -buffer.writeDoubleBE(Infinity, 0); -buffer.writeDoubleLE(Infinity, 8); - -assert.ok(buffer.equals(new Uint8Array([ - 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F, -]))); - -assert.strictEqual(buffer.readDoubleBE(0), Infinity); -assert.strictEqual(buffer.readDoubleLE(8), Infinity); - -buffer.writeDoubleBE(-Infinity, 0); -buffer.writeDoubleLE(-Infinity, 8); - -assert.ok(buffer.equals(new Uint8Array([ - 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, -]))); - -assert.strictEqual(buffer.readDoubleBE(0), -Infinity); -assert.strictEqual(buffer.readDoubleLE(8), -Infinity); - -buffer.writeDoubleBE(NaN, 0); -buffer.writeDoubleLE(NaN, 8); - -// JS only knows a single NaN but there exist two platform specific -// implementations. Therefore, allow both quiet and signalling NaNs. -if (buffer[1] === 0xF7) { - assert.ok(buffer.equals(new Uint8Array([ - 0x7F, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x7F, - ]))); -} else { - assert.ok(buffer.equals(new Uint8Array([ - 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7F, - ]))); -} - -assert.ok(Number.isNaN(buffer.readDoubleBE(0))); -assert.ok(Number.isNaN(buffer.readDoubleLE(8))); - -// OOB in writeDouble{LE,BE} should throw. -{ - const small = Buffer.allocUnsafe(1); - - ['writeDoubleLE', 'writeDoubleBE'].forEach((fn) => { - - // Verify that default offset works fine. - buffer[fn](23, undefined); - buffer[fn](23); - - assert.throws( - () => small[fn](11.11, 0), - { - code: 'ERR_BUFFER_OUT_OF_BOUNDS', - name: 'RangeError', - message: 'Attempt to access memory outside buffer bounds' - }); - - ['', '0', null, {}, [], () => {}, true, false].forEach((off) => { - assert.throws( - () => small[fn](23, off), - { code: 'ERR_INVALID_ARG_TYPE' }); - }); - - [Infinity, -1, 9].forEach((offset) => { - assert.throws( - () => buffer[fn](23, offset), - { - code: 'ERR_OUT_OF_RANGE', - name: 'RangeError', - message: 'The value of "offset" is out of range. ' + - `It must be >= 0 and <= 8. Received ${offset}` - }); - }); - - [NaN, 1.01].forEach((offset) => { - assert.throws( - () => buffer[fn](42, offset), - { - code: 'ERR_OUT_OF_RANGE', - name: 'RangeError', - message: 'The value of "offset" is out of range. ' + - `It must be an integer. Received ${offset}` - }); - }); - }); -} |