1'use strict'; 2// Refs: https://github.com/nodejs/node/issues/7788 3const common = require('../common'); 4const assert = require('assert'); 5const path = require('../common/fixtures').path; 6const repl = require('repl'); 7const stream = require('stream'); 8const inputStream = new stream.PassThrough(); 9const outputStream = new stream.PassThrough(); 10const fixture = path('is-object.js'); 11const r = repl.start({ 12 input: inputStream, 13 output: outputStream, 14 useGlobal: false 15}); 16 17let output = ''; 18outputStream.setEncoding('utf8'); 19outputStream.on('data', (data) => output += data); 20 21r.on('exit', common.mustCall(() => { 22 const results = output.replace(/^> /mg, '').split('\n'); 23 24 assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']); 25})); 26 27inputStream.write('const isObject = (obj) => obj.constructor === Object;\n'); 28inputStream.write('isObject({});\n'); 29inputStream.write(`require('${fixture}').isObject({});\n`); 30r.close(); 31