Skip to content

Commit efa7565

Browse files
committed
test(visitors): add tests for conditionless for loops
1 parent 76060ff commit efa7565

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// one for-statement
2+
for (;;) {
3+
// one break-statement
4+
break;
5+
}

test/spec/for-statements.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ test('coverage should count for-statement test expressions', t => {
3939
});
4040
});
4141

42+
test('coverage should count conditionless for-statements', t => {
43+
t.plan(2);
44+
runFixture('for-statements-no-condition').then(({locations}) => {
45+
const expressionLocations = locations.filter(isExpression);
46+
const statementLocations = locations.filter(isStatement);
47+
48+
// There are two statements:
49+
t.equal(statementLocations.length, 2);
50+
// There are at 0 expressions:
51+
t.equal(expressionLocations.length, 0);
52+
});
53+
});
54+
4255
test.skip('coverage should count for-statement branches', t => {
4356
t.plan(2);
4457
runFixture('for-statements').then(({locations}) => {

0 commit comments

Comments
 (0)