Skip to content

Commit

Permalink
add test case SwitchStatementNoBreak
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Aug 12, 2024
1 parent fb72843 commit e70894b
Show file tree
Hide file tree
Showing 16 changed files with 266 additions and 130 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/mock/src/branch/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const ConditionalExpression = require('./conditional.js');
const IfStatement = require('./if.js');
const LogicalExpression = require('./logical.js');
const SwitchStatement = require('./switch.js');
const SwitchStatementNoBreak = require('./switch-no-break.js');

const uncoveredFunction = (a) => {
const list = [1, 2, 3, 4, 5];
Expand Down Expand Up @@ -152,7 +153,7 @@ const branch = (a) => {
IfStatement();
LogicalExpression();
SwitchStatement();

SwitchStatementNoBreak();
};

module.exports = {
Expand Down
19 changes: 19 additions & 0 deletions test/mock/src/branch/switch-no-break.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// all branches should be covered 3/3
function SwitchStatementNoBreak(a) {
let result = 0;
switch (a) {
case 1:
result++;
case 2:
result++;
default:
result++;
}
return result;
}

module.exports = () => {
SwitchStatementNoBreak(1);
SwitchStatementNoBreak(2);
SwitchStatementNoBreak(3);
};
29 changes: 19 additions & 10 deletions test/snapshot/cli.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"type": "v8",
"summary": {
"bytes": "52.61 %",
"statements": "55.60 %",
"branches": "51.88 %",
"functions": "49.45 %",
"lines": "44.35 %"
"bytes": "53.59 %",
"statements": "56.61 %",
"branches": "52.04 %",
"functions": "50.54 %",
"lines": "45.58 %"
},
"files": {
"test/mock/node/lib/app.js": {
Expand Down Expand Up @@ -65,11 +65,11 @@
"test/mock/src/branch/branch.js": {
"functions": "70.00 %",
"branches": "65.85 %",
"statements": "84.72 %",
"lines": "73.87 %",
"bytes": "80.92 %",
"uncoveredLines": "9-19,27,56-59,73,80-82,107,118-123,135-138,143-145",
"extras": "1c,2b,8b,14b,16c,20b,25b,26c,29b,30c,34b,35c,36c,37c,38c,42b,44b,46b,55b,57c,60b,69b,71b,72c,75b,76c,84b,86b,97b,99b,104b,106c,110b,112b,114b,116b,117b,121c,124b,126b,133b,134b,136c,139b,140c,141c,149b,155b,157b,161b"
"statements": "85.14 %",
"lines": "74.34 %",
"bytes": "81.49 %",
"uncoveredLines": "10-20,28,57-60,74,81-83,108,119-124,136-139,144-146",
"extras": "1c,2b,9b,15b,17c,21b,26b,27c,30b,31c,35b,36c,37c,38c,39c,43b,45b,47b,56b,58c,61b,70b,72b,73c,76b,77c,85b,87b,98b,100b,105b,107c,111b,113b,115b,117b,118b,122c,125b,127b,134b,135b,137c,140b,141c,142c,150b,158b,162b"
},
"test/mock/src/branch/conditional.js": {
"functions": "100.00 %",
Expand Down Expand Up @@ -98,6 +98,15 @@
"uncoveredLines": "22-23,33-34,38,45,48-49,59-60",
"extras": "1c,2b,4b,10b,15b,19b,25b,29b,36b,40b,47b,51b,58b,62b,65b,66b,68b,73b,75b"
},
"test/mock/src/branch/switch-no-break.js": {
"functions": "100.00 %",
"branches": "66.67 %",
"statements": "100.00 %",
"lines": "100.00 %",
"bytes": "100.00 %",
"uncoveredLines": "",
"extras": "1c,14b,20b"
},
"test/mock/src/branch/switch.js": {
"functions": "100.00 %",
"branches": "40.91 %",
Expand Down
29 changes: 19 additions & 10 deletions test/snapshot/esbuild.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"type": "v8",
"summary": {
"bytes": "82.34 %",
"statements": "83.30 %",
"branches": "59.60 %",
"functions": "83.67 %",
"lines": "71.76 %"
"bytes": "82.76 %",
"statements": "83.73 %",
"branches": "59.68 %",
"functions": "84.16 %",
"lines": "72.48 %"
},
"files": {
"src/async.js": {
Expand All @@ -29,11 +29,11 @@
"src/branch/branch.js": {
"functions": "72.73 %",
"branches": "65.85 %",
"statements": "85.71 %",
"lines": "73.87 %",
"bytes": "80.88 %",
"uncoveredLines": "9-19,27,56-59,73,80-82,107,118-123,135-138,143-145",
"extras": "1c,2b,8b,14b,16c,20b,25b,26c,29b,30c,34b,35c,36c,37c,38c,42b,44b,46b,55b,57c,60b,69b,71b,72c,75b,76c,84b,86b,97b,99b,104b,106c,110b,112b,114b,116b,117b,121c,124b,126b,133b,134b,136c,139b,140c,141c,149b,155b,157b,161b"
"statements": "86.08 %",
"lines": "74.34 %",
"bytes": "81.46 %",
"uncoveredLines": "10-20,28,57-60,74,81-83,108,119-124,136-139,144-146",
"extras": "1c,2b,9b,15b,17c,21b,26b,27c,30b,31c,35b,36c,37c,38c,39c,43b,45b,47b,56b,58c,61b,70b,72b,73c,76b,77c,85b,87b,98b,100b,105b,107c,111b,113b,115b,117b,118b,122c,125b,127b,134b,135b,137c,140b,141c,142c,150b,158b,162b"
},
"src/branch/conditional.js": {
"functions": "100.00 %",
Expand Down Expand Up @@ -62,6 +62,15 @@
"uncoveredLines": "22-23,33-34,38,45,48-49,59-60",
"extras": "1c,2b,4b,10b,15b,19b,25b,29b,36b,40b,47b,51b,58b,62b,65b,66b,68b,73b,75b"
},
"src/branch/switch-no-break.js": {
"functions": "100.00 %",
"branches": "66.67 %",
"statements": "100.00 %",
"lines": "100.00 %",
"bytes": "100.00 %",
"uncoveredLines": "",
"extras": "1c,14b,20b"
},
"src/branch/switch.js": {
"functions": "100.00 %",
"branches": "40.91 %",
Expand Down
22 changes: 15 additions & 7 deletions test/snapshot/istanbul.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"type": "istanbul",
"summary": {
"lines": "82.12 %",
"statements": "82.05 %",
"functions": "76.82 %",
"branches": "58.33 %"
"lines": "82.54 %",
"statements": "82.46 %",
"functions": "77.38 %",
"branches": "58.80 %"
},
"files": {
"async.js": {
Expand All @@ -24,11 +24,11 @@
"extras": ""
},
"branch/branch.js": {
"lines": "86.11 %",
"lines": "86.48 %",
"functions": "70.00 %",
"statements": "86.48 %",
"statements": "86.84 %",
"branches": "65.85 %",
"uncoveredLines": "10-17,58,81,119-120,137",
"uncoveredLines": "11-18,59,82,120-121,138",
"extras": ""
},
"branch/conditional.js": {
Expand All @@ -55,6 +55,14 @@
"uncoveredLines": "",
"extras": ""
},
"branch/switch-no-break.js": {
"lines": "100.00 %",
"functions": "100.00 %",
"statements": "100.00 %",
"branches": "100.00 %",
"uncoveredLines": "",
"extras": ""
},
"branch/switch.js": {
"lines": "70.00 %",
"functions": "100.00 %",
Expand Down
29 changes: 19 additions & 10 deletions test/snapshot/merge.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"type": "v8",
"summary": {
"bytes": "75.52 %",
"statements": "77.92 %",
"branches": "59.73 %",
"functions": "72.38 %",
"lines": "64.87 %"
"bytes": "75.97 %",
"statements": "78.39 %",
"branches": "59.80 %",
"functions": "72.90 %",
"lines": "65.58 %"
},
"files": {
"my-vm-filename.js": {
Expand Down Expand Up @@ -83,11 +83,11 @@
"test/mock/src/branch/branch.js": {
"functions": "70.00 %",
"branches": "65.85 %",
"statements": "84.72 %",
"lines": "73.87 %",
"bytes": "80.92 %",
"uncoveredLines": "9-19,27,56-59,73,80-82,107,118-123,135-138,143-145",
"extras": "1c,2b,8b,14b,16c,20b,25b,26c,29b,30c,34b,35c,36c,37c,38c,42b,44b,46b,55b,57c,60b,69b,71b,72c,75b,76c,84b,86b,97b,99b,104b,106c,110b,112b,114b,116b,117b,121c,124b,126b,133b,134b,136c,139b,140c,141c,149b,155b,157b,161b"
"statements": "85.14 %",
"lines": "74.34 %",
"bytes": "81.49 %",
"uncoveredLines": "10-20,28,57-60,74,81-83,108,119-124,136-139,144-146",
"extras": "1c,2b,9b,15b,17c,21b,26b,27c,30b,31c,35b,36c,37c,38c,39c,43b,45b,47b,56b,58c,61b,70b,72b,73c,76b,77c,85b,87b,98b,100b,105b,107c,111b,113b,115b,117b,118b,122c,125b,127b,134b,135b,137c,140b,141c,142c,150b,158b,162b"
},
"test/mock/src/branch/conditional.js": {
"functions": "100.00 %",
Expand Down Expand Up @@ -116,6 +116,15 @@
"uncoveredLines": "22-23,33-34,38,45,48-49,59-60",
"extras": "1c,2b,4b,10b,15b,19b,25b,29b,36b,40b,47b,51b,58b,62b,65b,66b,68b,73b,75b"
},
"test/mock/src/branch/switch-no-break.js": {
"functions": "100.00 %",
"branches": "66.67 %",
"statements": "100.00 %",
"lines": "100.00 %",
"bytes": "100.00 %",
"uncoveredLines": "",
"extras": "1c,14b,20b"
},
"test/mock/src/branch/switch.js": {
"functions": "100.00 %",
"branches": "40.91 %",
Expand Down
29 changes: 19 additions & 10 deletions test/snapshot/node-api.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"type": "v8",
"summary": {
"bytes": "83.35 %",
"statements": "84.04 %",
"branches": "60.43 %",
"functions": "88.46 %",
"lines": "70.53 %"
"bytes": "83.86 %",
"statements": "84.58 %",
"branches": "60.52 %",
"functions": "88.89 %",
"lines": "71.53 %"
},
"files": {
"monocart-coverage-reports/test/mock/node/src/index.js": {
Expand All @@ -29,11 +29,11 @@
"monocart-coverage-reports/test/mock/src/branch/branch.js": {
"functions": "70.00 %",
"branches": "65.85 %",
"statements": "84.72 %",
"lines": "73.87 %",
"bytes": "80.92 %",
"uncoveredLines": "9-19,27,56-59,73,80-82,107,118-123,135-138,143-145",
"extras": "1c,2b,8b,14b,16c,20b,25b,26c,29b,30c,34b,35c,36c,37c,38c,42b,44b,46b,55b,57c,60b,69b,71b,72c,75b,76c,84b,86b,97b,99b,104b,106c,110b,112b,114b,116b,117b,121c,124b,126b,133b,134b,136c,139b,140c,141c,149b,155b,157b,161b"
"statements": "85.14 %",
"lines": "74.34 %",
"bytes": "81.49 %",
"uncoveredLines": "10-20,28,57-60,74,81-83,108,119-124,136-139,144-146",
"extras": "1c,2b,9b,15b,17c,21b,26b,27c,30b,31c,35b,36c,37c,38c,39c,43b,45b,47b,56b,58c,61b,70b,72b,73c,76b,77c,85b,87b,98b,100b,105b,107c,111b,113b,115b,117b,118b,122c,125b,127b,134b,135b,137c,140b,141c,142c,150b,158b,162b"
},
"monocart-coverage-reports/test/mock/src/branch/conditional.js": {
"functions": "100.00 %",
Expand Down Expand Up @@ -62,6 +62,15 @@
"uncoveredLines": "22-23,33-34,38,45,48-49,59-60",
"extras": "1c,2b,4b,10b,15b,19b,25b,29b,36b,40b,47b,51b,58b,62b,65b,66b,68b,73b,75b"
},
"monocart-coverage-reports/test/mock/src/branch/switch-no-break.js": {
"functions": "100.00 %",
"branches": "66.67 %",
"statements": "100.00 %",
"lines": "100.00 %",
"bytes": "100.00 %",
"uncoveredLines": "",
"extras": "1c,14b,20b"
},
"monocart-coverage-reports/test/mock/src/branch/switch.js": {
"functions": "100.00 %",
"branches": "40.91 %",
Expand Down
29 changes: 19 additions & 10 deletions test/snapshot/node-cdp.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"type": "v8",
"summary": {
"bytes": "83.35 %",
"statements": "84.04 %",
"branches": "60.43 %",
"functions": "88.46 %",
"lines": "70.53 %"
"bytes": "83.86 %",
"statements": "84.58 %",
"branches": "60.52 %",
"functions": "88.89 %",
"lines": "71.53 %"
},
"files": {
"monocart-coverage-reports/test/mock/node/src/index.js": {
Expand All @@ -29,11 +29,11 @@
"monocart-coverage-reports/test/mock/src/branch/branch.js": {
"functions": "70.00 %",
"branches": "65.85 %",
"statements": "84.72 %",
"lines": "73.87 %",
"bytes": "80.92 %",
"uncoveredLines": "9-19,27,56-59,73,80-82,107,118-123,135-138,143-145",
"extras": "1c,2b,8b,14b,16c,20b,25b,26c,29b,30c,34b,35c,36c,37c,38c,42b,44b,46b,55b,57c,60b,69b,71b,72c,75b,76c,84b,86b,97b,99b,104b,106c,110b,112b,114b,116b,117b,121c,124b,126b,133b,134b,136c,139b,140c,141c,149b,155b,157b,161b"
"statements": "85.14 %",
"lines": "74.34 %",
"bytes": "81.49 %",
"uncoveredLines": "10-20,28,57-60,74,81-83,108,119-124,136-139,144-146",
"extras": "1c,2b,9b,15b,17c,21b,26b,27c,30b,31c,35b,36c,37c,38c,39c,43b,45b,47b,56b,58c,61b,70b,72b,73c,76b,77c,85b,87b,98b,100b,105b,107c,111b,113b,115b,117b,118b,122c,125b,127b,134b,135b,137c,140b,141c,142c,150b,158b,162b"
},
"monocart-coverage-reports/test/mock/src/branch/conditional.js": {
"functions": "100.00 %",
Expand Down Expand Up @@ -62,6 +62,15 @@
"uncoveredLines": "22-23,33-34,38,45,48-49,59-60",
"extras": "1c,2b,4b,10b,15b,19b,25b,29b,36b,40b,47b,51b,58b,62b,65b,66b,68b,73b,75b"
},
"monocart-coverage-reports/test/mock/src/branch/switch-no-break.js": {
"functions": "100.00 %",
"branches": "66.67 %",
"statements": "100.00 %",
"lines": "100.00 %",
"bytes": "100.00 %",
"uncoveredLines": "",
"extras": "1c,14b,20b"
},
"monocart-coverage-reports/test/mock/src/branch/switch.js": {
"functions": "100.00 %",
"branches": "40.91 %",
Expand Down
29 changes: 19 additions & 10 deletions test/snapshot/node-env.snapshot.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"type": "v8",
"summary": {
"bytes": "83.35 %",
"statements": "84.04 %",
"branches": "60.43 %",
"functions": "88.46 %",
"lines": "70.53 %"
"bytes": "83.86 %",
"statements": "84.58 %",
"branches": "60.52 %",
"functions": "88.89 %",
"lines": "71.53 %"
},
"files": {
"monocart-coverage-reports/test/mock/node/src/index.js": {
Expand All @@ -29,11 +29,11 @@
"monocart-coverage-reports/test/mock/src/branch/branch.js": {
"functions": "70.00 %",
"branches": "65.85 %",
"statements": "84.72 %",
"lines": "73.87 %",
"bytes": "80.92 %",
"uncoveredLines": "9-19,27,56-59,73,80-82,107,118-123,135-138,143-145",
"extras": "1c,2b,8b,14b,16c,20b,25b,26c,29b,30c,34b,35c,36c,37c,38c,42b,44b,46b,55b,57c,60b,69b,71b,72c,75b,76c,84b,86b,97b,99b,104b,106c,110b,112b,114b,116b,117b,121c,124b,126b,133b,134b,136c,139b,140c,141c,149b,155b,157b,161b"
"statements": "85.14 %",
"lines": "74.34 %",
"bytes": "81.49 %",
"uncoveredLines": "10-20,28,57-60,74,81-83,108,119-124,136-139,144-146",
"extras": "1c,2b,9b,15b,17c,21b,26b,27c,30b,31c,35b,36c,37c,38c,39c,43b,45b,47b,56b,58c,61b,70b,72b,73c,76b,77c,85b,87b,98b,100b,105b,107c,111b,113b,115b,117b,118b,122c,125b,127b,134b,135b,137c,140b,141c,142c,150b,158b,162b"
},
"monocart-coverage-reports/test/mock/src/branch/conditional.js": {
"functions": "100.00 %",
Expand Down Expand Up @@ -62,6 +62,15 @@
"uncoveredLines": "22-23,33-34,38,45,48-49,59-60",
"extras": "1c,2b,4b,10b,15b,19b,25b,29b,36b,40b,47b,51b,58b,62b,65b,66b,68b,73b,75b"
},
"monocart-coverage-reports/test/mock/src/branch/switch-no-break.js": {
"functions": "100.00 %",
"branches": "66.67 %",
"statements": "100.00 %",
"lines": "100.00 %",
"bytes": "100.00 %",
"uncoveredLines": "",
"extras": "1c,14b,20b"
},
"monocart-coverage-reports/test/mock/src/branch/switch.js": {
"functions": "100.00 %",
"branches": "40.91 %",
Expand Down
Loading

0 comments on commit e70894b

Please sign in to comment.