• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../common');
3
4// This test ensures that writeSync does support inputs which
5// are then correctly converted into string buffers.
6
7const assert = require('assert');
8const fs = require('fs');
9const path = require('path');
10
11const tmpdir = require('../common/tmpdir');
12
13const filePath = path.join(tmpdir.path, 'test_buffer_type');
14const v = [true, false, 0, 1, Infinity, () => {}, {}, [], undefined, null];
15
16tmpdir.refresh();
17
18v.forEach((value) => {
19  const fd = fs.openSync(filePath, 'w');
20  fs.writeSync(fd, value);
21  assert.strictEqual(fs.readFileSync(filePath).toString(), String(value));
22});
23