View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // Test case file for checkstyle.
3   // Created: 2001
4   ////////////////////////////////////////////////////////////////////////////////
5   package com.puppycrawl.tools.checkstyle.checks.blocks.emptyblock;
6   
7   import java.io.*; // star import for instantiation tests
8   import java.awt.Dimension; // explicit import for instantiation tests
9   import java.awt.Color;
10  
11  class InputEmptyBlockSemantic2
12  {
13  	public void fooMethod()
14  	{
15  		int a = 1;
16  		if (a == 1) {} //is not OK 
17  		char[] s = {'1', '2'};
18  		int index = 2;
19  		if (doSideEffect() == 1) {} //is not OK, 
20  		while ((a = index - 1) != 0) {} // is OK 
21  		for (; index < s.length && s[index] != 'x'; index++) {} // is OK
22  		if (a == 1) {} else {System.identityHashCode("a");} // is not OK
23  		switch (a) {} //warn
24  		switch (a) { //ok
25          case 1:
26              a = 2;
27          case 2:
28              a = 3;
29          default:
30              a = 0;
31          }
32  	}
33  	
34  	public int doSideEffect()
35  	{
36  		return 1;
37  	}
38  }