Skip to content

Commit 56a37f7

Browse files
committed
add test case for uncoveredlines
1 parent b5b1401 commit 56a37f7

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"build": "tsc --build ./transform/tsconfig.json && node ./build/esbuild.js",
1616
"test": "node bin/as-test.js && cross-env NODE_OPTIONS=--experimental-vm-modules jest",
1717
"lint": "eslint src assembly tests-ts/test --max-warnings=0 && prettier -c .",
18-
"lint:fix": "eslint src assembly --fix",
18+
"lint:fix": "eslint src assembly --fix && npx prettier --write .",
1919
"example": "node bin/as-test.js --config example/as-test.config.cjs ; node bin/as-test.js --config example/as-test.config.js"
2020
},
2121
"dependencies": {

tests-ts/test/parser/singleFunctionAnalysis.test.ts

+77
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,83 @@ describe("singleFunctionAnalysis", () => {
5858
])
5959
);
6060
});
61+
62+
test("forLoop", () => {
63+
const covInfo: CovInfo = {
64+
branchInfo: [
65+
[1, 2],
66+
[1, 3],
67+
],
68+
lineInfo: new Map([
69+
[0, new Set([17, 18])],
70+
[1, new Set([18])],
71+
[2, new Set([18, 20])],
72+
[3, new Set([])],
73+
[4, new Set([22])],
74+
]),
75+
};
76+
const traceInfo = [0, 1, 3, 4];
77+
const analyzer = new SingleFunctionCoverageAnalysis(covInfo, "main");
78+
const result = analyzer.update(traceInfo);
79+
expect(result.uncoveredlines).toEqual(new Set([18]));
80+
});
81+
82+
test("ifWithoutElse", () => {
83+
const covInfo: CovInfo = {
84+
branchInfo: [
85+
[0, 1],
86+
[0, 2],
87+
],
88+
lineInfo: new Map([
89+
[0, new Set([2])],
90+
[1, new Set([3])],
91+
[2, new Set([5])],
92+
]),
93+
};
94+
const traceInfo = [0, 1];
95+
const analyzer = new SingleFunctionCoverageAnalysis(covInfo, "main");
96+
const result = analyzer.update(traceInfo);
97+
expect(result.uncoveredlines).toEqual(new Set([2]));
98+
});
99+
100+
test("threeOperandOperator", () => {
101+
const covInfo: CovInfo = {
102+
branchInfo: [
103+
[0, 1],
104+
[0, 2],
105+
],
106+
lineInfo: new Map([
107+
[0, new Set([26])],
108+
[1, new Set([26])],
109+
[2, new Set([26])],
110+
[3, new Set([26])],
111+
]),
112+
};
113+
const traceInfo = [3, 0, 1];
114+
const analyzer = new SingleFunctionCoverageAnalysis(covInfo, "main");
115+
const result = analyzer.update(traceInfo);
116+
expect(result.uncoveredlines).toEqual(new Set([26]));
117+
});
118+
119+
test("whileLoop", () => {
120+
const covInfo: CovInfo = {
121+
branchInfo: [
122+
[1, 2],
123+
[1, 3],
124+
],
125+
lineInfo: new Map([
126+
[0, new Set([9])],
127+
[1, new Set([10])],
128+
[2, new Set([11])],
129+
[3, new Set([])],
130+
[4, new Set([10, 13])],
131+
]),
132+
};
133+
const traceInfo = [0, 1, 3, 4];
134+
const analyzer = new SingleFunctionCoverageAnalysis(covInfo, "main");
135+
const result = analyzer.update(traceInfo);
136+
expect(result.uncoveredlines).toEqual(new Set([10]));
137+
});
61138
});
62139

63140
test("mergeFromGeneric()", () => {

0 commit comments

Comments
 (0)