• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vscode-debugadapter-testsupport.DebugClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vscode-debugadapter-testsupport.DebugClient的典型用法代码示例。如果您正苦于以下问题:TypeScript DebugClient类的具体用法?TypeScript DebugClient怎么用?TypeScript DebugClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DebugClient类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe('PHP Debug Adapter', () => {

    const TEST_PROJECT = path.normalize(__dirname + '/../../testproject');

    let client: DebugClient;

    beforeEach('start debug adapter', async () => {
        client = new DebugClient('node', path.normalize(__dirname + '/../phpDebug'), 'php');
        client.defaultTimeout = 10000;
        await client.start(process.env.VSCODE_DEBUG_PORT && parseInt(process.env.VSCODE_DEBUG_PORT));
    });

    afterEach('stop debug adapter', () =>
        client.stop()
    );

    describe('initialization', () => {

        it('should return supported features', async () => {
            const response = await client.initializeRequest();
            assert.equal(response.body.supportsConfigurationDoneRequest, true);
            assert.equal(response.body.supportsEvaluateForHovers, false);
            assert.equal(response.body.supportsConditionalBreakpoints, true);
            assert.equal(response.body.supportsFunctionBreakpoints, true);
        });
    });

    describe('launch as CLI', () => {

        const program = path.join(TEST_PROJECT, 'hello_world.php');

        it('should error on non-existing file', () =>
            assert.isRejected(client.launch({program: 'thisfiledoesnotexist.php'}))
        );

        it('should run program to the end', () =>
            Promise.all([
                client.launch({program}),
                client.configurationSequence(),
                client.waitForEvent('terminated')
            ])
        );

        it('should stop on entry', async () => {
            const [event] = await Promise.all([
                client.waitForEvent('stopped'),
                client.launch({program, stopOnEntry: true}),
                client.configurationSequence()
            ]);
            assert.propertyVal(event.body, 'reason', 'entry');
        });

        it('should not stop if launched without debugging', () =>
            Promise.all([
                client.launch({program, stopOnEntry: true, noDebug: true}),
                client.waitForEvent('terminated')
            ])
        );
    });

    describe('continuation commands', () => {

        const program = path.join(TEST_PROJECT, 'function.php');

        it('should handle run');
        it('should handle step_over');
        it('should handle step_in');
        it('should handle step_out');

        it('should error on pause request', () =>
            assert.isRejected(client.pauseRequest({threadId: 1}))
        );

        it('should handle disconnect', async () => {
            await Promise.all([
                client.launch({program, stopOnEntry: true}),
                client.waitForEvent('initialized')
            ]);
            await client.disconnectRequest();
        });
    });

    async function assertStoppedLocation(reason: 'entry' | 'breakpoint' | 'exception', path: string, line: number): Promise<{threadId: number, frame: DebugProtocol.StackFrame}> {
        const event = await client.waitForEvent('stopped') as DebugProtocol.StoppedEvent;
        assert.propertyVal(event.body, 'reason', reason);
        const threadId = event.body.threadId;
        const response = await client.stackTraceRequest({threadId});
        const frame = response.body.stackFrames[0];
        let expectedPath = path;
        let actualPath = frame.source.path;
        if (process.platform === 'win32') {
            expectedPath = expectedPath.toLowerCase();
            actualPath = actualPath.toLowerCase();
        }
        assert.equal(actualPath, expectedPath, 'stopped location: path mismatch');
        assert.equal(frame.line, line, 'stopped location: line mismatch');
        return {threadId, frame};
    }

    describe('breakpoints', () => {
//.........这里部分代码省略.........
开发者ID:Heresiarch88,项目名称:vscode-php-debug,代码行数:101,代码来源:adapter.ts


示例2: describe

describe('Accessor properties: The debugger', function() {

	let dc: DebugClient;
	const TESTDATA_PATH = path.join(__dirname, '../../testdata');
	const SOURCE_PATH = path.join(TESTDATA_PATH, 'web/main.js');

	afterEach(async function() {
		await dc.stop();
	});

	it('should show accessor properties', async function() {

		dc = await util.initDebugClient(TESTDATA_PATH, true);

		let properties = await startAndGetProperties(dc, 98, 'getterAndSetter()');

		assert.equal(util.findVariable(properties, 'getterProperty').value, 'Getter - expand to execute Getter');
		assert.equal(util.findVariable(properties, 'setterProperty').value, 'Setter');
		assert.equal(util.findVariable(properties, 'getterAndSetterProperty').value, 'Getter & Setter - expand to execute Getter');
	});

	it('should execute getters on demand', async function() {

		dc = await util.initDebugClient(TESTDATA_PATH, true);

		let properties = await startAndGetProperties(dc, 98, 'getterAndSetter()');

		let getterProperty = util.findVariable(properties, 'getterProperty');
		let getterPropertyResponse = await dc.variablesRequest({ variablesReference: getterProperty.variablesReference });
		let getterValue = util.findVariable(getterPropertyResponse.body.variables, 'Value from Getter').value;
		assert.equal(getterValue, '17');

		let getterAndSetterProperty = util.findVariable(properties, 'getterAndSetterProperty');
		let getterAndSetterPropertyResponse = await dc.variablesRequest({ variablesReference: getterAndSetterProperty.variablesReference });
		let getterAndSetterValue = util.findVariable(getterAndSetterPropertyResponse.body.variables, 'Value from Getter').value;
		assert.equal(getterAndSetterValue, '23');
	});

	it('should execute nested getters', async function() {

		dc = await util.initDebugClient(TESTDATA_PATH, true);

		let properties1 = await startAndGetProperties(dc, 98, 'getterAndSetter()');

		let getterProperty1 = util.findVariable(properties1, 'nested');
		let getterPropertyResponse1 = await dc.variablesRequest({ variablesReference: getterProperty1.variablesReference });
		let getterValue1 = util.findVariable(getterPropertyResponse1.body.variables, 'Value from Getter');

		let propertiesResponse2 = await dc.variablesRequest({ variablesReference: getterValue1.variablesReference });
		let properties2 = propertiesResponse2.body.variables;

		let getterProperty2 = util.findVariable(properties2, 'z');
		let getterPropertyResponse2 = await dc.variablesRequest({ variablesReference: getterProperty2.variablesReference });
		let getterValue2 = util.findVariable(getterPropertyResponse2.body.variables, 'Value from Getter').value;

		assert.equal(getterValue2, '"foo"');
	});

	it('should show and execute getters lifted from prototypes', async function() {

		dc = await util.initDebugClient(TESTDATA_PATH, true, { liftAccessorsFromPrototypes: 2 });

		let properties1 = await startAndGetProperties(dc, 116, 'protoGetter()');

		let getterProperty1 = util.findVariable(properties1, 'y');
		let getterPropertyResponse1 = await dc.variablesRequest({ variablesReference: getterProperty1.variablesReference });
		let getterValue1 = util.findVariable(getterPropertyResponse1.body.variables, 'Value from Getter').value;
		assert.equal(getterValue1, '"foo"');

		let getterProperty2 = util.findVariable(properties1, 'z');
		let getterPropertyResponse2 = await dc.variablesRequest({ variablesReference: getterProperty2.variablesReference });
		let getterValue2 = util.findVariable(getterPropertyResponse2.body.variables, 'Value from Getter').value;
		assert.equal(getterValue2, '"bar"');
	});

	it('should only scan the configured number of prototypes for accessors to lift', async function() {

		dc = await util.initDebugClient(TESTDATA_PATH, true, { liftAccessorsFromPrototypes: 1 });

		let properties = await startAndGetProperties(dc, 116, 'protoGetter()');

		util.findVariable(properties, 'y');
		assert.throws(() => util.findVariable(properties, 'z'));
	});

	async function startAndGetProperties(dc: DebugClient, bpLine: number, trigger: string): Promise<DebugProtocol.Variable[]> {

		await util.setBreakpoints(dc, SOURCE_PATH, [ bpLine ]);
	
		util.evaluate(dc, trigger);
		let stoppedEvent = await util.receiveStoppedEvent(dc);
		let stackTrace = await dc.stackTraceRequest({ threadId: stoppedEvent.body.threadId! });
		let scopes = await dc.scopesRequest({ frameId: stackTrace.body.stackFrames[0].id });
	
		let variablesResponse = await dc.variablesRequest({ variablesReference: scopes.body.scopes[0].variablesReference });
		let variable = util.findVariable(variablesResponse.body.variables, 'x');
		let propertiesResponse = await dc.variablesRequest({ variablesReference: variable.variablesReference });
		return propertiesResponse.body.variables;
	}
});
开发者ID:hbenl,项目名称:vscode-firefox-debug,代码行数:100,代码来源:testAccessorProperties.ts


示例3:

 .then(() => dc.configurationDoneRequest())
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:1,代码来源:debugClient.ts


示例4:

				dc.waitForEvent('initialized').then(event => {
					return dc.setBreakpointsRequest({
						breakpoints: [ { line: COND_BREAKPOINT_LINE, condition: 'i === 3' } ],
						source: { path: PROGRAM }
					});
				}).then(response => {
开发者ID:codedebug,项目名称:vscode-node-debug,代码行数:6,代码来源:adapter.test.ts


示例5: it

 it('should run program to the end', () =>
     Promise.all([
         client.launch({program}),
         client.configurationSequence(),
         client.waitForEvent('terminated')
     ])
开发者ID:Heresiarch88,项目名称:vscode-php-debug,代码行数:6,代码来源:adapter.ts


示例6: afterEach

 afterEach('stop debug adapter', () =>
     client.stop()
开发者ID:Heresiarch88,项目名称:vscode-php-debug,代码行数:2,代码来源:adapter.ts


示例7:

				dc.waitForEvent('initialized').then(event => {
					return dc.setExceptionBreakpointsRequest({
						filters: [ 'all' ]
					});
				}).then(response => {
开发者ID:rlugojr,项目名称:vscode-mock-debug,代码行数:5,代码来源:adapter.test.ts



注:本文中的vscode-debugadapter-testsupport.DebugClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript vscode-emmet-helper.doComplete函数代码示例发布时间:2022-05-25
下一篇:
TypeScript vscode-debugadapter.logger类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap