Skip to content

Commit 9a44c8c

Browse files
cjihrigrvagg
authored andcommitted
test: add batch of known issue tests
This commit adds tests for several known issues. Refs: #1901 Refs: #728 Refs: #4778 Refs: #947 Refs: #2734 PR-URL: #5653 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent f7aecd6 commit 9a44c8c

5 files changed

+87
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/1901
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const cp = require('child_process');
6+
const unicode = '中文测试'; // Length = 4, Byte length = 13
7+
8+
if (process.argv[2] === 'child') {
9+
console.log(unicode);
10+
} else {
11+
const cmd = `${process.execPath} ${__filename} child`;
12+
13+
cp.exec(cmd, { maxBuffer: 10 }, common.mustCall((err, stdout, stderr) => {
14+
assert.strictEqual(err.message, 'stdout maxBuffer exceeded');
15+
}));
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/728
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const EventEmitter = require('events');
6+
const ee = new EventEmitter();
7+
8+
ee.on('__proto__', common.mustCall((data) => {
9+
assert.strictEqual(data, 42);
10+
}));
11+
12+
ee.emit('__proto__', 42);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/4778
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const fs = require('fs');
6+
const path = require('path');
7+
const file = path.join(common.tmpDir, 'test-extensions.foo.bar');
8+
9+
common.refreshTmpDir();
10+
fs.writeFileSync(file, '', 'utf8');
11+
require.extensions['.foo.bar'] = (module, path) => {};
12+
delete require.extensions['.foo.bar'];
13+
require.extensions['.bar'] = common.mustCall((module, path) => {
14+
assert.strictEqual(module.id, file);
15+
assert.strictEqual(path, file);
16+
});
17+
require(path.join(common.tmpDir, 'test-extensions'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/947
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const cp = require('child_process');
6+
7+
if (process.argv[2] === 'child') {
8+
process.on('message', common.mustCall((msg) => {
9+
assert.strictEqual(msg, 'go');
10+
console.log('logging should not cause a crash');
11+
process.disconnect();
12+
}));
13+
} else {
14+
const child = cp.fork(__filename, ['child'], {silent: true});
15+
16+
child.on('close', common.mustCall((exitCode, signal) => {
17+
assert.strictEqual(exitCode, 0);
18+
assert.strictEqual(signal, null);
19+
}));
20+
21+
child.stdout.destroy();
22+
child.send('go');
23+
}

test/known_issues/test-vm-getters.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/2734
3+
require('../common');
4+
const assert = require('assert');
5+
const vm = require('vm');
6+
const sandbox = {};
7+
8+
Object.defineProperty(sandbox, 'prop', {
9+
get() {
10+
return 'foo';
11+
}
12+
});
13+
14+
const descriptor = Object.getOwnPropertyDescriptor(sandbox, 'prop');
15+
const context = vm.createContext(sandbox);
16+
const code = 'Object.getOwnPropertyDescriptor(this, "prop");';
17+
const result = vm.runInContext(code, context);
18+
19+
assert.strictEqual(result, descriptor);

0 commit comments

Comments
 (0)