当前位置: 首页>>代码示例>>TypeScript>>正文


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

本文整理汇总了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;未经允许,请勿转载。