Add tests for EA-52767 and KT-4366: "java.lang.IllegalArgumentException: Could not find a classifier for "...

This commit is contained in:
Nikolay Krasko
2014-01-15 14:53:14 +04:00
parent 07229b23d9
commit 0d141d959a
13 changed files with 183 additions and 8 deletions
@@ -0,0 +1,66 @@
/*
* Copyright 2010-2014 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 org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase
import org.jetbrains.jet.plugin.navigation.NavigationTestUtils
import org.jetbrains.jet.InTextDirectivesUtils
import java.io.File
import org.jetbrains.jet.plugin.PluginTestCaseBase
import org.junit.Assert
import junit.framework.AssertionFailedError
public abstract class AbstractReferenceResolveInLibrarySourcesTest : JetLightCodeInsightFixtureTestCase() {
class object {
val CARET_MARKER = "<caret>"
}
fun doTest(path: String) {
val fixture = myFixture!!
fixture.configureByFile(path)
val expectedResolveData = AbstractReferenceResolveTest.readResolveData(fixture.getFile()!!.getText())
val gotoData = NavigationTestUtils.invokeGotoImplementations(fixture.getEditor(), fixture.getFile())!!
Assert.assertEquals("Single target expected for origianl file", 1, gotoData.targets.size)
val testedPsiElement = gotoData.targets[0]
val testedElementFile = testedPsiElement.getContainingFile()!!
val lineContext = InTextDirectivesUtils.findStringWithPrefixes(fixture.getFile()!!.getText(), "CONTEXT:")
if (lineContext == null) {
throw AssertionFailedError("'CONTEXT: ' directive is expected to set up position in library file: ${testedElementFile.getName()}")
}
val inContextOffset = lineContext.indexOf(CARET_MARKER)
if (inContextOffset == -1) throw IllegalStateException("No '$CARET_MARKER' marker found in 'CONTEXT: $lineContext'")
val contextStr = lineContext.replace(CARET_MARKER, "")
val offsetInFile = testedElementFile.getText()!!.indexOf(contextStr)
if (offsetInFile == -1) throw IllegalStateException("Context '$contextStr' wasn't found in file ${testedElementFile.getName()}")
val offset = offsetInFile + inContextOffset
val reference = testedElementFile.findReferenceAt(offset)!!
AbstractReferenceResolveTest.checkReferenceResolve(expectedResolveData, offset, reference)
}
override fun getTestDataPath() : String = File(PluginTestCaseBase.getTestDataPathBase(), "/resolve/referenceInLib").getPath() + File.separator
override fun fileName(): String = getTestName(true) + ".kt"
}
@@ -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.AbstractReferenceResolveInLibrarySourcesTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/resolve/referenceInLib")
public class ReferenceResolveInLibrarySourcesTestGenerated extends AbstractReferenceResolveInLibrarySourcesTest {
public void testAllFilesPresentInReferenceInLib() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/resolve/referenceInLib"), Pattern.compile("^(.+)\\.kt$"), false);
}
@TestMetadata("builtInNumber.kt")
public void testBuiltInNumber() throws Exception {
doTest("idea/testData/resolve/referenceInLib/builtInNumber.kt");
}
@TestMetadata("inLibrarySource.kt")
public void testInLibrarySource() throws Exception {
doTest("idea/testData/resolve/referenceInLib/inLibrarySource.kt");
}
}
@@ -46,4 +46,9 @@ public class ReferenceResolveWithLibTestGenerated extends AbstractReferenceResol
doTest("idea/testData/resolve/referenceWithLib/fakeOverride2.kt");
}
@TestMetadata("sameNameInLib.kt")
public void testSameNameInLib() throws Exception {
doTest("idea/testData/resolve/referenceWithLib/sameNameInLib.kt");
}
}