diff options
author | Myles Borins <mborins@us.ibm.com> | 2016-07-22 16:37:54 -0700 |
---|---|---|
committer | Myles Borins <myles.borins@gmail.com> | 2016-08-04 09:37:17 -0700 |
commit | c5a18e748d8e78417f6e639baab4085fc446cdc6 (patch) | |
tree | 394890f843bcbcb0f88ab3f9a0db42f3e01d0fff /test/parallel/test-fs-truncate.js | |
parent | 320f433dcdb411da22d8ee9427bbdf5b071faca2 (diff) | |
download | android-node-v8-c5a18e748d8e78417f6e639baab4085fc446cdc6.tar.gz android-node-v8-c5a18e748d8e78417f6e639baab4085fc446cdc6.tar.bz2 android-node-v8-c5a18e748d8e78417f6e639baab4085fc446cdc6.zip |
Revert "fs: validate args of truncate functions in js"
This reverts commit c86c1eeab56df8a627d3d8da27008221ee295d33.
original commit message:
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: #2498
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/7950
Reviewed-By: Julien Gilli <jgilli@nodejs.org>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-fs-truncate.js')
-rw-r--r-- | test/parallel/test-fs-truncate.js | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/test/parallel/test-fs-truncate.js b/test/parallel/test-fs-truncate.js index be986937b3..ab0148a246 100644 --- a/test/parallel/test-fs-truncate.js +++ b/test/parallel/test-fs-truncate.js @@ -24,55 +24,6 @@ fs.truncateSync(filename); stat = fs.statSync(filename); assert.equal(stat.size, 0); -// path must be a string -assert.throws(function() { - fs.truncateSync({}); -}, /path must be a string/); - -assert.throws(function() { - fs.truncateSync([]); -}, /path must be a string/); - -// Even invalid file descriptors are not allowed -assert.throws(function() { - fs.truncateSync(-1); -}, /path must be a string/); - -assert.throws(function() { - fs.truncateSync(NaN); -}, /path must be a string/); - -assert.throws(function() { - fs.truncateSync(Infinity); -}, /path must be a string/); - -// Invalid lengths will also fail -assert.throws(function() { - fs.truncateSync('', ''); -}, /length must be a positive integer/); - -assert.throws(function() { - fs.truncateSync('', -1); -}, /length must be a positive integer/); - -assert.throws(function() { - fs.truncateSync('', NaN); -}, /length must be a positive integer/); - -assert.throws(function() { - fs.truncateSync('', Infinity); -}, /length must be a positive integer/); - -// null is a special case which will also be treated as zero length -fs.writeFileSync(filename, data); - -stat = fs.statSync(filename); -assert.equal(stat.size, 1024 * 16); - -fs.truncateSync(filename, null); -stat = fs.statSync(filename); -assert.equal(stat.size, 0); - // ftruncateSync fs.writeFileSync(filename, data); var fd = fs.openSync(filename, 'r+'); @@ -90,51 +41,6 @@ assert.equal(stat.size, 0); fs.closeSync(fd); -// file descriptor must be a unsigned 32-bit integer -assert.throws(function() { - fs.ftruncateSync({}); -}, /file descriptor must be a unsigned 32-bit integer/); - -// Even invalid file descriptors are not allowed -assert.throws(function() { - fs.ftruncateSync(-1); -}, /file descriptor must be a unsigned 32-bit integer/); - -assert.throws(function() { - fs.ftruncateSync(NaN); -}, /file descriptor must be a unsigned 32-bit integer/); - -assert.throws(function() { - fs.ftruncateSync(Infinity); -}, /file descriptor must be a unsigned 32-bit integer/); - -// Invalid lengths will also fail -assert.throws(function() { - fs.ftruncateSync(1, ''); -}, /length must be a positive integer/); - -assert.throws(function() { - fs.ftruncateSync(1, -1); -}, /length must be a positive integer/); - -assert.throws(function() { - fs.ftruncateSync(1, NaN); -}, /length must be a positive integer/); - -assert.throws(function() { - fs.ftruncateSync(1, Infinity); -}, /length must be a positive integer/); - -// null is a special case which will also be treated as zero length -fs.writeFileSync(filename, data); -fd = fs.openSync(filename, 'r+'); - -fs.ftruncateSync(fd, null); -stat = fs.statSync(filename); -assert.equal(stat.size, 0); - -fs.closeSync(fd); - // async tests testTruncate(common.mustCall(function(er) { if (er) throw er; |