• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const cp = require('child_process');
5const child = cp.spawn(process.execPath, ['--interactive']);
6const fixtures = require('../common/fixtures');
7const fixture = fixtures.path('is-object.js').replace(/\\/g, '/');
8let output = '';
9
10child.stdout.setEncoding('utf8');
11child.stdout.on('data', (data) => {
12  output += data;
13});
14
15child.on('exit', common.mustCall(() => {
16  const results = output.replace(/^> /mg, '').split('\n').slice(2);
17  assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
18}));
19
20child.stdin.write('const isObject = (obj) => obj.constructor === Object;\n');
21child.stdin.write('isObject({});\n');
22child.stdin.write(`require(${JSON.stringify(fixture)}).isObject({});\n`);
23child.stdin.write('.exit');
24child.stdin.end();
25