mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
384f5d44a8
Some tests are assuming they will be run from a directory that do not contain any quote or special character in its path. That assumption is not necessary, using `JSON.stringify` or `pathToFileURL` ensures the test can be run whatever the path looks like. PR-URL: https://github.com/nodejs/node/pull/48958 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Michaël Zasso <targos@protonmail.com>
25 lines
831 B
JavaScript
25 lines
831 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cp = require('child_process');
|
|
const child = cp.spawn(process.execPath, ['--interactive']);
|
|
const fixtures = require('../common/fixtures');
|
|
const fixture = fixtures.path('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.replace(/^> /mg, '').split('\n').slice(2);
|
|
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(${JSON.stringify(fixture)}).isObject({});\n`);
|
|
child.stdin.write('.exit');
|
|
child.stdin.end();
|