mirror of https://github.com/lukechilds/node.git
Browse Source
* test calling truncateSync() passing a file descriptor * test calling truncate() passing undefined as the 2nd argument Refs: https://coverage.nodejs.org/coverage-8ab561b2432bdae3/root/fs.js.html (line 673 and 692) PR-URL: https://github.com/nodejs/node/pull/10972 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>v7.x
Vinícius do Carmo
8 years ago
committed by
Italo A. Casas
2 changed files with 31 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||
'use strict'; |
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const path = require('path'); |
|||
const fs = require('fs'); |
|||
const tmp = common.tmpDir; |
|||
|
|||
common.refreshTmpDir(); |
|||
|
|||
const filename = path.resolve(tmp, 'truncate-sync-file.txt'); |
|||
|
|||
fs.writeFileSync(filename, 'hello world', 'utf8'); |
|||
|
|||
const fd = fs.openSync(filename, 'r+'); |
|||
|
|||
fs.truncateSync(fd, 5); |
|||
assert(fs.readFileSync(fd).equals(Buffer.from('hello'))); |
|||
|
|||
fs.closeSync(fd); |
|||
fs.unlinkSync(filename); |
Loading…
Reference in new issue