forked from phoedos/pmd
Convert groovy tests
This commit is contained in:
@ -45,10 +45,20 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd-lang-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -36,7 +36,11 @@ public class GroovyTokenizer implements Tokenizer {
|
||||
|
||||
int lastCol;
|
||||
if (token instanceof SourceInfo) {
|
||||
lastCol = ((SourceInfo) token).getColumnLast();
|
||||
lastCol = ((SourceInfo) token).getColumnLast() - 1;
|
||||
if (lastCol == 0) {
|
||||
// newline
|
||||
lastCol = token.getColumn() + 1;
|
||||
}
|
||||
} else {
|
||||
// fallback
|
||||
lastCol = token.getColumn() + tokenText.length();
|
||||
|
@ -4,34 +4,30 @@
|
||||
|
||||
package net.sourceforge.pmd.cpd;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
|
||||
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
||||
|
||||
public class GroovyTokenizerTest extends AbstractTokenizerTest {
|
||||
public class GroovyTokenizerTest extends CpdTextComparisonTest {
|
||||
|
||||
private static final String FILENAME = "BTree.groovy";
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void buildTokenizer() throws IOException {
|
||||
this.tokenizer = new GroovyTokenizer();
|
||||
this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), FILENAME));
|
||||
public GroovyTokenizerTest() {
|
||||
super(".groovy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSampleCode() throws IOException {
|
||||
return IOUtils.toString(GroovyTokenizer.class.getResourceAsStream(FILENAME), StandardCharsets.UTF_8);
|
||||
protected String getResourcePrefix() {
|
||||
return "../lang/groovy/cpd/testdata";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tokenizer newTokenizer(Properties properties) {
|
||||
return new GroovyTokenizer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tokenizeTest() throws IOException {
|
||||
this.expectedTokenCount = 369;
|
||||
super.tokenizeTest();
|
||||
public void testSample() {
|
||||
doTest("sample");
|
||||
}
|
||||
}
|
||||
|
421
pmd-groovy/src/test/resources/net/sourceforge/pmd/lang/groovy/cpd/testdata/sample.txt
vendored
Normal file
421
pmd-groovy/src/test/resources/net/sourceforge/pmd/lang/groovy/cpd/testdata/sample.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user