forked from phoedos/pmd
Port ruby tests
TODO there's a bug
This commit is contained in:
@@ -31,7 +31,6 @@ public class KotlinTokenizerTest extends CpdTextComparisonTest {
|
||||
doTest("comment");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIncrement() {
|
||||
doTest("increment");
|
||||
|
||||
7
pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt
vendored
Normal file
7
pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/comment.txt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
[Image] or [Truncated image[ Bcol Ecol
|
||||
L3
|
||||
[var] 1 3
|
||||
[x] 5 5
|
||||
[=] 7 7
|
||||
[0] 9 9
|
||||
EOF
|
||||
2
pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.txt
vendored
Normal file
2
pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/imports.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
[Image] or [Truncated image[ Bcol Ecol
|
||||
EOF
|
||||
207
pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt
vendored
Normal file
207
pmd-kotlin/src/test/resources/net/sourceforge/pmd/lang/kotlin/cpd/testdata/increment.txt
vendored
Normal file
@@ -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
|
||||
@@ -26,10 +26,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>
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
45
pmd-ruby/src/test/resources/net/sourceforge/pmd/lang/ruby/cpd/testdata/server.txt
vendored
Normal file
45
pmd-ruby/src/test/resources/net/sourceforge/pmd/lang/ruby/cpd/testdata/server.txt
vendored
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user