Added test to settle format of HtmlTabledDescriptorRenderer.

This commit is contained in:
Evgeny Gerashchenko
2012-12-13 20:31:46 +04:00
parent 542201f4ed
commit 0f38e3f1fc
4 changed files with 421 additions and 0 deletions
@@ -0,0 +1,169 @@
<html>
Type inference failed: Cannot infer type parameter <b>
T</b>
in<table>
<tr>
<td width="10%">
</td>
<td align="right" colspan="2">
<div style="white-space:nowrap;font-weight:bold;">
<b>
fun</b>
&lt;T, E>
writeToMyList</div>
</td>
<td>
<div style="white-space:nowrap;font-weight:bold;">
(</div>
</td>
<td align="right">
<div style="white-space:nowrap;font-weight:bold;">
l : MyList&lt;in T&gt;,</div>
</td>
<td align="right">
<div style="white-space:nowrap;font-weight:bold;">
t : T</div>
</td>
<td>
<div style="white-space:nowrap;font-weight:bold;">
)</div>
</td>
<td>
<div style="white-space:nowrap;font-weight:bold;">
: Unit <b>
where</b>
E : java.lang.Cloneable, E : java.io.Closeable</div>
</td>
</tr>
<tr>
<td colspan="8">
<div style="white-space:nowrap;">
None of the following substitutions</div>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
(</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<font color=red>
<b>
MyList&lt;in jet.Any&gt;</b>
</font>
<b>
,</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
jet.Any</b>
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
)</b>
</div>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
(</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
MyList&lt;in jet.Int&gt;</b>
<b>
,</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<font color=red>
<b>
jet.Int</b>
</font>
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
)</b>
</div>
</td>
</tr>
<tr>
<td colspan="8">
<div style="white-space:nowrap;">
can be applied to</div>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
(</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
MyList&lt;jet.Int&gt;</b>
<b>
,</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
jet.Any</b>
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
)</b>
</div>
</td>
</tr>
</table>
</html>
@@ -0,0 +1,167 @@
<html>
Type inference failed: Cannot infer type parameter <b>
T</b>
in<table>
<tr>
<td width="10%">
</td>
<td align="right" colspan="2">
<div style="white-space:nowrap;font-weight:bold;">
<b>
ctor</b>
Cons&lt;T, E : java.lang.Cloneable>
</div>
</td>
<td>
<div style="white-space:nowrap;font-weight:bold;">
(</div>
</td>
<td align="right">
<div style="white-space:nowrap;font-weight:bold;">
l : MyList&lt;in T&gt;,</div>
</td>
<td align="right">
<div style="white-space:nowrap;font-weight:bold;">
t : T</div>
</td>
<td>
<div style="white-space:nowrap;font-weight:bold;">
)</div>
</td>
<td>
<div style="white-space:nowrap;font-weight:bold;">
</div>
</td>
</tr>
<tr>
<td colspan="8">
<div style="white-space:nowrap;">
None of the following substitutions</div>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
(</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<font color=red>
<b>
MyList&lt;in jet.Any&gt;</b>
</font>
<b>
,</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
jet.Any</b>
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
)</b>
</div>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
(</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
MyList&lt;in jet.Int&gt;</b>
<b>
,</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<font color=red>
<b>
jet.Int</b>
</font>
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
)</b>
</div>
</td>
</tr>
<tr>
<td colspan="8">
<div style="white-space:nowrap;">
can be applied to</div>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
(</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
MyList&lt;jet.Int&gt;</b>
<b>
,</b>
</div>
</td>
<td align="right">
<div style="white-space:nowrap;">
<b>
jet.Any</b>
</div>
</td>
<td>
<div style="white-space:nowrap;">
<b>
)</b>
</div>
</td>
</tr>
</table>
</html>
@@ -0,0 +1,14 @@
// see org.jetbrains.jet.plugin.highlighter.HtmlTabledDescriptorRendererTest
import java.io.Closeable
class MyList<T>(t: T) {}
fun <T> getMyList(t: T): MyList<T> = MyList(t)
fun <T, E: Cloneable> writeToMyList (l: MyList< in T>, t: T) where E: Closeable {}
class Cons<T, E: Cloneable>(l: MyList<in T>, t: T)
fun test1(int: Int, any: Any) {
writeToMyList(getMyList(int), any)
Cons(getMyList(int), any)
}
@@ -0,0 +1,71 @@
/*
* Copyright 2010-2012 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.plugin.highlighter;
import com.intellij.openapi.util.Condition;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.jet.ConfigurationKind;
import org.jetbrains.jet.JetLiteFixture;
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
import org.jetbrains.jet.plugin.PluginTestCaseBase;
import java.util.Collections;
import java.util.List;
public class HtmlTabledDescriptorRendererTest extends JetLiteFixture {
@Override
protected JetCoreEnvironment createEnvironment() {
return createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY);
}
@Override
protected String getTestDataPath() {
return PluginTestCaseBase.getTestDataPathBase() + "/htmlTabledRenderer/";
}
public void testHtmlTabledRenderer() throws Exception {
String fileName = "htmlTabledRenderer.kt";
JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName));
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, Collections.<AnalyzerScriptParameter>emptyList());
BindingContext bindingContext = analyzeExhaust.getBindingContext();
List<Diagnostic> diagnostics = ContainerUtil.filter(bindingContext.getDiagnostics(), new Condition<Diagnostic>() {
@Override
public boolean value(Diagnostic diagnostic) {
return diagnostic.getFactory() == Errors.TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS;
}
});
assertEquals(diagnostics.size(), 2);
int index = 1;
for (Diagnostic diagnostic : diagnostics) {
String readableDiagnosticHtml = IdeErrorMessages.RENDERER.render(diagnostic).replaceAll(">", ">\n");
assertSameLinesWithFile(getTestDataPath() + "/diagnostic" + index + ".html", readableDiagnosticHtml);
index++;
}
}
}