summaryrefslogtreecommitdiff
path: root/cli/tests/node_compat/test/parallel/test-buffer-readfloat.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-buffer-readfloat.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-buffer-readfloat.js')
-rw-r--r--cli/tests/node_compat/test/parallel/test-buffer-readfloat.js113
1 files changed, 0 insertions, 113 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-buffer-readfloat.js b/cli/tests/node_compat/test/parallel/test-buffer-readfloat.js
deleted file mode 100644
index 780d3a6ac..000000000
--- a/cli/tests/node_compat/test/parallel/test-buffer-readfloat.js
+++ /dev/null
@@ -1,113 +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');
-
-// Test 32 bit float
-const buffer = Buffer.alloc(4);
-
-buffer[0] = 0;
-buffer[1] = 0;
-buffer[2] = 0x80;
-buffer[3] = 0x3f;
-assert.strictEqual(buffer.readFloatBE(0), 4.600602988224807e-41);
-assert.strictEqual(buffer.readFloatLE(0), 1);
-
-buffer[0] = 0;
-buffer[1] = 0;
-buffer[2] = 0;
-buffer[3] = 0xc0;
-assert.strictEqual(buffer.readFloatBE(0), 2.6904930515036488e-43);
-assert.strictEqual(buffer.readFloatLE(0), -2);
-
-buffer[0] = 0xff;
-buffer[1] = 0xff;
-buffer[2] = 0x7f;
-buffer[3] = 0x7f;
-assert.ok(Number.isNaN(buffer.readFloatBE(0)));
-assert.strictEqual(buffer.readFloatLE(0), 3.4028234663852886e+38);
-
-buffer[0] = 0xab;
-buffer[1] = 0xaa;
-buffer[2] = 0xaa;
-buffer[3] = 0x3e;
-assert.strictEqual(buffer.readFloatBE(0), -1.2126478207002966e-12);
-assert.strictEqual(buffer.readFloatLE(0), 0.3333333432674408);
-
-buffer[0] = 0;
-buffer[1] = 0;
-buffer[2] = 0;
-buffer[3] = 0;
-assert.strictEqual(buffer.readFloatBE(0), 0);
-assert.strictEqual(buffer.readFloatLE(0), 0);
-assert.ok(1 / buffer.readFloatLE(0) >= 0);
-
-buffer[3] = 0x80;
-assert.strictEqual(buffer.readFloatBE(0), 1.793662034335766e-43);
-assert.strictEqual(buffer.readFloatLE(0), -0);
-assert.ok(1 / buffer.readFloatLE(0) < 0);
-
-buffer[0] = 0;
-buffer[1] = 0;
-buffer[2] = 0x80;
-buffer[3] = 0x7f;
-assert.strictEqual(buffer.readFloatBE(0), 4.609571298396486e-41);
-assert.strictEqual(buffer.readFloatLE(0), Infinity);
-
-buffer[0] = 0;
-buffer[1] = 0;
-buffer[2] = 0x80;
-buffer[3] = 0xff;
-assert.strictEqual(buffer.readFloatBE(0), 4.627507918739843e-41);
-assert.strictEqual(buffer.readFloatLE(0), -Infinity);
-
-['readFloatLE', 'readFloatBE'].forEach((fn) => {
-
- // Verify that default offset works fine.
- buffer[fn](undefined);
- buffer[fn]();
-
- ['', '0', null, {}, [], () => {}, true, false].forEach((off) => {
- assert.throws(
- () => buffer[fn](off),
- { code: 'ERR_INVALID_ARG_TYPE' }
- );
- });
-
- [Infinity, -1, 1].forEach((offset) => {
- assert.throws(
- () => buffer[fn](offset),
- {
- code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError',
- message: 'The value of "offset" is out of range. ' +
- `It must be >= 0 and <= 0. Received ${offset}`
- });
- });
-
- assert.throws(
- () => Buffer.alloc(1)[fn](1),
- {
- code: 'ERR_BUFFER_OUT_OF_BOUNDS',
- name: 'RangeError',
- message: 'Attempt to access memory outside buffer bounds'
- });
-
- [NaN, 1.01].forEach((offset) => {
- assert.throws(
- () => buffer[fn](offset),
- {
- code: 'ERR_OUT_OF_RANGE',
- name: 'RangeError',
- message: 'The value of "offset" is out of range. ' +
- `It must be an integer. Received ${offset}`
- });
- });
-});