• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4common.skipIfInspectorDisabled();
5
6const fixtures = require('../common/fixtures');
7const startCLI = require('../common/debugger');
8
9const assert = require('assert');
10
11{
12
13  const cli = startCLI([fixtures.path('debugger/alive.js')]);
14
15  function onFatal(error) {
16    cli.quit();
17    throw error;
18  }
19
20  cli.waitForInitialBreak()
21    .then(() => cli.waitForPrompt())
22    .then(() => cli.command('exec [typeof heartbeat, typeof process.exit]'))
23    .then(() => {
24      assert.match(
25        cli.output,
26        /\[ 'function', 'function' \]/,
27        'works w/o paren'
28      );
29    })
30    .then(() => cli.command('repl'))
31    .then(() => {
32      assert.match(
33        cli.output,
34        /Press Ctrl\+C to leave debug repl\n+> /,
35        'shows hint for how to leave repl');
36      assert.doesNotMatch(cli.output, /debug>/, 'changes the repl style');
37    })
38    .then(() => cli.command('[typeof heartbeat, typeof process.exit]'))
39    .then(() => cli.waitFor(/function/))
40    .then(() => cli.waitForPrompt())
41    .then(() => {
42      assert.match(
43        cli.output,
44        /\[ 'function', 'function' \]/, 'can evaluate in the repl');
45      assert.match(cli.output, /> $/);
46    })
47    .then(() => cli.ctrlC())
48    .then(() => cli.waitFor(/debug> $/))
49    .then(() => cli.command('exec("[typeof heartbeat, typeof process.exit]")'))
50    .then(() => {
51      assert.match(
52        cli.output,
53        /\[ 'function', 'function' \]/,
54        'works w/ paren'
55      );
56    })
57    .then(() => cli.command('cont'))
58    .then(() => cli.command('exec [typeof heartbeat, typeof process.exit]'))
59    .then(() => {
60      assert.match(
61        cli.output,
62        /\[ 'undefined', 'function' \]/,
63        'non-paused exec can see global but not module-scope values');
64    })
65    .then(() => cli.quit())
66    .then(null, onFatal);
67}
68