2021-04-08 23:55:45 -07:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
|
|
|
|
const fixtures = require('../common/fixtures');
|
2021-05-03 21:58:42 -07:00
|
|
|
const startCLI = require('../common/debugger');
|
2021-04-08 23:55:45 -07:00
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2021-06-25 22:11:59 -07:00
|
|
|
const cli = startCLI([fixtures.path('debugger/alive.js')]);
|
2021-04-08 23:55:45 -07:00
|
|
|
|
|
|
|
function onFatal(error) {
|
|
|
|
cli.quit();
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
|
|
|
|
cli.waitForInitialBreak()
|
|
|
|
.then(() => cli.waitForPrompt())
|
|
|
|
.then(() => cli.command('exec [typeof heartbeat, typeof process.exit]'))
|
|
|
|
.then(() => {
|
|
|
|
assert.match(
|
|
|
|
cli.output,
|
|
|
|
/\[ 'function', 'function' \]/,
|
|
|
|
'works w/o paren'
|
|
|
|
);
|
|
|
|
})
|
2022-02-18 03:23:20 +08:00
|
|
|
.then(() => cli.command('p [typeof heartbeat, typeof process.exit]'))
|
|
|
|
.then(() => {
|
|
|
|
assert.match(
|
|
|
|
cli.output,
|
|
|
|
/\[ 'function', 'function' \]/,
|
|
|
|
'works w/o paren, short'
|
|
|
|
);
|
|
|
|
})
|
2021-04-08 23:55:45 -07:00
|
|
|
.then(() => cli.command('repl'))
|
|
|
|
.then(() => {
|
|
|
|
assert.match(
|
|
|
|
cli.output,
|
2020-09-19 09:01:00 -07:00
|
|
|
/Press Ctrl\+C to leave debug repl\n+> /,
|
2021-04-08 23:55:45 -07:00
|
|
|
'shows hint for how to leave repl');
|
|
|
|
assert.doesNotMatch(cli.output, /debug>/, 'changes the repl style');
|
|
|
|
})
|
|
|
|
.then(() => cli.command('[typeof heartbeat, typeof process.exit]'))
|
|
|
|
.then(() => cli.waitFor(/function/))
|
|
|
|
.then(() => cli.waitForPrompt())
|
|
|
|
.then(() => {
|
|
|
|
assert.match(
|
|
|
|
cli.output,
|
|
|
|
/\[ 'function', 'function' \]/, 'can evaluate in the repl');
|
|
|
|
assert.match(cli.output, /> $/);
|
|
|
|
})
|
|
|
|
.then(() => cli.ctrlC())
|
|
|
|
.then(() => cli.waitFor(/debug> $/))
|
|
|
|
.then(() => cli.command('exec("[typeof heartbeat, typeof process.exit]")'))
|
|
|
|
.then(() => {
|
|
|
|
assert.match(
|
|
|
|
cli.output,
|
|
|
|
/\[ 'function', 'function' \]/,
|
|
|
|
'works w/ paren'
|
|
|
|
);
|
|
|
|
})
|
2022-02-18 03:23:20 +08:00
|
|
|
.then(() => cli.command('p("[typeof heartbeat, typeof process.exit]")'))
|
|
|
|
.then(() => {
|
|
|
|
assert.match(
|
|
|
|
cli.output,
|
|
|
|
/\[ 'function', 'function' \]/,
|
|
|
|
'works w/ paren, short'
|
|
|
|
);
|
|
|
|
})
|
2021-04-08 23:55:45 -07:00
|
|
|
.then(() => cli.command('cont'))
|
|
|
|
.then(() => cli.command('exec [typeof heartbeat, typeof process.exit]'))
|
|
|
|
.then(() => {
|
|
|
|
assert.match(
|
|
|
|
cli.output,
|
|
|
|
/\[ 'undefined', 'function' \]/,
|
|
|
|
'non-paused exec can see global but not module-scope values');
|
|
|
|
})
|
|
|
|
.then(() => cli.quit())
|
|
|
|
.then(null, onFatal);
|
|
|
|
}
|