@@ -30,6 +30,14 @@ ruleTester.run("no-fallthrough", rule, {
3030 "switch(foo) { case 0: a(); /* fall through */ case 1: b(); }" ,
3131 "switch(foo) { case 0: a(); /* fallthrough */ case 1: b(); }" ,
3232 "switch(foo) { case 0: a(); /* FALLS THROUGH */ case 1: b(); }" ,
33+ "switch(foo) { case 0: { a(); /* falls through */ } case 1: b(); }" ,
34+ "switch(foo) { case 0: { a()\n /* falls through */ } case 1: b(); }" ,
35+ "switch(foo) { case 0: { a(); /* fall through */ } case 1: b(); }" ,
36+ "switch(foo) { case 0: { a(); /* fallthrough */ } case 1: b(); }" ,
37+ "switch(foo) { case 0: { a(); /* FALLS THROUGH */ } case 1: b(); }" ,
38+ "switch(foo) { case 0: { a(); } /* falls through */ case 1: b(); }" ,
39+ "switch(foo) { case 0: { a(); /* falls through */ } /* comment */ case 1: b(); }" ,
40+ "switch(foo) { case 0: { /* falls through */ } case 1: b(); }" ,
3341 "function foo() { switch(foo) { case 0: a(); return; case 1: b(); }; }" ,
3442 "switch(foo) { case 0: a(); throw 'foo'; case 1: b(); }" ,
3543 "while (a) { switch(foo) { case 0: a(); continue; case 1: b(); } }" ,
@@ -133,6 +141,30 @@ ruleTester.run("no-fallthrough", rule, {
133141 code : "switch(foo) { case 0:\n\n default: b() }" ,
134142 errors : errorsDefault
135143 } ,
144+ {
145+ code : "switch(foo) { case 0: {} default: b() }" ,
146+ errors : errorsDefault
147+ } ,
148+ {
149+ code : "switch(foo) { case 0: a(); { /* falls through */ } default: b() }" ,
150+ errors : errorsDefault
151+ } ,
152+ {
153+ code : "switch(foo) { case 0: { /* falls through */ } a(); default: b() }" ,
154+ errors : errorsDefault
155+ } ,
156+ {
157+ code : "switch(foo) { case 0: if (a) { /* falls through */ } default: b() }" ,
158+ errors : errorsDefault
159+ } ,
160+ {
161+ code : "switch(foo) { case 0: { { /* falls through */ } } default: b() }" ,
162+ errors : errorsDefault
163+ } ,
164+ {
165+ code : "switch(foo) { case 0: { /* comment */ } default: b() }" ,
166+ errors : errorsDefault
167+ } ,
136168 {
137169 code : "switch(foo) { case 0:\n // comment\n default: b() }" ,
138170 errors : errorsDefault
@@ -168,6 +200,20 @@ ruleTester.run("no-fallthrough", rule, {
168200 column : 1
169201 }
170202 ]
203+ } ,
204+ {
205+ code : "switch(foo) { case 0: { a();\n/* no break */\n/* todo: fix readability */ }\ndefault: b() }" ,
206+ options : [ {
207+ commentPattern : "no break"
208+ } ] ,
209+ errors : [
210+ {
211+ messageId : "default" ,
212+ type : "SwitchCase" ,
213+ line : 4 ,
214+ column : 1
215+ }
216+ ]
171217 }
172218 ]
173219} ) ;
0 commit comments