View Javadoc
1   ///////////////////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code and other text files for adherence to a set of rules.
3   // Copyright (C) 2001-2024 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  ///////////////////////////////////////////////////////////////////////////////////////////////
19  
20  package com.puppycrawl.tools.checkstyle.grammar.java8;
21  
22  import org.junit.jupiter.api.Test;
23  
24  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
25  import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
26  
27  public class LambdaTest extends AbstractModuleTestSupport {
28  
29      @Override
30      protected String getPackageLocation() {
31          return "com/puppycrawl/tools/checkstyle/grammar/java8";
32      }
33  
34      @Test
35      public void testLambdaInVariableInitialization()
36              throws Exception {
37          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
38          verifyWithInlineConfigParser(getPath("InputLambda1.java"), expected);
39      }
40  
41      @Test
42      public void testWithoutArgsOneLineLambdaBody()
43              throws Exception {
44          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
45          verifyWithInlineConfigParser(getPath("InputLambda2.java"), expected);
46      }
47  
48      @Test
49      public void testWithoutArgsFullLambdaBody()
50              throws Exception {
51          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
52          verifyWithInlineConfigParser(getPath("InputLambda3.java"), expected);
53      }
54  
55      @Test
56      public void testWithOneArgWithOneLineBody()
57              throws Exception {
58          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
59          verifyWithInlineConfigParser(getPath("InputLambda4.java"), expected);
60      }
61  
62      @Test
63      public void testWithOneArgWithFullBody()
64              throws Exception {
65          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
66          verifyWithInlineConfigParser(getPath("InputLambda5.java"), expected);
67      }
68  
69      @Test
70      public void testWithOneArgWithoutTypeOneLineBody()
71              throws Exception {
72          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
73          verifyWithInlineConfigParser(getPath("InputLambda6.java"), expected);
74      }
75  
76      @Test
77      public void testWithOneArgWithoutTypeFullBody()
78              throws Exception {
79          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
80          verifyWithInlineConfigParser(getPath("InputLambda7.java"), expected);
81      }
82  
83      @Test
84      public void testWithFewArgsWithoutTypeOneLineBody()
85              throws Exception {
86          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
87          verifyWithInlineConfigParser(getPath("InputLambda8.java"), expected);
88      }
89  
90      @Test
91      public void testWithFewArgsWithoutTypeFullBody()
92              throws Exception {
93          final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
94          verifyWithInlineConfigParser(getPath("InputLambda9.java"), expected);
95      }
96  
97      @Test
98      public void testWithOneArgWithoutParenthesesWithoutTypeOneLineBody()
99              throws Exception {
100         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
101         verifyWithInlineConfigParser(getPath("InputLambda10.java"), expected);
102     }
103 
104     @Test
105     public void testWithOneArgWithoutParenthesesWithoutTypeFullBody()
106             throws Exception {
107         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
108         verifyWithInlineConfigParser(getPath("InputLambda11.java"), expected);
109     }
110 
111     @Test
112     public void testWithFewArgWithTypeOneLine()
113             throws Exception {
114         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
115         verifyWithInlineConfigParser(getPath("InputLambda12.java"), expected);
116     }
117 
118     @Test
119     public void testWithFewArgWithTypeFullBody()
120             throws Exception {
121         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
122         verifyWithInlineConfigParser(getPath("InputLambda13.java"), expected);
123     }
124 
125     @Test
126     public void testWithMultilineBody()
127             throws Exception {
128         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
129         verifyWithInlineConfigParser(getPath("InputLambda14.java"), expected);
130     }
131 
132     @Test
133     public void testCasesFromSpec()
134             throws Exception {
135         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
136         verifyWithInlineConfigParser(getPath("InputLambda15.java"), expected);
137     }
138 
139     @Test
140     public void testWithTypecast()
141             throws Exception {
142         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
143         verifyWithInlineConfigParser(getPath("InputLambda16.java"), expected);
144     }
145 
146     @Test
147     public void testInAssignment()
148             throws Exception {
149         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
150         verifyWithInlineConfigParser(getPath("InputLambda17.java"), expected);
151     }
152 
153     @Test
154     public void testInTernary()
155             throws Exception {
156         final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
157         verifyWithInlineConfigParser(getPath("InputLambda18.java"), expected);
158     }
159 
160 }