11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst fs = require('fs'); 61cb0ef41Sopenharmony_ciconst path = require('path'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 91cb0ef41Sopenharmony_citmpdir.refresh(); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci{ 121cb0ef41Sopenharmony_ci const s = fs.createWriteStream(path.join(tmpdir.path, 'rw')); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci s.close(common.mustCall()); 151cb0ef41Sopenharmony_ci s.close(common.mustCall()); 161cb0ef41Sopenharmony_ci} 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci{ 191cb0ef41Sopenharmony_ci const s = fs.createWriteStream(path.join(tmpdir.path, 'rw2')); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci let emits = 0; 221cb0ef41Sopenharmony_ci s.on('close', () => { 231cb0ef41Sopenharmony_ci emits++; 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci s.close(common.mustCall(() => { 271cb0ef41Sopenharmony_ci assert.strictEqual(emits, 1); 281cb0ef41Sopenharmony_ci s.close(common.mustCall(() => { 291cb0ef41Sopenharmony_ci assert.strictEqual(emits, 1); 301cb0ef41Sopenharmony_ci })); 311cb0ef41Sopenharmony_ci process.nextTick(() => { 321cb0ef41Sopenharmony_ci s.close(common.mustCall(() => { 331cb0ef41Sopenharmony_ci assert.strictEqual(emits, 1); 341cb0ef41Sopenharmony_ci })); 351cb0ef41Sopenharmony_ci }); 361cb0ef41Sopenharmony_ci })); 371cb0ef41Sopenharmony_ci} 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci{ 401cb0ef41Sopenharmony_ci const s = fs.createWriteStream(path.join(tmpdir.path, 'rw'), { 411cb0ef41Sopenharmony_ci autoClose: false 421cb0ef41Sopenharmony_ci }); 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci s.close(common.mustCall()); 451cb0ef41Sopenharmony_ci s.close(common.mustCall()); 461cb0ef41Sopenharmony_ci} 47