Force the user of AstAccessControl to write at least one test violating restriction, implement such tests for existing tests

This is needed because the slightest change in the test setup can make the check useless without the client knowing
The solution is ugly but gives at least some protection against this
This commit is contained in:
Pavel V. Talanov
2014-04-22 17:58:54 +04:00
parent 071553c66b
commit b3898cfb0d
7 changed files with 100 additions and 17 deletions
@@ -18,24 +18,36 @@ package org.jetbrains.jet.completion;
import com.intellij.codeInsight.completion.CompletionTestCase;
import com.intellij.codeInsight.lookup.LookupElement;
import kotlin.Function0;
import kotlin.Function1;
import kotlin.Unit;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.completion.util.UtilPackage;
import org.jetbrains.jet.plugin.PluginTestCaseBase;
import org.jetbrains.jet.plugin.project.TargetPlatform;
import org.jetbrains.jet.plugin.stubs.AstAccessControl;
public abstract class AbstractMultiFileJvmBasicCompletionTest extends CompletionTestCase {
protected void doTest(@NotNull String testPath) throws Exception {
configureByFile(getTestName(false) + ".kt", "");
UtilPackage.testCompletion(getFile().getText(), TargetPlatform.JVM, new Function1<Integer, LookupElement[]>() {
@Override
public LookupElement[] invoke(Integer invocationCount) {
complete(invocationCount);
return myItems;
}
});
boolean shouldFail = testPath.contains("NoSpecifiedType");
AstAccessControl.instance$.testWithControlledAccessToAst(
shouldFail, getFile().getVirtualFile(), getProject(), getTestRootDisposable(),
new Function0<Unit>() {
@Override
public Unit invoke() {
UtilPackage.testCompletion(getFile().getText(), TargetPlatform.JVM, new Function1<Integer, LookupElement[]>() {
@Override
public LookupElement[] invoke(Integer invocationCount) {
complete(invocationCount);
return myItems;
}
});
return Unit.VALUE;
}
}
);
}
@Override