mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. PR-URL: https://github.com/nodejs/node/pull/4408 Reviewed-By: James M Snell <jasnell@gmail.com>
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
'use strict';
|
|
// Flags: --expose_internals
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const internalUtil = require('internal/util');
|
|
|
|
function getHiddenValue(obj, name) {
|
|
return function() {
|
|
internalUtil.getHiddenValue(obj, name);
|
|
};
|
|
}
|
|
|
|
assert.throws(getHiddenValue(), /obj must be an object/);
|
|
assert.throws(getHiddenValue(null, 'foo'), /obj must be an object/);
|
|
assert.throws(getHiddenValue(undefined, 'foo'), /obj must be an object/);
|
|
assert.throws(getHiddenValue('bar', 'foo'), /obj must be an object/);
|
|
assert.throws(getHiddenValue(85, 'foo'), /obj must be an object/);
|
|
assert.throws(getHiddenValue({}), /name must be a string/);
|
|
assert.throws(getHiddenValue({}, null), /name must be a string/);
|
|
assert.throws(getHiddenValue({}, []), /name must be a string/);
|
|
assert.deepEqual(internalUtil.getHiddenValue({}, 'foo'), undefined);
|
|
|
|
let arrowMessage;
|
|
|
|
try {
|
|
require('../fixtures/syntax/bad_syntax');
|
|
} catch (err) {
|
|
arrowMessage = internalUtil.getHiddenValue(err, 'arrowMessage');
|
|
}
|
|
|
|
assert(/bad_syntax\.js:1/.test(arrowMessage));
|