11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// This test checks that the `stop` event is emitted asynchronously. 51cb0ef41Sopenharmony_ci// 61cb0ef41Sopenharmony_ci// If it isn't asynchronous, then the listener will be called during the 71cb0ef41Sopenharmony_ci// execution of `watch.stop()`. That would be a bug. 81cb0ef41Sopenharmony_ci// 91cb0ef41Sopenharmony_ci// If it is asynchronous, then the listener will be removed before the event is 101cb0ef41Sopenharmony_ci// emitted. 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst fs = require('fs'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst listener = common.mustNotCall( 151cb0ef41Sopenharmony_ci 'listener should have been removed before the event was emitted' 161cb0ef41Sopenharmony_ci); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciconst watch = fs.watchFile(__filename, common.mustNotCall()); 191cb0ef41Sopenharmony_ciwatch.once('stop', listener); 201cb0ef41Sopenharmony_ciwatch.stop(); 211cb0ef41Sopenharmony_ciwatch.removeListener('stop', listener); 22