Skip to content

Commit

Permalink
test: add tests for extracting function name
Browse files Browse the repository at this point in the history
PR-URL: #42399
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cola119 authored and targos committed May 2, 2022
1 parent fbda87d commit 8e0e576
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/parallel/test-debugger-extract-function-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';
const common = require('../common');

common.skipIfInspectorDisabled();

const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');

const assert = require('assert');

const cli = startCLI([fixtures.path('debugger', 'three-lines.js')]);

function onFatal(error) {
cli.quit();
throw error;
}

cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('exec a = function func() {}; a;'))
.then(() => assert.match(cli.output, /\[Function: func\]/))
.then(() => cli.command('exec a = function func () {}; a;'))
.then(() => assert.match(cli.output, /\[Function\]/))
.then(() => cli.command('exec a = function() {}; a;'))
.then(() => assert.match(cli.output, /\[Function: function\]/))
.then(() => cli.command('exec a = () => {}; a;'))
.then(() => assert.match(cli.output, /\[Function\]/))
.then(() => cli.command('exec a = function* func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction: func\]/))
.then(() => cli.command('exec a = function *func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction: \*func\]/))
.then(() => cli.command('exec a = function*func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction: function\*func\]/))
.then(() => cli.command('exec a = function * func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction\]/))
.then(() => cli.quit())
.then(null, onFatal);

0 comments on commit 8e0e576

Please sign in to comment.