Skip to content

Commit c5c8d71

Browse files
committed
Update Javadocs
1 parent ca52924 commit c5c8d71

2 files changed

Lines changed: 8 additions & 70 deletions

File tree

liquidjava-verifier/src/test/java/liquidjava/api/tests/TestExamples.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ public class TestExamples {
2727
Diagnostics diagnostics = Diagnostics.getInstance();
2828

2929
/**
30-
* Test the file at the given path by launching the verifier and checking for errors and warnings. The
31-
* file/directory is expected to be either correct, contain an error, or report warnings based on its name.
32-
*
33-
* @param path
34-
* path to the file to test
30+
* Runs the verifier and checks the expected diagnostics
3531
*/
3632
@ParameterizedTest
3733
@MethodSource("sourcePaths")
@@ -72,6 +68,9 @@ else if (shouldFail(pathName)) {
7268
}
7369
}
7470

71+
/**
72+
* Checks that the found diagnostics match the expected diagnostics
73+
*/
7574
private static void checkExpectedDiagnostics(String pathName, Collection<? extends LJDiagnostic> found,
7675
List<Pair<String, Integer>> expected, String output) {
7776
if (found.size() != expected.size()) {
@@ -102,13 +101,7 @@ private static boolean matches(LJDiagnostic diagnostic, Pair<String, Integer> ex
102101
}
103102

104103
/**
105-
* Returns a Stream of paths to test files in the testSuite directory. These include files with names starting with
106-
* "Correct" or "Error", and directories containing "correct" or "error". §
107-
*
108-
* @return Stream of paths to test files
109-
*
110-
* @throws IOException
111-
* if an I/O error occurs or the path does not exist
104+
* Returns the test suite paths to verify
112105
*/
113106
private static Stream<Path> sourcePaths() throws IOException {
114107
return Files.find(Paths.get("../liquidjava-example/src/main/java/testSuite/"), Integer.MAX_VALUE,
@@ -128,8 +121,7 @@ private static Stream<Path> sourcePaths() throws IOException {
128121
}
129122

130123
/**
131-
* Test multiple paths at once, including both files and directories. This test ensures that the verifier can handle
132-
* multiple inputs correctly and that no errors are found in files/directories that are expected to be correct.
124+
* Verifies that multiple correct inputs can be processed together
133125
*/
134126
@Test
135127
public void testMultiplePaths() {

liquidjava-verifier/src/test/java/liquidjava/utils/TestUtils.java

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,22 @@
1616

1717
public 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

Comments
 (0)