11cb0ef41Sopenharmony_ci// Previews in strict mode should indicate ReferenceErrors. 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci'use strict'; 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst common = require('../common'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') { 101cb0ef41Sopenharmony_ci const stream = require('stream'); 111cb0ef41Sopenharmony_ci const repl = require('repl'); 121cb0ef41Sopenharmony_ci class ActionStream extends stream.Stream { 131cb0ef41Sopenharmony_ci readable = true; 141cb0ef41Sopenharmony_ci run(data) { 151cb0ef41Sopenharmony_ci this.emit('data', `${data}`); 161cb0ef41Sopenharmony_ci this.emit('keypress', '', { ctrl: true, name: 'd' }); 171cb0ef41Sopenharmony_ci } 181cb0ef41Sopenharmony_ci resume() {} 191cb0ef41Sopenharmony_ci pause() {} 201cb0ef41Sopenharmony_ci } 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci repl.start({ 231cb0ef41Sopenharmony_ci input: new ActionStream(), 241cb0ef41Sopenharmony_ci output: new stream.Writable({ 251cb0ef41Sopenharmony_ci write(chunk, _, next) { 261cb0ef41Sopenharmony_ci console.log(chunk.toString()); 271cb0ef41Sopenharmony_ci next(); 281cb0ef41Sopenharmony_ci } 291cb0ef41Sopenharmony_ci }), 301cb0ef41Sopenharmony_ci useColors: false, 311cb0ef41Sopenharmony_ci terminal: true 321cb0ef41Sopenharmony_ci }).inputStream.run('xyz'); 331cb0ef41Sopenharmony_ci} else { 341cb0ef41Sopenharmony_ci const assert = require('assert'); 351cb0ef41Sopenharmony_ci const { spawnSync } = require('child_process'); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci const result = spawnSync( 381cb0ef41Sopenharmony_ci process.execPath, 391cb0ef41Sopenharmony_ci ['--use-strict', `${__filename}`, 'child'] 401cb0ef41Sopenharmony_ci ); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci assert.match( 431cb0ef41Sopenharmony_ci result.stdout.toString(), 441cb0ef41Sopenharmony_ci /\/\/ ReferenceError: xyz is not defined/ 451cb0ef41Sopenharmony_ci ); 461cb0ef41Sopenharmony_ci} 47