11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fs = require('fs'); 41cb0ef41Sopenharmony_ciconst path = require('path'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 71cb0ef41Sopenharmony_ciconst file = path.join(tmpdir.path, 'write_stream_filehandle_test.txt'); 81cb0ef41Sopenharmony_ciconst input = 'hello world'; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_citmpdir.refresh(); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cifs.promises.open(file, 'w+').then((handle) => { 131cb0ef41Sopenharmony_ci handle.on('close', common.mustCall()); 141cb0ef41Sopenharmony_ci const stream = fs.createWriteStream(null, { fd: handle }); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci stream.end(input); 171cb0ef41Sopenharmony_ci stream.on('close', common.mustCall(() => { 181cb0ef41Sopenharmony_ci const output = fs.readFileSync(file, 'utf-8'); 191cb0ef41Sopenharmony_ci assert.strictEqual(output, input); 201cb0ef41Sopenharmony_ci })); 211cb0ef41Sopenharmony_ci}).then(common.mustCall()); 22