diff --git a/pmd-kotlin/src/test/java/net/sourceforge/pmd/cpd/KotlinTokenizerTest.java b/pmd-kotlin/src/test/java/net/sourceforge/pmd/cpd/KotlinTokenizerTest.java index 28231a36d6..539b527858 100644 --- a/pmd-kotlin/src/test/java/net/sourceforge/pmd/cpd/KotlinTokenizerTest.java +++ b/pmd-kotlin/src/test/java/net/sourceforge/pmd/cpd/KotlinTokenizerTest.java @@ -31,7 +31,6 @@ public class KotlinTokenizerTest extends CpdTextComparisonTest { doTest("comment"); } - @Test public void testIncrement() { doTest("increment"); diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt new file mode 100644 index 0000000000..d13247bcc2 --- /dev/null +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt @@ -0,0 +1,7 @@ + [Image] or [Truncated image[ Bcol Ecol +L3 + [var] 1 3 + [x] 5 5 + [=] 7 7 + [0] 9 9 +EOF diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.txt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.txt new file mode 100644 index 0000000000..49ab402048 --- /dev/null +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.txt @@ -0,0 +1,2 @@ + [Image] or [Truncated image[ Bcol Ecol +EOF diff --git a/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt new file mode 100644 index 0000000000..661e0ceb3a --- /dev/null +++ b/pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt @@ -0,0 +1,207 @@ + [Image] or [Truncated image[ Bcol Ecol +L3 + [var] 1 3 + [x] 5 5 + [=] 7 7 + [0] 9 9 +L5 + [fun] 1 3 + [increment1] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L6 + [fun] 1 3 + [increment2] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L7 + [fun] 1 3 + [increment3] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L8 + [fun] 1 3 + [increment4] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L9 + [fun] 1 3 + [increment5] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L10 + [fun] 1 3 + [increment6] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L11 + [fun] 1 3 + [increment7] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L12 + [fun] 1 3 + [increment8] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L13 + [fun] 1 3 + [increment9] 5 14 + [(] 15 15 + [)] 16 16 + [{] 18 18 + [x] 20 20 + [+=] 22 23 + [1] 25 25 + [}] 27 27 +L14 + [fun] 1 3 + [increment10] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L15 + [fun] 1 3 + [increment11] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L16 + [fun] 1 3 + [increment12] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L17 + [fun] 1 3 + [increment13] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L18 + [fun] 1 3 + [increment14] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L19 + [fun] 1 3 + [increment15] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L20 + [fun] 1 3 + [increment16] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L21 + [fun] 1 3 + [increment17] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L22 + [fun] 1 3 + [increment18] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L23 + [fun] 1 3 + [increment19] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +L24 + [fun] 1 3 + [increment20] 5 15 + [(] 16 16 + [)] 17 17 + [{] 19 19 + [x] 21 21 + [+=] 23 24 + [1] 26 26 + [}] 28 28 +EOF diff --git a/pmd-ruby/pom.xml b/pmd-ruby/pom.xml index 6f7f54eff3..acebc95dc7 100644 --- a/pmd-ruby/pom.xml +++ b/pmd-ruby/pom.xml @@ -26,10 +26,20 @@ junit test + + org.junit.vintage + junit-vintage-engine + test + net.sourceforge.pmd pmd-test test + + net.sourceforge.pmd + pmd-lang-test + test + diff --git a/pmd-ruby/src/test/java/net/sourceforge/pmd/cpd/RubyTokenizerTest.java b/pmd-ruby/src/test/java/net/sourceforge/pmd/cpd/RubyTokenizerTest.java index decb493bf8..b4398fdf36 100644 --- a/pmd-ruby/src/test/java/net/sourceforge/pmd/cpd/RubyTokenizerTest.java +++ b/pmd-ruby/src/test/java/net/sourceforge/pmd/cpd/RubyTokenizerTest.java @@ -4,36 +4,31 @@ 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 RubyTokenizerTest extends AbstractTokenizerTest { +public class RubyTokenizerTest extends CpdTextComparisonTest { - @Before - @Override - public void buildTokenizer() { - this.tokenizer = new RubyTokenizer(); - this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), "server.rb")); + public RubyTokenizerTest() { + super(".rb"); } @Override - public String getSampleCode() { - try { - return IOUtils.toString(RubyTokenizerTest.class.getResourceAsStream("server.rb"), StandardCharsets.UTF_8); - } catch (IOException e) { - throw new RuntimeException(e); - } + protected String getResourcePrefix() { + return "../lang/ruby/cpd/testdata"; } + @Override + public Tokenizer newTokenizer(Properties properties) { + return new RubyTokenizer(); + } + + @Test - public void tokenizeTest() throws IOException { - this.expectedTokenCount = 30; - super.tokenizeTest(); + public void testSimple() { + doTest("server"); } } diff --git a/pmd-ruby/src/test/resources/net/sourceforge/pmd/cpd/server.rb b/pmd-ruby/src/test/resources/net/sourceforge/pmd/lang/ruby/cpd/testdata/server.rb similarity index 100% rename from pmd-ruby/src/test/resources/net/sourceforge/pmd/cpd/server.rb rename to pmd-ruby/src/test/resources/net/sourceforge/pmd/lang/ruby/cpd/testdata/server.rb diff --git a/pmd-ruby/src/test/resources/net/sourceforge/pmd/lang/ruby/cpd/testdata/server.txt b/pmd-ruby/src/test/resources/net/sourceforge/pmd/lang/ruby/cpd/testdata/server.txt new file mode 100644 index 0000000000..b54c81a53f --- /dev/null +++ b/pmd-ruby/src/test/resources/net/sourceforge/pmd/lang/ruby/cpd/testdata/server.txt @@ -0,0 +1,45 @@ + [Image] or [Truncated image[ Bcol Ecol +L1 + [require] 0 6 + ["socket"] 9 16 +L3 + [gs] 0 1 + [=] 3 3 + [tcpserver.open] 5 18 + [0] 20 20 +L4 + [addr] 0 3 + [=] 5 5 + [gs.addr] 7 13 +L5 + [addr.shift] 0 9 +L7 + [true] 6 9 +L8 + [ns] 2 3 + [=] 5 5 + [gs.accept] 7 15 +L9 + [print] 2 6 + [ns] 8 9 + [" is accepted"] 13 26 +L10 + [thread.start] 2 13 +L11 + [s] 4 4 + [=] 6 6 + [ns] 8 9 + [ # save to dynamic variable] 31 57 +L12 + [s.gets] 10 15 +L13 + [s.write] 6 12 + [$_] 14 15 +L15 + [print] 4 8 + [s] 10 10 +L18 + [" is gone [ -46 39 +L19 + [s.close] 4 10 +EOF