1616
1717public class TestUtils {
1818
19- private static final Pattern EXPECTED_DIAGNOSTIC = Pattern .compile ("//\\ s*(.*?\\ b(Error|Warning)\\ b)" ,
20- Pattern .CASE_INSENSITIVE );
19+ private static final Pattern EXPECTED_DIAGNOSTIC = Pattern .compile ("//\\ s*(.*?\\ b(Error|Warning)\\ b)" , Pattern .CASE_INSENSITIVE );
2120 private final static Factory factory = new Launcher ().getFactory ();
2221 private final static Context context = Context .getInstance ();
2322
24- /**
25- * Determines if the given path indicates that the test should pass
26- *
27- * @param path
28- */
2923 public static boolean shouldPass (String path ) {
3024 return path .toLowerCase ().contains ("correct" );
3125 }
3226
33- /**
34- * Determines if the given path indicates that the test should fail
35- *
36- * @param path
37- */
3827 public static boolean shouldFail (String path ) {
3928 return path .toLowerCase ().contains ("error" );
4029 }
4130
42- /**
43- * Determines if the given path indicates that the test should report warnings
44- *
45- * @param path
46- */
4731 public static boolean shouldWarn (String path ) {
4832 return path .toLowerCase ().contains ("warning" );
4933 }
5034
51- /**
52- * Reads the expected error messages from the given file by looking for a comment containing the expected error
53- * message.
54- *
55- * @param filePath
56- *
57- * @return list of expected error messages found in the file, or empty list if there was an error reading the file
58- * or if there are no expected error messages in the file
59- */
6035 public static List <Pair <String , Integer >> getExpectedErrorsFromFile (Path filePath ) {
6136 return getExpectedDiagnosticsFromFile (filePath , "error" );
6237 }
@@ -79,39 +54,14 @@ private static List<Pair<String, Integer>> getExpectedDiagnosticsFromFile(Path f
7954 return expectedDiagnostics ;
8055 }
8156
82- /**
83- * Reads the expected warning messages from the given file by looking for a comment containing the expected warning
84- * message.
85- *
86- * @param filePath
87- *
88- * @return list of expected warning messages found in the file, or empty list if there was an error reading the file
89- * or if there are no expected warning messages in the file
90- */
9157 public static List <Pair <String , Integer >> getExpectedWarningsFromFile (Path filePath ) {
9258 return getExpectedDiagnosticsFromFile (filePath , "warning" );
9359 }
9460
95- /**
96- * Reads the expected error messages from all files in the given directory and combines them into a single list
97- *
98- * @param dirPath
99- *
100- * @return list of expected error messages from all files in the directory, or empty list if there was an error
101- * reading the directory or if there are no files in the directory
102- */
10361 public static List <Pair <String , Integer >> getExpectedErrorsFromDirectory (Path dirPath ) {
10462 return getExpectedDiagnosticsFromDirectory (dirPath , "error" );
10563 }
10664
107- /**
108- * Reads the expected warning messages from all files in the given directory and combines them into a single list.
109- *
110- * @param dirPath
111- *
112- * @return list of expected warning messages from all files in the directory, or empty list if there was an error
113- * reading the directory or if there are no files in the directory
114- */
11565 public static List <Pair <String , Integer >> getExpectedWarningsFromDirectory (Path dirPath ) {
11666 return getExpectedDiagnosticsFromDirectory (dirPath , "warning" );
11767 }
@@ -129,11 +79,7 @@ private static List<Pair<String, Integer>> getExpectedDiagnosticsFromDirectory(P
12979 return expectedDiagnostics ;
13080 }
13181
132- /**
133- * Helper method to add an integer variable to the context
134- */
13582 public static void addIntVariableToContext (String name ) {
136- context .addVarToContext (name , factory .Type ().INTEGER_PRIMITIVE , new Predicate (),
137- factory .Code ().createCodeSnippetStatement ("" ));
83+ context .addVarToContext (name , factory .Type ().INTEGER_PRIMITIVE , new Predicate (), factory .Code ().createCodeSnippetStatement ("" ));
13884 }
13985}
0 commit comments