-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
missing coverage of closing brace when return
ends a switch/case
#81
Comments
It was true!
It as not true
It was neither true nor false
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 94.12 | 71.43 | 100 | 94.12 | |
foo.js | 94.12 | 71.43 | 100 | 94.12 | 7 |
----------|----------|----------|----------|----------|-------------------| I'm seeing line |
@bcoe If I rename the file to |
Yes. $ c8 --help
[...]
--exclude, -x a list of specific files and directories that should be
excluded from coverage (glob patterns are supported)
[Default:
["coverage/**","packages/*/test/**","test/**","test{,-*}.js","**/*{.,-}test.js
","**/__tests__/**","**/node_modules/**","**/babel.config.js"]] One of the default glob patterns |
@Trott do we want to keep this open still? but perhaps be more specific, like closing |
¯\(ツ)/¯ Seems like it might have the same root cause as #61 and/or #62? So if you wanted to close it as a probable-duplicate, I would be OK with that. But in the meantime, I'll update it.... |
return
inside switch/case
return
ends a switch/case
(Updated. Might not be a bad idea to hide most of the subsequent comments as outdated or whatever.) |
@Trott thanks 👍 ... these bugs will probably ultimately be addressed in |
i meet similar issue foobar.ts export function test_1(param: boolean) {
switch (param) {
case true:
console.log("true");
break;
case false:
console.log("false");
}
}
export function test_2(param: boolean) {
switch (param) {
case true:
console.log("true");
break;
default:
console.log("false");
break;
}
}
export function test_3(param: boolean) {
switch (param) {
case true:
console.log("true");
break;
default:
throw new Error("error");
}
} test.ts import { test_1, test_2, test_3 } from "./foobar";
test_1(true);
test_1(false);
test_2(true);
test_2(false);
test_3(true);
try {
test_3(false);
} catch (err) {
console.log("error caught");
} output true
false
true
false
true
error caught
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 80 | 66.67 | 100 | 80 | |
plop.ts | 80 | 66.67 | 100 | 80 | 16,19,20,27,29,30 |
----------|----------|----------|----------|----------|-------------------| It not only happens with return in switch statement. It happens on line with This make border effects too for line 20 and 30 on |
I think this has been fixed in V8 although awaiting a release? |
@Trott hey, I remember this bit of the codebase, Let's cherry-pick that commit 😄 |
Code in foo.js:
Command:
c8 node foo.js
Output:
The text was updated successfully, but these errors were encountered: