node/test/parallel/test-fs-write-no-fd.js
Sakthipriyan Vairamani c86c1eeab5 fs: validate args of truncate functions in js
This patch

 1. moves the basic validation of arguments to `truncate` family
    of functions to the JavaScript layer from the C++ layer.

 2. makes sure that the File Descriptors are validated strictly.

PR-URL: https://github.com/nodejs/node/pull/2498
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-07-22 03:58:33 +05:30

14 lines
390 B
JavaScript

'use strict';
require('../common');
const fs = require('fs');
const assert = require('assert');
assert.throws(function() {
fs.write(null, Buffer.allocUnsafe(1), 0, 1, () => {});
}, /TypeError: file descriptor must be a unsigned 32-bit integer/);
assert.throws(function() {
fs.write(undefined, '1', 0, 1, () => {});
}, /TypeError: file descriptor must be a unsigned 32-bit integer/);