summaryrefslogtreecommitdiff
path: root/test/parallel/test-repl-eval-scope.js
blob: 00b577cba73f76c9dc29cde8c22ddbb76b27d459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
const common = require('../common');
const assert = require('assert');
const repl = require('repl');

{
  const stream = new common.ArrayStream();
  const options = {
    eval: common.mustCall((cmd, context) => {
      assert.strictEqual(cmd, '.scope\n');
      assert.deepStrictEqual(context, { animal: 'Sterrance' });
    }),
    input: stream,
    output: stream,
    terminal: true
  };

  const r = repl.start(options);
  r.context = { animal: 'Sterrance' };

  stream.emit('data', '\t');
  stream.emit('.exit\n');
}