Skip to content

Commit ebe1c31

Browse files
committed
Remove unused code
1 parent dec4235 commit ebe1c31

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

src/test/commentTest.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { test } from "bun:test";
1+
import { test, expect } from "bun:test";
22
import { testFunctions as testFuncsForGo } from "./collect-go";
33
import { testFunctions as testFuncsForC } from "./collect-c";
44
import { TestManager } from "./commentTestManager";
5+
56
const testManager = new TestManager({
67
testFunctions: [...testFuncsForC, ...testFuncsForGo],
78
});
89

9-
test.each(testManager.allTests)(testManager.nameFormat, testManager.invoke);
10+
test.each(testManager.allTests)(
11+
testManager.nameFormat,
12+
// @ts-expect-error: Mismatch between function types
13+
testManager.invokeWith((failure: string) => expect().fail(failure)),
14+
);

src/test/commentTestHandlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function getMarkerMap(cfg: CFG): Map<string, string> {
5353
return markerMap;
5454
}
5555

56-
type RequirementHandler = (testFunc: TestFunction) => null | string;
56+
export type RequirementHandler = (testFunc: TestFunction) => null | string;
5757
export const requirementTests: {
5858
[key: string]: RequirementHandler | undefined;
5959
} = {

src/test/commentTestManager.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
import { requirementTests } from "./commentTestHandlers";
1+
import {
2+
requirementTests,
3+
type RequirementHandler,
4+
} from "./commentTestHandlers";
25
import type { TestFunction } from "./commentTestTypes";
3-
import { expect } from "bun:test";
46

57
interface TestManagerOptions {
68
testFunctions: TestFunction[];
79
}
810
export class TestManager {
911
private readonly testFunctions: TestFunction[];
10-
private readonly testMap: Map<string, TestFunction>;
1112
public readonly nameFormat = "%s";
12-
// @ts-expect-error: Implicit any type
13-
public readonly invoke = (_name, testFunc, reqHandler) => {
14-
const failure: null | string = reqHandler(testFunc);
15-
if (failure) {
16-
expect().fail(failure);
17-
} else {
18-
expect().pass();
19-
}
20-
};
2113

2214
constructor(options: TestManagerOptions) {
2315
this.testFunctions = options.testFunctions;
24-
this.testMap = new Map(
25-
this.testFunctions.map((testFunc) => [testFunc.name, testFunc]),
26-
);
16+
}
17+
18+
public invokeWith(failureCallback: (failure: string) => void) {
19+
return (
20+
_name: string,
21+
testFunc: TestFunction,
22+
reqHandler: RequirementHandler,
23+
) => {
24+
const failure: null | string = reqHandler(testFunc);
25+
if (failure) {
26+
failureCallback(failure);
27+
}
28+
};
2729
}
2830

2931
public get allTests() {

0 commit comments

Comments
 (0)