Skip to content

Commit 466b3cf

Browse files
committed
Change error checking code to work
1 parent 4b1c478 commit 466b3cf

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/test/suite/fixtures/recorded/nonMatchErrors/takeFunk.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ initialState:
1616
finalState: null
1717
returnValue: null
1818
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: namedFunction, includeSiblings: false}, isImplicit: false}]
19-
errorName: NoContainingScopeError
19+
thrownError: {name: NoContainingScopeError}

src/test/suite/fixtures/recorded/nonMatchErrors/takeList.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ initialState:
1616
finalState: null
1717
returnValue: null
1818
fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: inside, modifier: {type: containingScope, scopeType: list, includeSiblings: false}, isImplicit: false}]
19-
errorName: Error
19+
thrownError: {name: NoContainingScopeError}

src/test/suite/recorded.test.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,22 @@ async function runTest(file: string) {
105105

106106
// Assert that recorded decorations are present
107107
checkMarks(fixture.initialState.marks, readableHatMap);
108+
108109
if (fixture.thrownError != null) {
109-
try {
110-
await vscode.commands.executeCommand(
111-
"cursorless.command",
112-
fixture.command
113-
);
114-
} catch (e) {
115-
const err = e as Error;
116-
assert.equal(err.name, fixture.thrownError);
117-
} finally {
118-
return;
119-
}
110+
await assert.rejects(
111+
async () => {
112+
await vscode.commands.executeCommand(
113+
"cursorless.command",
114+
fixture.command
115+
);
116+
},
117+
(err: Error) => {
118+
assert.strictEqual(err.name, fixture.thrownError?.name);
119+
}
120+
);
121+
return;
120122
}
123+
121124
const returnValue = await vscode.commands.executeCommand(
122125
"cursorless.command",
123126
fixture.command

0 commit comments

Comments
 (0)