Skip to content

Commit d268cf5

Browse files
authored
test: add tests for extracting function name
PR-URL: #42399 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 02e0c17 commit d268cf5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
common.skipIfInspectorDisabled();
5+
6+
const fixtures = require('../common/fixtures');
7+
const startCLI = require('../common/debugger');
8+
9+
const assert = require('assert');
10+
11+
const cli = startCLI([fixtures.path('debugger', 'three-lines.js')]);
12+
13+
function onFatal(error) {
14+
cli.quit();
15+
throw error;
16+
}
17+
18+
cli.waitForInitialBreak()
19+
.then(() => cli.waitForPrompt())
20+
.then(() => cli.command('exec a = function func() {}; a;'))
21+
.then(() => assert.match(cli.output, /\[Function: func\]/))
22+
.then(() => cli.command('exec a = function func () {}; a;'))
23+
.then(() => assert.match(cli.output, /\[Function\]/))
24+
.then(() => cli.command('exec a = function() {}; a;'))
25+
.then(() => assert.match(cli.output, /\[Function: function\]/))
26+
.then(() => cli.command('exec a = () => {}; a;'))
27+
.then(() => assert.match(cli.output, /\[Function\]/))
28+
.then(() => cli.command('exec a = function* func() {}; a;'))
29+
.then(() => assert.match(cli.output, /\[GeneratorFunction: func\]/))
30+
.then(() => cli.command('exec a = function *func() {}; a;'))
31+
.then(() => assert.match(cli.output, /\[GeneratorFunction: \*func\]/))
32+
.then(() => cli.command('exec a = function*func() {}; a;'))
33+
.then(() => assert.match(cli.output, /\[GeneratorFunction: function\*func\]/))
34+
.then(() => cli.command('exec a = function * func() {}; a;'))
35+
.then(() => assert.match(cli.output, /\[GeneratorFunction\]/))
36+
.then(() => cli.quit())
37+
.then(null, onFatal);

0 commit comments

Comments
 (0)