|
@@ -1,13 +1,6 @@
|
|
|
package de.jplag.scala;
|
|
package de.jplag.scala;
|
|
|
|
|
|
|
|
-import de.jplag.Token;
|
|
|
|
|
-import de.jplag.TokenConstants;
|
|
|
|
|
-import de.jplag.TokenList;
|
|
|
|
|
-import de.jplag.TokenPrinter;
|
|
|
|
|
-import org.junit.jupiter.api.BeforeEach;
|
|
|
|
|
-import org.junit.jupiter.api.Test;
|
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
+import static org.junit.jupiter.api.Assertions.fail;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -19,7 +12,15 @@ import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
import java.util.stream.IntStream;
|
|
|
import java.util.stream.StreamSupport;
|
|
import java.util.stream.StreamSupport;
|
|
|
|
|
|
|
|
-import static org.junit.jupiter.api.Assertions.fail;
|
|
|
|
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+
|
|
|
|
|
+import de.jplag.Token;
|
|
|
|
|
+import de.jplag.TokenConstants;
|
|
|
|
|
+import de.jplag.TokenList;
|
|
|
|
|
+import de.jplag.TokenPrinter;
|
|
|
|
|
|
|
|
class ScalaFrontendTest {
|
|
class ScalaFrontendTest {
|
|
|
|
|
|
|
@@ -46,7 +47,7 @@ class ScalaFrontendTest {
|
|
|
private static final int NOT_SET = -1;
|
|
private static final int NOT_SET = -1;
|
|
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger("Scala frontend test");
|
|
private final Logger logger = LoggerFactory.getLogger("Scala frontend test");
|
|
|
- private final String[] testFiles = new String[]{"Complete.scala", "Parser.scala"};
|
|
|
|
|
|
|
+ private final String[] testFiles = new String[] {"Complete.scala", "Parser.scala"};
|
|
|
private final File testFileLocation = Path.of("src", "test", "resources", "de", "jplag", "scala").toFile();
|
|
private final File testFileLocation = Path.of("src", "test", "resources", "de", "jplag", "scala").toFile();
|
|
|
private Language language;
|
|
private Language language;
|
|
|
|
|
|
|
@@ -58,7 +59,7 @@ class ScalaFrontendTest {
|
|
|
@Test
|
|
@Test
|
|
|
void parseTestFiles() {
|
|
void parseTestFiles() {
|
|
|
for (String fileName : testFiles) {
|
|
for (String fileName : testFiles) {
|
|
|
- TokenList tokens = language.parse(testFileLocation, new String[]{fileName});
|
|
|
|
|
|
|
+ TokenList tokens = language.parse(testFileLocation, new String[] {fileName});
|
|
|
String output = TokenPrinter.printTokens(tokens, testFileLocation, List.of(fileName));
|
|
String output = TokenPrinter.printTokens(tokens, testFileLocation, List.of(fileName));
|
|
|
logger.info(output);
|
|
logger.info(output);
|
|
|
|
|
|
|
@@ -88,9 +89,8 @@ class ScalaFrontendTest {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Confirms that the code is covered to a basic extent, i.e. each line of code contains at least one token.
|
|
* Confirms that the code is covered to a basic extent, i.e. each line of code contains at least one token.
|
|
|
- *
|
|
|
|
|
* @param fileName a code sample file name
|
|
* @param fileName a code sample file name
|
|
|
- * @param tokens the TokenList generated from the sample
|
|
|
|
|
|
|
+ * @param tokens the TokenList generated from the sample
|
|
|
*/
|
|
*/
|
|
|
private void testSourceCoverage(String fileName, TokenList tokens) {
|
|
private void testSourceCoverage(String fileName, TokenList tokens) {
|
|
|
File testFile = new File(testFileLocation, fileName);
|
|
File testFile = new File(testFileLocation, fileName);
|
|
@@ -125,7 +125,6 @@ class ScalaFrontendTest {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Gets the line numbers of lines containing actual code, omitting empty lines and comment lines.
|
|
* Gets the line numbers of lines containing actual code, omitting empty lines and comment lines.
|
|
|
- *
|
|
|
|
|
* @param lines lines of a code file
|
|
* @param lines lines of a code file
|
|
|
* @return an array of the line numbers of code lines
|
|
* @return an array of the line numbers of code lines
|
|
|
*/
|
|
*/
|
|
@@ -158,8 +157,7 @@ class ScalaFrontendTest {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Confirms that all Token types are 'reachable' with a complete code example.
|
|
* Confirms that all Token types are 'reachable' with a complete code example.
|
|
|
- *
|
|
|
|
|
- * @param tokens TokenList which is supposed to contain all types of tokens
|
|
|
|
|
|
|
+ * @param tokens TokenList which is supposed to contain all types of tokens
|
|
|
* @param fileName The file name of the complete code example
|
|
* @param fileName The file name of the complete code example
|
|
|
*/
|
|
*/
|
|
|
private void testTokenCoverage(TokenList tokens, String fileName) {
|
|
private void testTokenCoverage(TokenList tokens, String fileName) {
|