Skip to content

Commit e6a18f8

Browse files
committed
test: add tests for runner coverage with different stdout column widths
1 parent 8b0c699 commit e6a18f8

20 files changed

Lines changed: 570 additions & 0 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Empty functions that don't do anything
2+
function doNothing1() {
3+
// Not implemented
4+
}
5+
6+
function doNothing2() {
7+
// No logic here
8+
}
9+
10+
function unusedFunction1() {
11+
// Intentionally left empty
12+
}
13+
14+
function unusedFunction2() {
15+
// Another empty function
16+
}
17+
18+
// Unused variables
19+
const unusedVariable1 = "This is never used";
20+
const unusedVariable2 = 42;
21+
let unusedVariable3;
22+
23+
// Empty class with no methods
24+
class UnusedClass {
25+
constructor() {
26+
// Constructor does nothing
27+
}
28+
}
29+
30+
// Empty object literal
31+
const emptyObject = {};
32+
33+
// Empty array
34+
const emptyArray = [];
35+
36+
// Function with parameters but no body
37+
function doNothingWithParams(param1, param2) {
38+
// No implementation
39+
}
40+
41+
// Function that returns nothing
42+
function returnsNothing() {
43+
// No return statement
44+
}
45+
46+
// Another unused function
47+
function unusedFunction3() {
48+
// More empty code
49+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Empty functions that don't do anything
2+
function doNothing1() {
3+
// Not implemented
4+
}
5+
6+
function doNothing2() {
7+
// No logic here
8+
}
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
// Empty functions that don't do anything
2+
function doNothing1() {
3+
// Not implemented
4+
}
5+
6+
function doNothing2() {
7+
// No logic here
8+
}
9+
10+
function unusedFunction1() {
11+
// Intentionally left empty
12+
}
13+
14+
function unusedFunction2() {
15+
// Another empty function
16+
}
17+
18+
// Unused variables
19+
const unusedVariable1 = "This is never used";
20+
const unusedVariable2 = 42;
21+
let unusedVariable3;
22+
23+
// Empty class with no methods
24+
class UnusedClass {
25+
constructor() {
26+
// Constructor does nothing
27+
}
28+
}
29+
30+
// Empty object literal
31+
const emptyObject = {};
32+
33+
// Empty array
34+
const emptyArray = [];
35+
36+
// Function with parameters but no body
37+
function doNothingWithParams(param1, param2) {
38+
// No implementation
39+
}
40+
41+
// Function that returns nothing
42+
function returnsNothing() {
43+
// No return statement
44+
}
45+
46+
// Another unused function
47+
function unusedFunction3() {
48+
// More empty code
49+
}
50+
51+
// Empty functions with different signatures
52+
function doNothing4() {
53+
// No logic here
54+
}
55+
56+
function doNothing5() {
57+
// Another placeholder
58+
}
59+
60+
function doNothingWithRestParams(...args) {
61+
// Function with rest parameters but no logic
62+
}
63+
64+
function doNothingWithCallback(callback) {
65+
// Callback not called
66+
}
67+
68+
// Unused variables of different types
69+
const unusedVariable7 = null;
70+
const unusedVariable8 = undefined;
71+
const unusedVariable9 = Symbol('unused');
72+
let unusedVariable10;
73+
74+
// Another empty class
75+
class YetAnotherUnusedClass {
76+
// No properties or methods
77+
}
78+
79+
// Unused object with nested array
80+
const unusedObjectWithArray = {
81+
innerArray: []
82+
};
83+
84+
// Another empty array
85+
const anotherEmptyArray = [];
86+
87+
// Function with default and rest parameters
88+
function anotherComplexFunction(param1 = 10, ...rest) {
89+
// No implementation
90+
}
91+
92+
// More unused functions
93+
function unusedFunction5() {
94+
// Placeholder
95+
}
96+
97+
function unusedFunction6() {
98+
// Empty again
99+
}
100+
101+
function unusedFunction7() {
102+
// Still nothing here
103+
}
104+
105+
// Empty static method in class
106+
class UnusedClassWithStaticMethod {
107+
static unusedStaticMethod() {
108+
// No logic inside static method
109+
}
110+
}
111+
112+
// Empty getter and setter in a class
113+
class ClassWithGetterSetter {
114+
get unusedGetter() {
115+
// Empty getter
116+
}
117+
118+
set unusedSetter(value) {
119+
// Empty setter
120+
}
121+
}
122+
123+
// Unused function returning undefined
124+
function returnsUndefined() {
125+
return undefined;
126+
}
127+
128+
// Empty promise-returning function
129+
function emptyPromiseFunction() {
130+
return new Promise((resolve, reject) => {
131+
// No promise logic
132+
});
133+
}
134+
135+
// Empty immediately-invoked function expression (IIFE)
136+
(function emptyIIFE() {
137+
// No implementation
138+
})();
139+
140+
// Unused generator function with parameters
141+
function* unusedGeneratorFunctionWithParams(param1, param2) {
142+
// No yielding of values
143+
}
144+
145+
// Unused async arrow function
146+
const unusedAsyncArrowFunction = async () => {
147+
// No async logic here
148+
};
149+
150+
// Unused map function with no logic
151+
const unusedMapFunction = new Map();
152+
153+
// Unused set function with no logic
154+
const unusedSetFunction = new Set();
155+
156+
// Empty for loop
157+
for (let i = 0; i < 10; i++) {
158+
// Loop does nothing
159+
}
160+
161+
// Empty while loop
162+
while (false) {
163+
// Never executes
164+
}
165+
166+
// Empty try-catch-finally block
167+
try {
168+
// Nothing to try
169+
} catch (error) {
170+
// No error handling
171+
} finally {
172+
// Nothing to finalize
173+
}
174+
175+
// Empty if-else block
176+
if (false) {
177+
// No logic here
178+
} else {
179+
// Nothing here either
180+
}
181+
182+
// Empty switch statement
183+
switch (false) {
184+
case true:
185+
// No case logic
186+
break;
187+
default:
188+
// Default does nothing
189+
break;
190+
}
191+
192+
// Empty nested function
193+
function outerFunction() {
194+
function innerFunction() {
195+
// Empty inner function
196+
}
197+
}
198+
199+
// More unused arrow functions
200+
const unusedArrowFunction1 = () => {};
201+
const unusedArrowFunction2 = param => {};
202+
203+
// Empty function with a try-catch block
204+
function emptyTryCatchFunction() {
205+
try {
206+
// Nothing to try
207+
} catch (error) {
208+
// No error handling
209+
}
210+
}
211+
212+
// Unused async generator function
213+
async function* unusedAsyncGenerator() {
214+
// No async yielding
215+
}
216+
217+
// Unused function returning an empty array
218+
function returnsEmptyArray() {
219+
return [];
220+
}
221+
222+
// Unused function returning an empty object
223+
function returnsEmptyObject() {
224+
return {};
225+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Flags: --experimental-test-coverage
2+
import * as a from '../coverage-snap/b.mjs';
3+
import * as b from '../coverage-snap/a.mjs';
4+
import * as c from '../coverage-snap/many-uncovered-lines.mjs';
5+
import { test } from 'node:test';
6+
7+
process.stdout.columns = 100;
8+
9+
test(`Coverage Print Fixed Width ${process.stdout.columns}`);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
TAP version 13
2+
# Subtest: Coverage Print Fixed Width 100
3+
ok 1 - Coverage Print Fixed Width 100
4+
---
5+
duration_ms: *
6+
...
7+
1..1
8+
# tests 1
9+
# suites 0
10+
# pass 1
11+
# fail 0
12+
# cancelled 0
13+
# skipped 0
14+
# todo 0
15+
# duration_ms *
16+
# start of coverage report
17+
# --------------------------------------------------------------------------------------------------
18+
# file | line % | branch % | funcs % | uncovered lines
19+
# --------------------------------------------------------------------------------------------------
20+
# …runner/coverage-snap/a.mjs | 53.06 | 100.00 | 0.00 | 2-4 6-8 10-12 14-16 26-27 37-39 42-4…
21+
# …runner/coverage-snap/b.mjs | 25.00 | 100.00 | 0.00 | 2-4 6-8
22+
# …p/many-uncovered-lines.mjs | 59.11 | 42.86 | 3.23 | 2-4 6-8 10-12 14-16 26-27 37-39 42-4…
23+
# …dth-100-uncovered-lines.js | 100.00 | 100.00 | 100.00 |
24+
# --------------------------------------------------------------------------------------------------
25+
# all files | 58.42 | 60.00 | 2.44 |
26+
# --------------------------------------------------------------------------------------------------
27+
# end of coverage report
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Flags: --experimental-test-coverage
2+
import * as a from '../coverage-snap/b.mjs';
3+
import * as b from '../coverage-snap/a.mjs';
4+
import { test } from 'node:test';
5+
6+
process.stdout.columns = 100;
7+
8+
test(`Coverage Print Fixed Width ${process.stdout.columns}`);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
TAP version 13
2+
# Subtest: Coverage Print Fixed Width 100
3+
ok 1 - Coverage Print Fixed Width 100
4+
---
5+
duration_ms: *
6+
...
7+
1..1
8+
# tests 1
9+
# suites 0
10+
# pass 1
11+
# fail 0
12+
# cancelled 0
13+
# skipped 0
14+
# todo 0
15+
# duration_ms *
16+
# start of coverage report
17+
# --------------------------------------------------------------------------------------------------
18+
# file | line % | branch % | funcs % | uncovered lines
19+
# --------------------------------------------------------------------------------------------------
20+
# test/fixtures/test-runner/coverage-snap/a.mjs | 53.06 | 100.00 | 0.00 | 2-4 6-8 10-12 1…
21+
# test/fixtures/test-runner/coverage-snap/b.mjs | 25.00 | 100.00 | 0.00 | 2-4 6-8
22+
# …xtures/test-runner/output/coverage-width-100.js | 100.00 | 100.00 | 100.00 |
23+
# --------------------------------------------------------------------------------------------------
24+
# all files | 55.38 | 100.00 | 0.00 |
25+
# --------------------------------------------------------------------------------------------------
26+
# end of coverage report
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Flags: --experimental-test-coverage
2+
import * as a from '../coverage-snap/b.mjs';
3+
import * as b from '../coverage-snap/a.mjs';
4+
import * as c from '../coverage-snap/many-uncovered-lines.mjs';
5+
import { test } from 'node:test';
6+
7+
process.stdout.columns = 150;
8+
9+
test(`Coverage Print Fixed Width ${process.stdout.columns}`);

0 commit comments

Comments
 (0)