• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Previews in strict mode should indicate ReferenceErrors.
2
3'use strict';
4
5const common = require('../common');
6
7common.skipIfInspectorDisabled();
8
9if (process.argv[2] === 'child') {
10  const stream = require('stream');
11  const repl = require('repl');
12  class ActionStream extends stream.Stream {
13    readable = true;
14    run(data) {
15      this.emit('data', `${data}`);
16      this.emit('keypress', '', { ctrl: true, name: 'd' });
17    }
18    resume() {}
19    pause() {}
20  }
21
22  repl.start({
23    input: new ActionStream(),
24    output: new stream.Writable({
25      write(chunk, _, next) {
26        console.log(chunk.toString());
27        next();
28      }
29    }),
30    useColors: false,
31    terminal: true
32  }).inputStream.run('xyz');
33} else {
34  const assert = require('assert');
35  const { spawnSync } = require('child_process');
36
37  const result = spawnSync(
38    process.execPath,
39    ['--use-strict', `${__filename}`, 'child']
40  );
41
42  assert.match(
43    result.stdout.toString(),
44    /\/\/ ReferenceError: xyz is not defined/
45  );
46}
47