• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2// Flags: --expose-internals
3
4require('../common');
5const assert = require('assert');
6const fixtures = require('../common/fixtures');
7const { internalBinding } = require('internal/test/binding');
8
9const {
10  getHiddenValue,
11  setHiddenValue,
12  arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex
13} = internalBinding('util');
14
15assert.strictEqual(
16  getHiddenValue({}, kArrowMessagePrivateSymbolIndex),
17  undefined);
18
19const obj = {};
20assert.strictEqual(
21  setHiddenValue(obj, kArrowMessagePrivateSymbolIndex, 'bar'),
22  true);
23assert.strictEqual(
24  getHiddenValue(obj, kArrowMessagePrivateSymbolIndex),
25  'bar');
26
27let arrowMessage;
28
29try {
30  require(fixtures.path('syntax', 'bad_syntax'));
31} catch (err) {
32  arrowMessage =
33      getHiddenValue(err, kArrowMessagePrivateSymbolIndex);
34}
35
36assert(/bad_syntax\.js:1/.test(arrowMessage));
37