Tests and testinputs have been created.

This commit is contained in:
Ilja Dubinin 2014-05-02 14:55:52 +04:00 committed by Ilja Dubinin
parent 95f3a80071
commit 0b1e5a3fdb
22 changed files with 562 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
public class AnnotationsTest extends BaseCheckTestSupport {
@Test
public void testInlineAnnotation()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputAnnotationsTest1.java"), expected);
}
@Test
public void testRepeatebleAnnotation()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputAnnotationsTest2.java"), expected);
}
}

View File

@ -0,0 +1,22 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
public class DefaulMethodsTest extends BaseCheckTestSupport {
@Test
public void testCanParse()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputDefaultMethodsTest.java"), expected);
}
}

View File

@ -0,0 +1,165 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
public class LambdaTest extends BaseCheckTestSupport {
@Test
public void testLambdaInVariableInitialization()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest1.java"), expected);
}
@Test
public void testWithoutArgsOneLineLambdaBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest2.java"), expected);
}
@Test
public void testWithoutArgsFullLambdaBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest3.java"), expected);
}
@Test
public void testWithOneArgWithOneLineBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest4.java"), expected);
}
@Test
public void testWithOneArgWithFullBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest5.java"), expected);
}
@Test
public void testWithOneArgWIthoutTypeOneLineBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest6.java"), expected);
}
@Test
public void testWithOneArgWIthoutTypeFullBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest7.java"), expected);
}
@Test
public void testWithFewArgsWithoutTypeOneLineBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest8.java"), expected);
}
@Test
public void testWithFewArgsWithoutTypeFullBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest9.java"), expected);
}
@Test
public void testWithOneArgWIthoutParenthesesWithoutTypeOneLineBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest10.java"), expected);
}
@Test
public void testWithOneArgWIthoutParenthesesWithoutTypeFullBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest11.java"), expected);
}
@Test
public void testWithFewArgWIthTypeOneLine()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest12.java"), expected);
}
@Test
public void testWithFewArgWithTypeFullBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest13.java"), expected);
}
@Test
public void testWIthMultilineBody()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputLambdaTest14.java"), expected);
}
}

View File

@ -0,0 +1,21 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import org.junit.Test;
import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck;
public class MethodReferencesTest extends BaseCheckTestSupport {
@Test
public void testCanParse()
throws Exception
{
final DefaultConfiguration checkConfig =
createCheckConfig(MemberNameCheck.class);
final String[] expected = {};
verify(checkConfig, getPath("grammars/java8/InputMethodReferencesTest.java"), expected);
}
}

View File

@ -0,0 +1,38 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
public class InputTypeAnnotationsTest1 {
@NonNull
List<Integer> numbers;
public static void main(String[] args) {
Object str = "";
String myString = (@NonNull String) str;
Object object = new @Interned Object();
}
void monitorTemperature() throws @Critical Exception { }
abstract class UnmodifiableList<T> implements @Readonly List<@Readonly T> {
}
@interface NonNull {
}
@interface Readonly {
}
@interface Interned {
}
@interface Critical {
}
}

View File

@ -0,0 +1,13 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
@Schedule
public class InputTypeAnnotationsTest2 {
@Repeatable(Schedules.class)
public @interface Schedule {
Schedule[] value;
}
}

View File

@ -0,0 +1,11 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public interface InputDefaultMethods {
default public void doSomething(){
System.out.println("Something done.");
}
public void doOneMoreThing();
}

View File

@ -0,0 +1,12 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest1 {
static Runnable r1 = ()->System.out.println("Hello world one!");
static Runnable r2 = () -> System.out.println("Hello world two!");
public static void main(String[] args) {
r1.run();
r2.run();
}
}

View File

@ -0,0 +1,20 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest10 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth("fef");
}
public static void main(String[] args) {
testVoidLambda(s1 -> System.out.println(s1));
}
private interface TestOfVoidLambdas {
public void doSmth(String first);
}
}

View File

@ -0,0 +1,20 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest11 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth("fef");
}
public static void main(String[] args) {
testVoidLambda(s1 -> {System.out.println(s1);});
}
private interface TestOfVoidLambdas {
public void doSmth(String first);
}
}

View File

@ -0,0 +1,20 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest12 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth("fef", 5);
}
public static void main(String[] args) {
testVoidLambda((String s1, Integer i2) -> System.out.println(s1));
}
private interface TestOfVoidLambdas {
public void doSmth(String first, Integer second);
}
}

View File

@ -0,0 +1,22 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest12 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth("fef", 5);
}
public static void main(String[] args) {
testVoidLambda((String s1, Integer i2) -> {
System.out.println(s1);
});
}
private interface TestOfVoidLambdas {
public void doSmth(String first, Integer second);
}
}

View File

@ -0,0 +1,18 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
public class InputLambdaTest14 {
public static void main(String args[]) {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);
numbers.forEach(first -> {
System.out.println("first");
System.out.println("second");
System.out.println("third");
});
}
}

View File

@ -0,0 +1,24 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
import TestLabmda.TestOfVoidLambdas;
public class InputLabdaTest2 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth();
}
public static void main(String[] args) {
testVoidLambda(() -> System.out.println("Method in interface called"));
}
private interface TestOfVoidLambdas {
public void doSmth();
}
}

View File

@ -0,0 +1,26 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
import TestLabmda.TestOfVoidLambdas;
public class InputLabdaTest3 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth();
}
public static void main(String[] args) {
testVoidLambda(() -> {
System.out.println("Method in interface called");
});
}
private interface TestOfVoidLambdas {
public void doSmth();
}
}

View File

@ -0,0 +1,10 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest4 {
public void doSomething() {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
numbers.forEach((Integer value) -> System.out.println(value));
}
}

View File

@ -0,0 +1,10 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest5 {
public void doSomething() {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
numbers.forEach((Integer value) -> {System.out.println(value);});
}
}

View File

@ -0,0 +1,10 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest6 {
public void doSomething() {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
numbers.forEach((value) -> System.out.println(value));
}
}

View File

@ -0,0 +1,15 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
public class InputLabdaTest7 {
public void doSomething() {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
numbers.forEach((value) -> {
System.out.println(value);
});
}
}

View File

@ -0,0 +1,19 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest8 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth("fef", 2);
}
public static void main(String[] args) {
testVoidLambda((s1, s2) -> System.out.println(s1 + s2));
}
private interface TestOfVoidLambdas {
public void doSmth(String first, Integer second);
}
}

View File

@ -0,0 +1,19 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
public class InputLabdaTest9 {
public static void testVoidLambda(TestOfVoidLambdas test) {
System.out.println("Method called");
test.doSmth("fef", 2);
}
public static void main(String[] args) {
testVoidLambda((s1, s2) -> {System.out.println(s1 + s2);});
}
private interface TestOfVoidLambdas {
public void doSmth(String first, Integer second);
}
}

View File

@ -0,0 +1,15 @@
package com.puppycrawl.tools.checkstyle.grammars.java8;
import java.util.Arrays;
import java.util.List;
public interface InputDefaultMethods {
public static void main(String args[]) {
List<Integer> numbers = Arrays.asList(1,2,3,4,5,6);
numbers.forEach(System.out::println);
}
}