Create test for resolving with compiled kotlin dependency

Test for resolving fake overrides from binaries
This commit is contained in:
Pavel V. Talanov
2013-09-16 13:09:46 +04:00
parent 0749fc8cbb
commit 10797db588
7 changed files with 128 additions and 0 deletions
@@ -57,6 +57,7 @@ import org.jetbrains.jet.plugin.refactoring.inline.AbstractInlineTest;
import org.jetbrains.jet.psi.AbstractJetPsiMatcherTest;
import org.jetbrains.jet.resolve.AbstractResolveBaseTest;
import org.jetbrains.jet.resolve.AbstractResolveTest;
import org.jetbrains.jet.resolve.AbstractResolveWithLibTest;
import org.jetbrains.jet.safeDelete.AbstractJetSafeDeleteTest;
import org.jetbrains.jet.generators.tests.generator.SimpleTestClassModel;
import org.jetbrains.jet.generators.tests.generator.TestClassModel;
@@ -465,6 +466,13 @@ public class GenerateTests {
testModel("idea/testData/resolve/references", true, "doTest")
);
generateTest(
"idea/tests/",
"ReferenceResolveWithLibTestGenerated",
AbstractResolveWithLibTest.class,
testModel("idea/testData/resolve/referenceWithLib", false, "doTest")
);
generateTest(
"idea/tests/",
"JetFindUsagesTest",
@@ -0,0 +1,9 @@
package test
import dependency.B
fun test(b: B) {
b.<caret>f()
}
// REF: (in dependency.A).f()
@@ -0,0 +1,12 @@
package test
import dependency.A
public open class B(): A() {
}
fun test(b: B) {
b.<caret>f()
}
// REF: (in dependency.A).f()
@@ -0,0 +1,5 @@
package dependency
public open class A() {
public open fun f() {}
}
@@ -0,0 +1,8 @@
package dependency
public open class A() {
public open fun f() {}
}
public open class B(): A() {
}
@@ -0,0 +1,37 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.resolve;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
import static com.intellij.openapi.util.text.StringUtil.startsWithIgnoreCase;
public abstract class AbstractResolveWithLibTest extends AbstractResolveBaseTest {
private static final String TEST_DATA_PATH = "idea/testData/resolve/referenceWithLib";
private static final String ALL_FILES_PRESENT_PREFIX = "allFilesPresentIn";
@Override
protected LightProjectDescriptor getProjectDescriptor() {
String testName = getTestName(true);
if (startsWithIgnoreCase(testName, ALL_FILES_PRESENT_PREFIX)) {
return null;
}
return new JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/" + testName + "Src", false);
}
}
@@ -0,0 +1,49 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.resolve;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.resolve.AbstractResolveWithLibTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/resolve/referenceWithLib")
public class ReferenceResolveWithLibTestGenerated extends AbstractResolveWithLibTest {
public void testAllFilesPresentInReferenceWithLib() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/resolve/referenceWithLib"), Pattern.compile("^(.+)\\.kt$"), false);
}
@TestMetadata("fakeOverride.kt")
public void testFakeOverride() throws Exception {
doTest("idea/testData/resolve/referenceWithLib/fakeOverride.kt");
}
@TestMetadata("fakeOverride2.kt")
public void testFakeOverride2() throws Exception {
doTest("idea/testData/resolve/referenceWithLib/fakeOverride2.kt");
}
}