Issue #2161: unify test input locations for blocks package

This commit is contained in:
rnveach 2015-10-15 22:53:56 -04:00
parent 61f8aaca7b
commit bf529ef600
27 changed files with 443 additions and 115 deletions

View File

@ -23,6 +23,9 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck.MSG_
import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck.MSG_KEY_BLOCK_NO_STMT;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
@ -30,6 +33,11 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
public class EmptyBlockCheckTest
extends BaseCheckTestSupport {
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "blocks" + File.separator + filename);
}
/* Additional test for jacoco, since valueOf()
* is generated by javac and jacoco reports that
@ -47,14 +55,14 @@ public class EmptyBlockCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(EmptyBlockCheck.class);
final String[] expected = {
"75:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"77:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"79:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"82:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"178:5: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"206:29: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"208:41: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"219:12: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"33:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"35:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"37:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"40:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"63:5: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"71:29: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"73:41: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"84:12: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
};
verify(checkConfig, getPath("InputSemantic.java"), expected);
}
@ -66,11 +74,11 @@ public class EmptyBlockCheckTest
createCheckConfig(EmptyBlockCheck.class);
checkConfig.addAttribute("option", BlockOption.TEXT.toString());
final String[] expected = {
"75:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "try"),
"77:17: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "finally"),
"178:5: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "INSTANCE_INIT"),
"206:29: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "synchronized"),
"219:12: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "STATIC_INIT"),
"33:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "try"),
"35:17: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "finally"),
"63:5: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "INSTANCE_INIT"),
"71:29: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "synchronized"),
"84:12: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "STATIC_INIT"),
};
verify(checkConfig, getPath("InputSemantic.java"), expected);
}
@ -82,14 +90,14 @@ public class EmptyBlockCheckTest
createCheckConfig(EmptyBlockCheck.class);
checkConfig.addAttribute("option", BlockOption.STMT.toString());
final String[] expected = {
"75:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"77:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"79:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"82:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"178:5: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"206:29: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"208:41: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"219:12: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"33:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"35:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"37:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"40:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"63:5: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"71:29: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"73:41: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
"84:12: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
};
verify(checkConfig, getPath("InputSemantic.java"), expected);
}

View File

@ -25,6 +25,9 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_K
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.IOException;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Before;
import org.junit.Test;
@ -41,6 +44,12 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport {
checkConfig = createCheckConfig(LeftCurlyCheck.class);
}
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "blocks" + File.separator + filename);
}
/* Additional test for jacoco, since valueOf()
* is generated by javac and jacoco reports that
* valueOf() is uncovered.
@ -62,10 +71,10 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport {
public void testDefault() throws Exception {
final String[] expected = {
"8:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1),
"12:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"30:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"39:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"10:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"14:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"18:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"22:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
};
verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
}
@ -74,12 +83,12 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport {
public void testNL() throws Exception {
checkConfig.addAttribute("option", LeftCurlyOption.NL.toString());
final String[] expected = {
"49:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"53:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"58:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"62:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"67:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 12),
"72:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"27:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"31:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"36:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"40:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"45:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 12),
"50:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
};
verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
}
@ -89,16 +98,16 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport {
checkConfig.addAttribute("option", LeftCurlyOption.NLOW.toString());
final String[] expected = {
"8:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1),
"12:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"30:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"39:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"49:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"53:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"58:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"62:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"67:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 12),
"72:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"10:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"14:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"18:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"22:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5),
"27:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"31:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14),
"36:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"40:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
"45:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 12),
"50:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 18),
};
verify(checkConfig, getPath("InputScopeInnerInterfaces.java"), expected);
}

View File

@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle.checks.blocks;
import static com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck.MSG_KEY_NEED_BRACES;
import java.io.File;
import java.io.IOException;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
@ -30,6 +31,18 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
public class NeedBracesCheckTest extends BaseCheckTestSupport {
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "blocks" + File.separator + filename);
}
@Override
protected String getNonCompilablePath(String filename) throws IOException {
return super.getNonCompilablePath("checks" + File.separator
+ "blocks" + File.separator + filename);
}
@Test
public void testIt() throws Exception {
final DefaultConfiguration checkConfig =
@ -85,9 +98,7 @@ public class NeedBracesCheckTest extends BaseCheckTestSupport {
final String[] expected = {
"7: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"),
};
verify(checkConfig, new File("src/test/resources-noncompilable/com/puppycrawl/"
+ "tools/checkstyle/blocks/InputSingleLineLambda.java").getCanonicalPath(),
expected);
verify(checkConfig, getNonCompilablePath("InputSingleLineLambda.java"), expected);
}
@Test

View File

@ -25,6 +25,9 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_SAME;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.IOException;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Before;
import org.junit.Test;
@ -40,6 +43,12 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport {
checkConfig = createCheckConfig(RightCurlyCheck.class);
}
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "blocks" + File.separator + filename);
}
/* Additional test for jacoco, since valueOf()
* is generated by javac and jacoco reports that
* valueOf() is uncovered.
@ -160,57 +169,57 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport {
+ "LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, "
+ "STATIC_INIT, INSTANCE_INIT");
final String[] expected = {
"9:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"12:65: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 65),
"23:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
"27:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
"30:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
"33:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
"39:73: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 73),
"41:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
"46:58: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 58),
"48:97: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 97),
"51:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
"54:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
"61:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
"68:62: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 62),
"77:28: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 28),
"79:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21),
"81:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
"83:14: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 14),
"94:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
"104:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
"108:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
"112:52: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 52),
"112:112: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 112),
"115:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 18),
"119:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
"122:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
"124:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
"128:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"137:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"139:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"149:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"151:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
"8:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"11:65: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 65),
"22:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46),
"26:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31),
"29:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35),
"32:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36),
"38:73: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 73),
"40:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
"45:58: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 58),
"47:97: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 97),
"50:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
"53:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
"60:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38),
"67:62: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 62),
"76:28: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 28),
"78:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21),
"80:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20),
"82:14: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 14),
"93:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26),
"103:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
"107:29: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 29),
"111:52: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 52),
"111:112: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 112),
"114:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 18),
"118:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 23),
"121:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
"123:30: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 30),
"127:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"136:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"138:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"148:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"150:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
"151:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"151:93: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 93),
"152:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"152:93: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 93),
"153:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"154:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77),
"154:93: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 93),
"160:37: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 37),
"167:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
"182:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"189:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"189:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 13),
"198:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"198:10: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 10),
"202:49: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 49),
"202:50: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 50),
"205:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
"205:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
"205:77: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 77),
"209:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
"217:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
"153:93: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 93),
"159:37: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 37),
"166:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37),
"181:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"188:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"188:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 13),
"197:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9),
"197:10: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 10),
"201:49: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 49),
"201:50: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 50),
"204:75: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 75),
"204:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
"204:77: " + getCheckMessage(MSG_KEY_LINE_NEW, "}", 77),
"208:76: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 76),
"216:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27),
};
verify(checkConfig, getPath("InputRightCurlyAnnotations.java"), expected);

View File

@ -46,7 +46,7 @@ public class ParameterNameCheckTest
createCheckConfig(ParameterNameCheck.class);
checkConfig.addAttribute("format", "^NO_WAY_MATEY$");
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputLeftCurlyOther.java"), expected);
verify(checkConfig, getPath("checks/naming/InputCatchOnly.java"), expected);
}
@Test

View File

@ -1,5 +1,5 @@
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.blocks;
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputSingleLineLambda {
static Runnable r1 = ()->System.out.println("Hello world one!");

View File

@ -1,4 +0,0 @@
package com.puppycrawl.tools.checkstyle;import java.lang.annotation.ElementType;import java.lang.annotation.Target;import java.util.ArrayList;import java.util.List;class InputLeftCurlyAllInOneLine{
}

View File

@ -0,0 +1,119 @@
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.blocks;
/**
* Test case for correct use of braces.
* @author Oliver Burn
**/
class InputBraces
{
/** @return helper func **/
boolean condition()
{
return false;
}
/** Test do/while loops **/
void testDoWhile()
{
// Valid
do {
testDoWhile();
}
while (condition());
// Invalid
do testDoWhile(); while (condition());
}
/** Test while loops **/
void testWhile()
{
// Valid
while (condition()) {
testWhile();
}
// Invalid
while(condition());
while (condition())
testWhile();
while (condition())
if (condition())
testWhile();
}
/** Test for loops **/
void testFor()
{
// Valid
for (int i = 1; i < 5; i++) {
testFor();
}
// Invalid
for(int i = 1;i < 5;i++);
for (int i = 1; i < 5; i++)
testFor();
for (int i = 1; i < 5;
i++)
if (i > 2)
testFor();
}
/** Test if constructs **/
public void testIf()
{
// Valid
if (condition()) {
testIf();
}
else if (condition()) {
testIf();
}
else {
testIf();
}
// Invalid
if (condition());
if (condition())
testIf();
if (condition())
testIf();
else
testIf();
if (condition())
testIf();
else {
testIf();
}
if (condition()) {
testIf();
}
else
testIf();
if (condition())
if (condition())
testIf();
}
void whitespaceAfterSemi()
{
//reject
int i = 1;int j = 2;
//accept
for (;;) {
}
}
/** Empty constructor block. **/
public InputBraces() {}
/** Empty method block. **/
public void emptyImplementation() {}
}

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputBracesSingleLineStatements
{

View File

@ -0,0 +1,4 @@
package com.puppycrawl.tools.checkstyle.checks.blocks;import java.lang.annotation.ElementType;import java.lang.annotation.Target;import java.util.ArrayList;import java.util.List;class InputLeftCurlyAllInOneLine{
}

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputLeftCurlyEnums {
enum Colors {RED,

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

View File

@ -2,7 +2,7 @@
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
/**
* Test case for correct use of braces.

View File

@ -2,7 +2,7 @@
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
/**
* Test case for correct use of braces.

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputNeedBracesCheckTest
{

View File

@ -2,7 +2,7 @@
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
class InputRightCurly
{

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputRightCurlyAloneOrSingleline {

View File

@ -1,6 +1,5 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
@TestClassAnnotation
class InputRightCurlyAnnotations
{

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
abstract class CharSequenceReader{
abstract void moveTo(double deltaX, double deltaY);

View File

@ -1,4 +1,4 @@
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

View File

@ -2,7 +2,7 @@
// Test case file for checkstyle.
// Created: 2015
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
/**
* Test case for RightCurly with option SAME to omit oneliners

View File

@ -0,0 +1,52 @@
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputScopeInnerInterfaces
{
private interface PrivateInterface
{
}
interface PackageInnerInterface
{
}
protected interface ProtectedInnerInterface
{
}
public interface PublicInnerInterface
{
}
private
class
MyClass1 {
}
class
MyClass2 {
}
private
interface
MyInterface1 {
}
interface
MyInterface2 {
}
protected
enum
MyEnum {
}
private
@interface
MyAnnotation {
}
}

View File

@ -2,7 +2,7 @@
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
public class InputScopeInnerInterfaces2{
// inner interfaces with different scopes

View File

@ -0,0 +1,87 @@
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.blocks;
import java.io.*; // star import for instantiation tests
import java.awt.Dimension; // explicit import for instantiation tests
import java.awt.Color;
/**
* Test case for detecting empty block statements.
* @author Lars Kühne
**/
class InputSemantic
{
static {
Boolean x = new Boolean(true);
}
{
Boolean x = new Boolean(true);
Boolean[] y = new Boolean[]{Boolean.TRUE, Boolean.FALSE};
}
Boolean getBoolean()
{
return new java.lang.Boolean(true);
}
void exHandlerTest()
{
try {
}
finally {
}
try {
// something
}
finally {
// something
}
try {
; // something
}
finally {
; // statement
}
}
/** test **/
private static final long IGNORE = 666l + 666L;
public class EqualsVsHashCode1
{
public boolean equals(int a)
{
return a == 1;
}
}
// empty instance initializer
{
}
private class InputBraces {
}
synchronized void foo() {
synchronized (this) {} // not OK
synchronized (Class.class) { // OK
synchronized (new Object()) {
// not OK if checking statements
}
}
}
static {
int a = 0;}
static {
}
}

View File

@ -2,7 +2,7 @@
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle;
package com.puppycrawl.tools.checkstyle.checks.blocks;
import java.io.*; // star import for instantiation tests
import java.awt.Dimension; // explicit import for instantiation tests

View File

@ -0,0 +1,34 @@
package com.puppycrawl.tools.checkstyle.checks.naming;
/**
* Test case for skipping over catch names.
**/
public class InputCatchOnly {
int foo() {
if (System.currentTimeMillis() > 1000)
return 1;
int test = 0;
try
{
return 1;
}
catch (Exception e)
{
return 0;
}
}
public InputCatchOnly()
{
return;
}
class InnerFoo
{
public void fooInnerMethod ()
{
}
}
}