mirror of
https://github.com/denoland/deno.git
synced 2024-12-20 22:34:46 -05:00
fb24fd37c9
This PR enables node compat test cases found passing by using the tool added in #27122 The percentage of passing test case increases from 16.16% to 30.43% by this change.
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
// deno-fmt-ignore-file
|
|
// deno-lint-ignore-file
|
|
|
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
|
// Taken from Node 20.11.1
|
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
|
|
|
'use strict';
|
|
|
|
// Tests that passing a negative offset does not crash the process
|
|
|
|
const common = require('../common');
|
|
|
|
const {
|
|
closeSync,
|
|
open,
|
|
write,
|
|
writeSync,
|
|
} = require('fs');
|
|
|
|
const assert = require('assert');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
const filename = tmpdir.resolve('test.txt');
|
|
|
|
open(filename, 'w+', common.mustSucceed((fd) => {
|
|
assert.throws(() => {
|
|
write(fd, Buffer.alloc(0), -1, common.mustNotCall());
|
|
}, {
|
|
code: 'ERR_OUT_OF_RANGE',
|
|
});
|
|
assert.throws(() => {
|
|
writeSync(fd, Buffer.alloc(0), -1);
|
|
}, {
|
|
code: 'ERR_OUT_OF_RANGE',
|
|
});
|
|
closeSync(fd);
|
|
}));
|
|
|
|
const filename2 = tmpdir.resolve('test2.txt');
|
|
|
|
// Make sure negative length's don't cause aborts either
|
|
|
|
open(filename2, 'w+', common.mustSucceed((fd) => {
|
|
assert.throws(() => {
|
|
write(fd, Buffer.alloc(0), 0, -1, common.mustNotCall());
|
|
}, {
|
|
code: 'ERR_OUT_OF_RANGE',
|
|
});
|
|
assert.throws(() => {
|
|
writeSync(fd, Buffer.alloc(0), 0, -1);
|
|
}, {
|
|
code: 'ERR_OUT_OF_RANGE',
|
|
});
|
|
closeSync(fd);
|
|
}));
|