aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources
diff options
context:
space:
mode:
authorVladislav Lisetskii <vladlis54@gmail.com>2017-04-09 21:18:16 +0300
committerRoman Ivanov <romani@users.noreply.github.com>2017-04-17 10:51:06 -0700
commit8de64da1a00da618106b03c68400a5b265ec2580 (patch)
tree920ee7f7fc2262c22a2c706193b62762e9335ad1 /src/test/resources
parentdc9e156d7a23b2caf979da8e552517545db01171 (diff)
downloadcheckstyle-8de64da1a00da618106b03c68400a5b265ec2580.tar.gz
Issue #3546: Add lambda in RightCurlyCheck
Diffstat (limited to 'src/test/resources')
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneLambda.java47
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSinglelineLambda.java49
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlySameLambda.java78
3 files changed, 174 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneLambda.java
new file mode 100644
index 000000000..bc76452bd
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneLambda.java
@@ -0,0 +1,47 @@
+package com.puppycrawl.tools.checkstyle.checks.blocks;
+
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class InputRightCurlyAloneLambda {
+
+ static Runnable r1 = () -> {
+ String.valueOf("Test rightCurly one!");
+ };
+
+ static Runnable r2 = () -> String.valueOf("Test rightCurly two!");
+
+ static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");}; //violation
+
+ static Runnable r4 = () -> {
+ String.valueOf("Test rightCurly four!");}; //violation
+
+ static Runnable r5 = () ->
+ {
+ String.valueOf("Test rightCurly five!");
+ };
+
+ static Runnable r6 = () -> {};
+
+ static Runnable r7 = () -> {
+ };
+
+ static Runnable r8 = () ->
+ {
+ };
+
+ static Runnable r9 = () -> {
+ String.valueOf("Test rightCurly nine!");
+ }; int i; // violation
+
+ void foo1() {
+ Stream.of("Hello").filter(s -> {
+ return s != null;
+ }
+ ).collect(Collectors.toList());
+
+ Stream.of("Hello").filter(s -> {
+ return s != null;
+ }).collect(Collectors.toList()); // violation
+ }
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSinglelineLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSinglelineLambda.java
new file mode 100644
index 000000000..9c4a3008f
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlyAloneOrSinglelineLambda.java
@@ -0,0 +1,49 @@
+package com.puppycrawl.tools.checkstyle.checks.blocks;
+
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class InputRightCurlyAloneOrSinglelineLambda {
+
+ static Runnable r1 = () -> {
+ String.valueOf("Test rightCurly one!");
+ };
+
+ static Runnable r2 = () -> String.valueOf("Test rightCurly two!");
+
+ static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");};
+
+ static Runnable r4 = () -> {
+ String.valueOf("Test rightCurly four!");}; //violation
+
+ static Runnable r5 = () ->
+ {
+ String.valueOf("Test rightCurly five!");
+ };
+
+ static Runnable r6 = () -> {};
+
+ static Runnable r7 = () -> {
+ };
+
+ static Runnable r8 = () ->
+ {
+ };
+
+ static Runnable r9 = () -> {
+ String.valueOf("Test rightCurly nine!");
+ }; int i; // violation
+
+ void foo1() {
+ Stream.of("Hello").filter(s -> {
+ return s != null;
+ }
+ ).collect(Collectors.toList());
+
+ Stream.of("Hello").filter(s -> {
+ return s != null;
+ }).collect(Collectors.toList()); // violation
+
+ Stream.of("Hello").filter(s -> {return s != null;}).collect(Collectors.toList()); // violation
+ }
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlySameLambda.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlySameLambda.java
new file mode 100644
index 000000000..216556328
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputRightCurlySameLambda.java
@@ -0,0 +1,78 @@
+package com.puppycrawl.tools.checkstyle.checks.blocks;
+
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class InputRightCurlySameLambda {
+
+ static Runnable r1 = () -> {
+ String.valueOf("Test rightCurly one!");
+ };
+
+ static Runnable r2 = () -> String.valueOf("Test rightCurly two!");
+
+ static Runnable r3 = () -> {String.valueOf("Test rightCurly three!");};
+
+ static Runnable r4 = () -> {
+ String.valueOf("Test rightCurly four!");}; //violation
+
+ static Runnable r5 = () ->
+ {
+ String.valueOf("Test rightCurly five!");
+ };
+
+ static Runnable r6 = () -> {};
+
+ static Runnable r7 = () -> {
+ };
+
+ static Runnable r8 = () ->
+ {
+ };
+
+ static Runnable r9 = () -> {
+ String.valueOf("Test rightCurly nine!");
+ }; int i; // violation
+
+ void foo1() {
+ Stream.of("Hello").filter(s -> {
+ return s != null;
+ } // violation
+ ).collect(Collectors.toList());
+
+ Stream.of("Hello").filter(s -> {
+ return s != null;
+ }).collect(Collectors.toList());
+
+ Stream.of("Hello").filter(s -> {return s != null;})
+ .collect(Collectors.toList());
+
+ Stream.of("Hello").filter(s -> {return s != null;}).collect(Collectors.toList());
+
+ Stream.of("Hello").filter(s -> {
+ return s != null;}).collect(Collectors.toList()); // violation
+
+ bar(() -> {return;}, () -> {return;});
+
+ bar(() -> {
+ return;
+ }, () -> {return;});
+
+ bar(() -> {
+ return;
+ }, () -> {
+ return;
+ });
+
+ bar(() -> {
+ return;}, () -> {return;}); // violation
+
+ bar(() -> {
+ return;
+ }, () -> {
+ return;}); // violation
+
+ }
+
+ void bar(Runnable r1, Runnable r2) { }
+}