1010
1111// Test cases for a parser of https://www.slashdev.ca/javapp/
1212public class JPPParserTest {
13- private record TestCase ( String formula , String expected ) {
13+ private record TestCase < Input , Expected >( Input input , Expected expected ) {
1414 }
1515
1616 private record ThrowingTestCase (String formula ) {
1717 }
1818
19- private static List <JPPParserTest .TestCase > testCases () {
19+ private static List <JPPParserTest .TestCase < String , String >> abstractionTests () {
2020 return List .of (
2121 /// #if expression
2222 // expression := <operand> <operator> <operand> | [!]defined(name)
2323 // expression := operand == operand
24- new JPPParserTest .TestCase ("//#if 1 == -42" , "1__EQ____U_MINUS__42" ),
24+ new JPPParserTest .TestCase <> ("//#if 1 == -42" , "1__EQ____U_MINUS__42" ),
2525 // expression := operand != operand
26- new JPPParserTest .TestCase ("// #if 1 != 0" , "1__NEQ__0" ),
26+ new JPPParserTest .TestCase <> ("// #if 1 != 0" , "1__NEQ__0" ),
2727 // expression := operand <= operand
28- new JPPParserTest .TestCase ("//#if -1 <= 0" , "__U_MINUS__1__LEQ__0" ),
28+ new JPPParserTest .TestCase <> ("//#if -1 <= 0" , "__U_MINUS__1__LEQ__0" ),
2929 // expression := operand < operand
30- new JPPParserTest .TestCase ("//#if \" str\" < 0" , "__QUOTE__str__QUOTE____LT__0" ),
30+ new JPPParserTest .TestCase <> ("//#if \" str\" < 0" , "__QUOTE__str__QUOTE____LT__0" ),
3131 // expression := operand >= operand
32- new JPPParserTest .TestCase ("// #if \" str\" >= \" str\" " , "__QUOTE__str__QUOTE____GEQ____QUOTE__str__QUOTE__" ),
32+ new JPPParserTest .TestCase <> ("// #if \" str\" >= \" str\" " , "__QUOTE__str__QUOTE____GEQ____QUOTE__str__QUOTE__" ),
3333 // expression := operand > operand
34- new JPPParserTest .TestCase ("// #if 1.2 > 0" , "1__DOT__2__GT__0" ),
34+ new JPPParserTest .TestCase <> ("// #if 1.2 > 0" , "1__DOT__2__GT__0" ),
3535 // expression := defined(name)
36- new JPPParserTest .TestCase ("//#if defined(property)" , "DEFINED_property" ),
36+ new JPPParserTest .TestCase <> ("//#if defined(property)" , "DEFINED_property" ),
3737 // expression := !defined(name)
38- new JPPParserTest .TestCase ("//#if !defined(property)" , "__U_NOT__DEFINED_property" ),
38+ new JPPParserTest .TestCase <> ("//#if !defined(property)" , "__U_NOT__DEFINED_property" ),
3939 // operand := ${property}
40- new JPPParserTest .TestCase ("//#if ${os_version} == 4.1" , "os_version__EQ__4__DOT__1" ),
40+ new JPPParserTest .TestCase <> ("//#if ${os_version} == 4.1" , "os_version__EQ__4__DOT__1" ),
4141
4242 /// #if expression and expression
43- new JPPParserTest .TestCase ("//#if 1 > 2 and defined( FEAT_A )" , "1__GT__2&&DEFINED_FEAT_A" ),
43+ new JPPParserTest .TestCase <> ("//#if 1 > 2 and defined( FEAT_A )" , "1__GT__2&&DEFINED_FEAT_A" ),
4444
4545 /// #if expression or expression
46- new JPPParserTest .TestCase ("//#if !defined(left) or defined(right)" , "__U_NOT__DEFINED_left||DEFINED_right" ),
46+ new JPPParserTest .TestCase <> ("//#if !defined(left) or defined(right)" , "__U_NOT__DEFINED_left||DEFINED_right" ),
4747
4848 /// #if expression and expression or expression
49- new JPPParserTest .TestCase ("//#if ${os_version} == 4.1 and 1 > -42 or defined(ALL)" , "os_version__EQ__4__DOT__1&&1__GT____U_MINUS__42||DEFINED_ALL" )
49+ new JPPParserTest .TestCase <> ("//#if ${os_version} == 4.1 and 1 > -42 or defined(ALL)" , "os_version__EQ__4__DOT__1&&1__GT____U_MINUS__42||DEFINED_ALL" )
5050 );
5151 }
5252
@@ -72,11 +72,11 @@ private static List<JPPParserTest.ThrowingTestCase> throwingTestCases() {
7272 }
7373
7474 @ ParameterizedTest
75- @ MethodSource ("testCases " )
75+ @ MethodSource ("abstractionTests " )
7676 public void testCase (JPPParserTest .TestCase testCase ) throws UnparseableFormulaException {
7777 assertEquals (
7878 testCase .expected ,
79- new JPPDiffLineFormulaExtractor ().extractFormula (testCase .formula ())
79+ new JPPDiffLineFormulaExtractor ().extractFormula (( String ) testCase .input ())
8080 );
8181 }
8282
0 commit comments