node/test/parallel/test-util-internal.js
James M Snell 3d20190a3a src: remove throws in set/getHiddenValue
These are internal only utility functions, CHECK instead of throw

PR-URL: https://github.com/nodejs/node/pull/16544
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2017-11-02 07:24:49 -07:00

36 lines
790 B
JavaScript

'use strict';
// Flags: --expose_internals
require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const {
getHiddenValue,
setHiddenValue,
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex
} = process.binding('util');
assert.strictEqual(
getHiddenValue({}, kArrowMessagePrivateSymbolIndex),
undefined);
const obj = {};
assert.strictEqual(
setHiddenValue(obj, kArrowMessagePrivateSymbolIndex, 'bar'),
true);
assert.strictEqual(
getHiddenValue(obj, kArrowMessagePrivateSymbolIndex),
'bar');
let arrowMessage;
try {
require(fixtures.path('syntax', 'bad_syntax'));
} catch (err) {
arrowMessage =
getHiddenValue(err, kArrowMessagePrivateSymbolIndex);
}
assert(/bad_syntax\.js:1/.test(arrowMessage));