added diagnostic message tests to ensure that number value types don't appear in error messages

This commit is contained in:
Svetlana Isakova
2013-07-22 13:18:25 +04:00
parent 80eb45b793
commit 8b7585af66
6 changed files with 234 additions and 0 deletions
@@ -0,0 +1,19 @@
package a
fun <T> id(t: T): T = t
fun <T> either(t1: T, t2: T): T = t1
fun <T> foo(l: List<T>) {}
fun <T> bar(t: T, l: MutableList<T>) {}
fun test(l: MutableList<String>) {
val c: Int = id(9223372036854775807)
val g: Byte = either(1, 300)
foo(1)
bar(1, l)
}
@@ -0,0 +1,23 @@
<!-- numberValueTypes1 -->
<html>
Type inference failed. Expected type mismatch: <table>
<tr>
<td>
found: </td>
<td>
<font color=red>
<b>
jet.Long</b>
</font>
</td>
</tr>
<tr>
<td>
required: </td>
<td>
<b>
jet.Int</b>
</td>
</tr>
</table>
</html>
@@ -0,0 +1,23 @@
<!-- numberValueTypes2 -->
<html>
Type inference failed. Expected type mismatch: <table>
<tr>
<td>
found: </td>
<td>
<font color=red>
<b>
jet.Int</b>
</font>
</td>
</tr>
<tr>
<td>
required: </td>
<td>
<b>
jet.Byte</b>
</td>
</tr>
</table>
</html>
@@ -0,0 +1,48 @@
<!-- numberValueTypes3 -->
<html>
Type inference failed: <table>
<tr>
<td width="10%">
</td>
<td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;">
<b>
fun</b>
&lt;T>
foo</td>
<td style="white-space:nowrap;font-weight:bold;">
(</td>
<td align="right" style="white-space:nowrap;font-weight:bold;">
l: jet.List&lt;T&gt;</td>
<td style="white-space:nowrap;font-weight:bold;">
)</td>
<td style="white-space:nowrap;font-weight:bold;">
: jet.Unit</td>
</tr>
<tr>
<td colspan="7" style="white-space:nowrap;">
cannot be applied to</td>
</tr>
<tr>
<td width="10%">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
<b>
(</b>
</td>
<td align="right" style="white-space:nowrap;">
<font color=red>
<b>
jet.Int</b>
</font>
</td>
<td style="white-space:nowrap;">
<b>
)</b>
</td>
</tr>
</table>
</html>
@@ -0,0 +1,116 @@
<!-- numberValueTypes4 -->
<html>
Type inference failed: Cannot infer type parameter <b>
T</b>
in <table>
<tr>
<td width="10%">
</td>
<td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;">
<b>
fun</b>
&lt;T>
bar</td>
<td style="white-space:nowrap;font-weight:bold;">
(</td>
<td align="right" style="white-space:nowrap;font-weight:bold;">
t: T,</td>
<td align="right" style="white-space:nowrap;font-weight:bold;">
l: jet.MutableList&lt;T&gt;</td>
<td style="white-space:nowrap;font-weight:bold;">
)</td>
<td style="white-space:nowrap;font-weight:bold;">
: jet.Unit</td>
</tr>
<tr>
<td colspan="8" style="white-space:nowrap;">
None of the following substitutions</td>
</tr>
<tr>
<td width="10%">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
<b>
(</b>
</td>
<td align="right" style="white-space:nowrap;">
<font color=red>
<b>
jet.String</b>
</font>
<b>
,</b>
</td>
<td align="right" style="white-space:nowrap;">
<b>
jet.MutableList&lt;jet.String&gt;</b>
</td>
<td style="white-space:nowrap;">
<b>
)</b>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
<b>
(</b>
</td>
<td align="right" style="white-space:nowrap;">
<b>
jet.Int</b>
<b>
,</b>
</td>
<td align="right" style="white-space:nowrap;">
<font color=red>
<b>
jet.MutableList&lt;jet.Int&gt;</b>
</font>
</td>
<td style="white-space:nowrap;">
<b>
)</b>
</td>
</tr>
<tr>
<td colspan="8" style="white-space:nowrap;">
can be applied to</td>
</tr>
<tr>
<td width="10%">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
</td>
<td style="white-space:nowrap;">
<b>
(</b>
</td>
<td align="right" style="white-space:nowrap;">
<b>
jet.Int</b>
<b>
,</b>
</td>
<td align="right" style="white-space:nowrap;">
<b>
jet.MutableList&lt;jet.String&gt;</b>
</td>
<td style="white-space:nowrap;">
<b>
)</b>
</td>
</tr>
</table>
</html>
@@ -113,4 +113,9 @@ public class DiagnosticMessageTest extends JetLiteFixture {
public void testInvisibleMember() throws Exception {
doTest("invisibleMember", 3, Errors.INVISIBLE_MEMBER, Errors.INVISIBLE_MEMBER, Errors.INVISIBLE_MEMBER);
}
public void testNumberValueTypes() throws Exception {
doTest("numberValueTypes", 4, Errors.TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, Errors.TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH,
Errors.TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS);
}
}