From 8e0e57666954874c9e263dce1b33c1634ccdbdda Mon Sep 17 00:00:00 2001 From: Kohei Ueno Date: Sun, 1 May 2022 12:51:14 +0900 Subject: [PATCH] test: add tests for extracting function name PR-URL: https://github.com/nodejs/node/pull/42399 Reviewed-By: Rich Trott Reviewed-By: James M Snell --- .../test-debugger-extract-function-name.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/parallel/test-debugger-extract-function-name.js diff --git a/test/parallel/test-debugger-extract-function-name.js b/test/parallel/test-debugger-extract-function-name.js new file mode 100644 index 00000000000000..aff97ee2954487 --- /dev/null +++ b/test/parallel/test-debugger-extract-function-name.js @@ -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);