11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst fs = require('fs');
51cb0ef41Sopenharmony_ciconst path = require('path');
61cb0ef41Sopenharmony_ciconst { promisify } = require('util');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst read = promisify(fs.read);
91cb0ef41Sopenharmony_ciconst write = promisify(fs.write);
101cb0ef41Sopenharmony_ciconst exists = promisify(fs.exists);
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci{
131cb0ef41Sopenharmony_ci  const fd = fs.openSync(__filename, 'r');
141cb0ef41Sopenharmony_ci  read(fd, Buffer.alloc(1024), 0, 1024, null).then(common.mustCall((obj) => {
151cb0ef41Sopenharmony_ci    assert.strictEqual(typeof obj.bytesRead, 'number');
161cb0ef41Sopenharmony_ci    assert(obj.buffer instanceof Buffer);
171cb0ef41Sopenharmony_ci    fs.closeSync(fd);
181cb0ef41Sopenharmony_ci  }));
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
221cb0ef41Sopenharmony_citmpdir.refresh();
231cb0ef41Sopenharmony_ci{
241cb0ef41Sopenharmony_ci  const filename = path.join(tmpdir.path, 'write-promise.txt');
251cb0ef41Sopenharmony_ci  const fd = fs.openSync(filename, 'w');
261cb0ef41Sopenharmony_ci  write(fd, Buffer.from('foobar')).then(common.mustCall((obj) => {
271cb0ef41Sopenharmony_ci    assert.strictEqual(typeof obj.bytesWritten, 'number');
281cb0ef41Sopenharmony_ci    assert.strictEqual(obj.buffer.toString(), 'foobar');
291cb0ef41Sopenharmony_ci    fs.closeSync(fd);
301cb0ef41Sopenharmony_ci  }));
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci{
341cb0ef41Sopenharmony_ci  exists(__filename).then(common.mustCall((x) => {
351cb0ef41Sopenharmony_ci    assert.strictEqual(x, true);
361cb0ef41Sopenharmony_ci  }));
371cb0ef41Sopenharmony_ci}
38