Skip to content

Commit 055a6cc

Browse files
committed
Fix error scope tests
1 parent 35c575b commit 055a6cc

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/test/adapter.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,26 @@ describe('PHP Debug Adapter', () => {
216216
client.waitForEvent('stopped') as Promise<DebugProtocol.StoppedEvent>
217217
]);
218218

219-
async function getErrorScope(threadId: number): Promise<{name: string, type?: string, message?: string, code?: string}> {
219+
async function getErrorScope(): Promise<{name: string, type?: string, message?: string, code?: string}> {
220220
const frameId = (await client.stackTraceRequest({threadId})).body.stackFrames[0].id;
221221
const errorScope = (await client.scopesRequest({frameId})).body.scopes[0];
222-
assert.propertyVal(errorScope, 'name', name);
223222
const variables = (await client.variablesRequest({variablesReference: errorScope.variablesReference})).body.variables;
223+
const errorInfo: {name: string, type?: string, message?: string, code?: string} = {name: errorScope.name};
224224
const type = variables.find(variable => variable.name === 'type');
225+
if (type) {
226+
errorInfo.type = type.value;
227+
}
225228
const message = variables.find(variable => variable.name === 'message');
229+
if (message) {
230+
errorInfo.message = message.value;
231+
}
226232
const code = variables.find(variable => variable.name === 'code');
227-
return {
228-
name: errorScope.name,
229-
type: type && type.value,
230-
message: message && message.value,
231-
code: code && code.value
232-
};
233+
if (code) {
234+
errorInfo.code = code.value;
235+
}
236+
return errorInfo;
233237
}
234-
assert.deepEqual(await getErrorScope(threadId), {
238+
assert.deepEqual(await getErrorScope(), {
235239
name: 'Notice',
236240
type: 'Notice',
237241
message: '"Undefined index: undefined_index"',
@@ -241,7 +245,7 @@ describe('PHP Debug Adapter', () => {
241245
client.continueRequest({threadId}),
242246
client.waitForEvent('stopped')
243247
]);
244-
assert.deepEqual(await getErrorScope(threadId), {
248+
assert.deepEqual(await getErrorScope(), {
245249
name: 'Warning',
246250
type: 'Warning',
247251
message: '"Illegal offset type"',
@@ -251,7 +255,7 @@ describe('PHP Debug Adapter', () => {
251255
client.continueRequest({threadId}),
252256
client.waitForEvent('stopped')
253257
]);
254-
assert.deepEqual(await getErrorScope(threadId), {
258+
assert.deepEqual(await getErrorScope(), {
255259
name: 'Exception',
256260
type: 'Exception',
257261
message: '"this is an exception"'
@@ -260,7 +264,7 @@ describe('PHP Debug Adapter', () => {
260264
client.continueRequest({threadId}),
261265
client.waitForEvent('stopped')
262266
]);
263-
const fatalErrorScope = await getErrorScope(threadId);
267+
const fatalErrorScope = await getErrorScope();
264268
assert.propertyVal(fatalErrorScope, 'name', 'Fatal error');
265269
assert.propertyVal(fatalErrorScope, 'type', 'Fatal error');
266270
assert.match(fatalErrorScope.message, /^"Uncaught Exception/);

0 commit comments

Comments
 (0)