|
|
@@ -22,7 +22,6 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import de.jplag.Token;
|
|
|
import de.jplag.TokenConstants;
|
|
|
-import de.jplag.TokenList;
|
|
|
import de.jplag.TokenPrinter;
|
|
|
|
|
|
class GoFrontendTest {
|
|
|
@@ -59,7 +58,7 @@ class GoFrontendTest {
|
|
|
@Test
|
|
|
void parseTestFiles() {
|
|
|
for (String fileName : testFiles) {
|
|
|
- TokenList tokens = language.parse(testFileLocation, new String[] {fileName});
|
|
|
+ List<Token> tokens = language.parse(testFileLocation, new String[] {fileName});
|
|
|
String output = TokenPrinter.printTokens(tokens, testFileLocation, List.of(fileName));
|
|
|
logger.info(output);
|
|
|
|
|
|
@@ -90,7 +89,7 @@ class GoFrontendTest {
|
|
|
* @param fileName a code sample file name
|
|
|
* @param tokens the TokenList generated from the sample
|
|
|
*/
|
|
|
- private void testSourceCoverage(String fileName, TokenList tokens) {
|
|
|
+ private void testSourceCoverage(String fileName, List<Token> tokens) {
|
|
|
File testFile = new File(testFileLocation, fileName);
|
|
|
|
|
|
List<String> lines = null;
|
|
|
@@ -104,7 +103,7 @@ class GoFrontendTest {
|
|
|
// All lines that contain code
|
|
|
var codeLines = getCodeLines(lines);
|
|
|
// All lines that contain a token
|
|
|
- var tokenLines = IntStream.range(0, tokens.size()).mapToObj(tokens::getToken).mapToInt(Token::getLine).distinct().boxed().toList();
|
|
|
+ var tokenLines = tokens.stream().mapToInt(Token::getLine).distinct().boxed().toList();
|
|
|
|
|
|
if (codeLines.size() > tokenLines.size()) {
|
|
|
List<Integer> missedLinesIndices = new ArrayList<>(codeLines);
|
|
|
@@ -157,8 +156,8 @@ class GoFrontendTest {
|
|
|
* @param tokens TokenList which is supposed to contain all types of tokens
|
|
|
* @param fileName The file name of the complete code example
|
|
|
*/
|
|
|
- private void testTokenCoverage(TokenList tokens, String fileName) {
|
|
|
- var foundTokens = StreamSupport.stream(tokens.allTokens().spliterator(), true).mapToInt(Token::getType).sorted().distinct().boxed().toList();
|
|
|
+ private void testTokenCoverage(List<Token> tokens, String fileName) {
|
|
|
+ var foundTokens = StreamSupport.stream(tokens.spliterator(), true).mapToInt(Token::getType).sorted().distinct().boxed().toList();
|
|
|
|
|
|
// Exclude SEPARATOR_TOKEN, as it does not occur
|
|
|
var missingTokenTypes = IntStream.range(0, GoTokenConstants.NUM_DIFF_TOKENS).filter(i -> i != TokenConstants.SEPARATOR_TOKEN).boxed()
|