You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
924 B

'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const path = require('path');
const child = cp.spawn(process.execPath, ['--interactive']);
const fixture = path.join(common.fixturesDir, 'is-object.js').replace(/\\/g,
'/');
let output = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', (data) => {
output += data;
});
child.on('exit', common.mustCall(() => {
const results = output.split('\n').map((line) => {
return line.replace(/\w*>\w*/, '').trim();
});
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
}));
child.stdin.write('const isObject = (obj) => obj.constructor === Object;\n');
child.stdin.write('isObject({});\n');
child.stdin.write(`require('${fixture}').isObject({});\n`);
child.stdin.write('.exit');
child.stdin.end();