diff --git a/test/parallel/test-fs-buffertype-writesync.js b/test/parallel/test-fs-buffertype-writesync.js new file mode 100644 index 00000000000000..0c8bf4b0fcf811 --- /dev/null +++ b/test/parallel/test-fs-buffertype-writesync.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); + +// This test ensures that writeSync does support inputs which +// are then correctly converted into string buffers. + +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); + +const filePath = path.join(common.tmpDir, 'test_buffer_type'); +const v = [true, false, 0, 1, Infinity, common.noop, {}, [], undefined, null]; + +common.refreshTmpDir(); + +v.forEach((value) => { + const fd = fs.openSync(filePath, 'w'); + fs.writeSync(fd, value); + assert.strictEqual(fs.readFileSync(filePath).toString(), value + ''); +});