Added test cases for Kotlin support for CPD.
This commit is contained in:
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.kotlin.KotlinLanguageModule;
|
||||
|
||||
public class LanguageVersionTest extends AbstractLanguageVersionTest {
|
||||
|
||||
public LanguageVersionTest(String name, String terseName, String version, LanguageVersion expected) {
|
||||
super(name, terseName, version, expected);
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][] { { KotlinLanguageModule.NAME, KotlinLanguageModule.TERSE_NAME, "1.3",
|
||||
LanguageRegistry.getLanguage(KotlinLanguageModule.NAME).getDefaultVersion(), }, });
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.cpd;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class KotlinTokenizerTest extends AbstractTokenizerTest {
|
||||
|
||||
private final String filename;
|
||||
private final int nExpectedTokens;
|
||||
|
||||
public KotlinTokenizerTest(String filename, int nExpectedTokens) {
|
||||
this.filename = filename;
|
||||
this.nExpectedTokens = nExpectedTokens;
|
||||
}
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
return Arrays.asList(
|
||||
new Object[] { "comment.kt", 5 },
|
||||
new Object[] { "increment.kt", 185 },
|
||||
new Object[] { "imports.kt", 1 }
|
||||
);
|
||||
}
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void buildTokenizer() throws IOException {
|
||||
this.tokenizer = new KotlinTokenizer();
|
||||
this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), this.filename));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSampleCode() throws IOException {
|
||||
return IOUtils.toString(KotlinTokenizer.class.getResourceAsStream(this.filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tokenizeTest() throws IOException {
|
||||
this.expectedTokenCount = nExpectedTokens;
|
||||
super.tokenizeTest();
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.github.shyiko.ktlint.internal
|
||||
|
||||
var x = 0
|
||||
|
||||
/*
|
||||
fun increment1() { x += 1 }
|
||||
fun increment2() { x += 1 }
|
||||
fun increment3() { x += 1 }
|
||||
fun increment4() { x += 1 }
|
||||
fun increment5() { x += 1 }
|
||||
fun increment6() { x += 1 }
|
||||
fun increment7() { x += 1 }
|
||||
fun increment8() { x += 1 }
|
||||
fun increment9() { x += 1 }
|
||||
fun increment10() { x += 1 }
|
||||
fun increment11() { x += 1 }
|
||||
fun increment12() { x += 1 }
|
||||
fun increment13() { x += 1 }
|
||||
fun increment14() { x += 1 }
|
||||
fun increment15() { x += 1 }
|
||||
fun increment16() { x += 1 }
|
||||
fun increment17() { x += 1 }
|
||||
fun increment18() { x += 1 }
|
||||
fun increment19() { x += 1 }
|
||||
fun increment20() { x += 1 }
|
||||
*/
|
||||
|
@ -0,0 +1,4 @@
|
||||
import java.math.BigInteger
|
||||
import java.math.BigInteger as BigInt
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*
|
@ -0,0 +1,25 @@
|
||||
package com.github.shyiko.ktlint.internal
|
||||
|
||||
var x = 0
|
||||
|
||||
fun increment1() { x += 1 }
|
||||
fun increment2() { x += 1 }
|
||||
fun increment3() { x += 1 }
|
||||
fun increment4() { x += 1 }
|
||||
fun increment5() { x += 1 }
|
||||
fun increment6() { x += 1 }
|
||||
fun increment7() { x += 1 }
|
||||
fun increment8() { x += 1 }
|
||||
fun increment9() { x += 1 }
|
||||
fun increment10() { x += 1 }
|
||||
fun increment11() { x += 1 }
|
||||
fun increment12() { x += 1 }
|
||||
fun increment13() { x += 1 }
|
||||
fun increment14() { x += 1 }
|
||||
fun increment15() { x += 1 }
|
||||
fun increment16() { x += 1 }
|
||||
fun increment17() { x += 1 }
|
||||
fun increment18() { x += 1 }
|
||||
fun increment19() { x += 1 }
|
||||
fun increment20() { x += 1 }
|
||||
|
Reference in New Issue
Block a user