11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst fs = require('fs'); 71cb0ef41Sopenharmony_ciconst path = require('path'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 101cb0ef41Sopenharmony_citmpdir.refresh(); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cifs.access(Buffer.from(tmpdir.path), common.mustSucceed()); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst buf = Buffer.from(path.join(tmpdir.path, 'a.txt')); 151cb0ef41Sopenharmony_cifs.open(buf, 'w+', common.mustSucceed((fd) => { 161cb0ef41Sopenharmony_ci assert(fd); 171cb0ef41Sopenharmony_ci fs.close(fd, common.mustSucceed()); 181cb0ef41Sopenharmony_ci})); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciassert.throws( 211cb0ef41Sopenharmony_ci () => { 221cb0ef41Sopenharmony_ci fs.accessSync(true); 231cb0ef41Sopenharmony_ci }, 241cb0ef41Sopenharmony_ci { 251cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 261cb0ef41Sopenharmony_ci name: 'TypeError', 271cb0ef41Sopenharmony_ci message: 'The "path" argument must be of type string or an instance of ' + 281cb0ef41Sopenharmony_ci 'Buffer or URL. Received type boolean (true)' 291cb0ef41Sopenharmony_ci } 301cb0ef41Sopenharmony_ci); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ciconst dir = Buffer.from(fixtures.fixturesDir); 331cb0ef41Sopenharmony_cifs.readdir(dir, 'hex', common.mustSucceed((hexList) => { 341cb0ef41Sopenharmony_ci fs.readdir(dir, common.mustSucceed((stringList) => { 351cb0ef41Sopenharmony_ci stringList.forEach((val, idx) => { 361cb0ef41Sopenharmony_ci const fromHexList = Buffer.from(hexList[idx], 'hex').toString(); 371cb0ef41Sopenharmony_ci assert.strictEqual( 381cb0ef41Sopenharmony_ci fromHexList, 391cb0ef41Sopenharmony_ci val, 401cb0ef41Sopenharmony_ci `expected ${val}, got ${fromHexList} by hex decoding ${hexList[idx]}` 411cb0ef41Sopenharmony_ci ); 421cb0ef41Sopenharmony_ci }); 431cb0ef41Sopenharmony_ci })); 441cb0ef41Sopenharmony_ci})); 45