New J2K: Fix existing test data

This commit is contained in:
Ilya Kirillov
2019-02-03 16:42:16 +03:00
committed by Ilya Kirillov
parent 7e30b9e7f5
commit f8b8d07621
27 changed files with 546 additions and 143 deletions
@@ -0,0 +1 @@
val a: Array<Double?> = arrayOf(1.0, 2.0, 3.0)
@@ -0,0 +1 @@
val a: Array<Float?> = arrayOf(1.0f, 2f, 3f)
@@ -0,0 +1,14 @@
class AssignmentAsExpression {
private var field = 0
private var field2 = 0
fun assign(value: Int) {
field = value
val v = field
field2 = value
field = field2
val j: Int
j = 0
val i = j
}
}
@@ -1,6 +1,5 @@
// !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true
import java.util.HashSet;
class Foo {
void foo(HashSet o) {
@@ -0,0 +1,11 @@
// !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true
import java.util.HashSet
internal class Foo {
fun foo(o: HashSet<*>?) {
val o2: HashSet<*>? = o
var foo: Int = 0
foo = o2!!.size
}
}
@@ -0,0 +1,6 @@
internal class Foo {
fun foo(o: HashSet<*>?) {
var foo = 0
foo = o!!.size
}
}
@@ -0,0 +1,20 @@
internal class C(private val arg1: Int, private val arg2: Int, private val arg3: Int) {
fun foo(p: Int): Int {
return p
}
constructor(arg1: Int, arg2: Int, other: C) : this(arg1, arg2, 0) {
println(foo(1) + foo(2) + other.foo(3) + staticFoo(4) + C.staticFoo(5))
}
companion object {
private fun staticFoo(p: Int): Int {
return p
}
fun staticFoo2(): Int {
return 0
}
}
}
@@ -0,0 +1,10 @@
class SomeClass {
internal var a = 0
internal var b = 0
internal fun doSomeWhile(i: Int) {
do {
b = i
a = b
} while (i < 0)
}
}
@@ -0,0 +1,15 @@
internal class CtorComment {
var myA: String?
/**
* This constructor is especially useful
*/
init {
myA = "str"
}
}
/**
* This constructor is especially useful
*/
internal class CtorComment2
+1 -1
View File
@@ -1,5 +1,5 @@
internal enum class E {
I;
private val name: String? = null
private override val name: String? = null
}
-3
View File
@@ -1,3 +0,0 @@
for (i in 0 until N!!) {
println(i)
}
+1 -1
View File
@@ -3,6 +3,6 @@ package demo
internal class Test {
fun test(vararg args: Any?) {
var args: Any? = args
args = intArrayOf(1, 2, 3)
args = arrayOf(1, 2, 3)
}
}
+40
View File
@@ -0,0 +1,40 @@
internal class Test {
fun printNumbers() {
for (i1 in 0..0)
println(i1)
val b: Byte = 1
for (i2 in 0 until b)
println(i2)
val s: Short = 1
for (i3 in 0 until s)
println(i3)
val l = 1L
for (i4 in 0 until l)
println(i4)
val d = 1.0
var i5 = 0
while (i5 < d) {
println(i5)
i5++
}
val f = 1.0f
var i6 = 0
while (i6 < f) {
println(i6)
i6++
}
val c = 1.toChar()
var i7 = 0
while (i7 < c.toInt()) {
println(i7)
i7++
}
}
}
+137
View File
@@ -0,0 +1,137 @@
internal class A {
fun equals() {
val i = 1
val b: Byte = 1
val s: Short = 1
val l: Long = 1
val d = 1.0
val f = 1.0f
val c = 1.toChar()
t(i == i)
t(i == b.toInt())
t(i == s.toInt())
t(i.toLong() == l)
t(i.toDouble() == d)
t(i.toFloat() == f)
t(i == c.toInt())
t(b.toInt() == i)
t(b == b)
t(b.toShort() == s)
t(b.toLong() == l)
t(b.toDouble() == d)
t(b.toFloat() == f)
t(b == c.toByte())
t(s.toInt() == i)
t(s == b.toShort())
t(s == s)
t(s.toLong() == l)
t(s.toDouble() == d)
t(s.toFloat() == f)
t(s == c.toShort())
t(l == i.toLong())
t(l == b.toLong())
t(l == s.toLong())
t(l == l)
t(l.toDouble() == d)
t(l.toFloat() == f)
t(l == c.toLong())
t(d == i.toDouble())
t(d == b.toDouble())
t(d == s.toDouble())
t(d == l.toDouble())
t(d == d)
t(d == f.toDouble())
t(d == c.toDouble())
t(f == i.toFloat())
t(f == b.toFloat())
t(f == s.toFloat())
t(f == l.toFloat())
t(f.toDouble() == d)
t(f == f)
t(f == c.toFloat())
t(c.toInt() == i)
t(c.toByte() == b)
t(c.toShort() == s)
t(c.toLong() == l)
t(c.toDouble() == d)
t(c.toFloat() == f)
t(c == c)
t(i.toDouble() != d)
}
fun compare() {
val i = 1
val b: Byte = 1
val s: Short = 1
val l: Long = 1
val d = 1.0
val f = 1.0f
val c = 1.toChar()
t(i > i)
t(i > b)
t(i > s)
t(i > l)
t(i > d)
t(i > f)
t(i > c.toInt())
t(b > i)
t(b > b)
t(b > s)
t(b > l)
t(b > d)
t(b > f)
t(b > c.toByte())
t(s > i)
t(s > b)
t(s > s)
t(s > l)
t(s > d)
t(s > f)
t(s > c.toShort())
t(l > i)
t(l > b)
t(l > s)
t(l > l)
t(l > d)
t(l > f)
t(l > c.toLong())
t(d > i)
t(d > b)
t(d > s)
t(d > l)
t(d > d)
t(d > f)
t(d > c.toDouble())
t(f > i)
t(f > b)
t(f > s)
t(f > l)
t(f > d)
t(f > f)
t(f > c.toFloat())
t(c.toInt() > i)
t(c.toByte() > b)
t(c.toShort() > s)
t(c.toLong() > l)
t(c.toDouble() > d)
t(c.toFloat() > f)
t(c > c)
}
private fun t(b: Boolean) {}
}
@@ -0,0 +1,7 @@
import kotlinApi.KotlinTrait
internal class A {
fun foo(t: KotlinTrait): Int {
return t.nullableFun()!!.length + t.notNullableFun().length
}
}
@@ -0,0 +1,7 @@
import kotlinApi.globalFunction
internal class C {
fun foo() {
val s = globalFunction("x")
}
}
@@ -1,5 +1,5 @@
// ERROR: No value passed for parameter 'field'
import kotlinApi.property
import kotlinApi.KotlinClass
internal class C : KotlinClass() {
fun foo() {
@@ -1,4 +1,4 @@
test@ for (i in 0..max!!) {
test@ for (i in 0..max) {
var n: Int = substring!!.length()
var j = i
var k = 0
+15
View File
@@ -0,0 +1,15 @@
// ERROR: Unresolved reference: LinkedList
import java.util.ArrayList
class ForEach {
fun test() {
val xs: ArrayList<Any?> = ArrayList()
val ys: MutableList<Any?> = LinkedList<Any?>()
for (x in xs) {
ys.add(x)
}
for (y in ys) {
xs.add(y)
}
}
}
+17
View File
@@ -0,0 +1,17 @@
// ERROR: Unresolved reference: LinkedList
// ERROR: Null can not be a value of a non-null type Any
// ERROR: Null can not be a value of a non-null type Any
import java.util.ArrayList
class Lists {
fun test() {
val xs: MutableList<Any?> = ArrayList()
val ys: MutableList<Any?> = LinkedList<Any?>()
val zs: ArrayList<Any?> = ArrayList()
xs.add(null)
ys.add(null)
xs.clear()
ys.clear()
zs.add(null)
}
}
@@ -0,0 +1,28 @@
internal class A {
private var l1 = 1L
private var l2: Long = 1
private val l3 = 1L
private var l4: Long = -1
private val l5 = 123456789101112
private val l6 = -123456789101112
private val l7: Long = +1
private val l8 = +1L
fun foo1(l: Long) {}
fun foo2(l: Long?) {}
fun bar() {
foo1(1)
foo1(1L)
foo2(1L)
foo1(-1)
l1 = 10
l2 = 10L
l4 = 10
}
fun foo(z: Long) {
val b1 = z == 1L
val b2 = z != 1L
}
}
@@ -0,0 +1,12 @@
package demo
internal class Map {
fun <K, V> put(k: K?, v: V?) {}
}
internal class U {
fun test() {
val m = Map()
m.put<String?, Int?>(null, 10)
}
}
@@ -0,0 +1,41 @@
import java.util.HashMap
internal enum class E {
A, B, C
}
internal class A {
fun foo(list: List<String?>, collection: Collection<Int?>, map: Map<Int?, Int?>) {
val a = "".length
val b = E.A.name
val c = E.A.ordinal
val d = list.size + collection.size
val e = map.size
val f = map.keys.size
val g = map.values.size
val h = map.entries.size
}
fun bar(list: MutableList<String?>, map: HashMap<String?, Int?>) {
val c = "a"[0]
val b = 10.toByte()
val i = 10.1.toInt()
val f = 10.1.toFloat()
val l = 10.1.toLong()
val s = 10.1.toShort()
try {
val removed = list.removeAt(10)
val isRemoved = list.remove("a")
} catch (e: Exception) {
System.err.println(e.message)
throw RuntimeException(e.cause)
}
for (entry in map.entries) {
val key = entry.key
val value = entry.value
entry.setValue(value!! + 1)
}
}
}
@@ -1,135 +1,134 @@
//import java.nio.charset.Charset;
//import java.util.*;
//
//class A {
// void constructors() throws Exception {
// new String();
// // TODO: new String("original");
// new String(new char[] {'a', 'b', 'c'});
// new String(new char[] {'b', 'd'}, 1, 1);
// new String(new int[] { 32, 65, 127 }, 0, 3);
//
// byte[] bytes = new byte[] { 32, 65, 100, 81 };
// Charset charset = Charset.forName("utf-8");
// new String(bytes);
// new String(bytes, charset);
// new String(bytes, 0, 2);
// new String(bytes, "utf-8");
// new String(bytes, 0, 2, "utf-8");
// new String(bytes, 0, 2, charset);
//
// new String(new StringBuilder("content"));
// new String(new StringBuffer("content"));
// }
//
// void normalMethods() {
// String s = "test string";
// s.length();
// s.isEmpty();
// s.charAt(1);
// s.codePointAt(2);
// s.codePointBefore(2);
// s.codePointCount(0, s.length());
// s.offsetByCodePoints(0, 4);
// s.compareTo("test 2");
// s.contains("seq");
// s.contentEquals(new StringBuilder(s));
// s.contentEquals(new StringBuffer(s));
// s.endsWith("ng");
// s.startsWith("te");
// s.startsWith("st", 2);
// s.indexOf("st");
// s.indexOf("st", 5);
// s.lastIndexOf("st");
// s.lastIndexOf("st", 4);
// s.indexOf('t');
// s.indexOf('t', 5);
// s.lastIndexOf('t');
// s.lastIndexOf('t', 5);
// s.substring(1);
// s.substring(0, 4);
// s.subSequence(0, 4);
// s.replace('e', 'i');
// s.replace("est", "oast");
// s.intern();
// s.toLowerCase();
// s.toLowerCase(Locale.FRENCH);
// s.toUpperCase();
// s.toUpperCase(Locale.FRENCH);
//
// s.toString();
// s.toCharArray();
// }
//
// void specialMethods() throws Exception {
// String s = "test string";
// s.equals("test");
// s.equalsIgnoreCase(
// "tesT"
// );
// s.compareToIgnoreCase("Test");
// s.regionMatches(
// true,
// 0,
// "TE",
// 0,
// 2
// );
// s.regionMatches(0, "st", 1, 2);
// s.matches("\\w+");
// s.replaceAll("\\w+", "---")
// .replaceFirst("([s-t])", "A$1");
// useSplit(s.split("\\s+"));
// useSplit(s.split("\\s+", 0));
// useSplit(s.split("\\s+", -1));
// useSplit(s.split("\\s+", 2));
// int limit = 5;
// useSplit(s.split("\\s+", limit));
// s.trim();
// s.concat(" another");
//
// s.getBytes();
// s.getBytes(Charset.forName("utf-8"));
// s.getBytes("utf-8");
//
// char[] chars = new char[10];
// s.getChars(1, 11, chars, 0);
// }
//
// void staticMethods() {
// String.valueOf(1);
// String.valueOf(1L);
// String.valueOf('a');
// String.valueOf(true);
// String.valueOf(1.11F);
// String.valueOf(3.14);
// String.valueOf(new Object());
//
// String.format(
// Locale.FRENCH,
// "Je ne mange pas %d jours",
// 6
// );
// String.format("Operation completed with %s", "success");
//
// char[] chars = {'a', 'b', 'c'};
// String.valueOf(chars);
// String.valueOf(chars, 1, 2);
// String.copyValueOf(chars);
// String.copyValueOf(chars, 1, 2);
//
// Comparator<String> order = String.CASE_INSENSITIVE_ORDER;
// }
//
// void unsupportedMethods() {
// String s = "test string";
// /* TODO:
// s.indexOf(32);
// s.indexOf(32, 2);
// s.lastIndexOf(32);
// s.lastIndexOf(32, 2);
// */
// }
//
// void useSplit(String[] result) {}
//}
import java.nio.charset.Charset;
import java.util.*;
class A {
void constructors() throws Exception {
new String();
// TODO: new String("original");
new String(new char[] {'a', 'b', 'c'});
new String(new char[] {'b', 'd'}, 1, 1);
new String(new int[] { 32, 65, 127 }, 0, 3);
byte[] bytes = new byte[] { 32, 65, 100, 81 };
Charset charset = Charset.forName("utf-8");
new String(bytes);
new String(bytes, charset);
new String(bytes, 0, 2);
new String(bytes, "utf-8");
new String(bytes, 0, 2, "utf-8");
new String(bytes, 0, 2, charset);
new String(new StringBuilder("content"));
new String(new StringBuffer("content"));
}
void normalMethods() {
String s = "test string";
s.length();
s.isEmpty();
s.charAt(1);
s.codePointAt(2);
s.codePointBefore(2);
s.codePointCount(0, s.length());
s.offsetByCodePoints(0, 4);
s.compareTo("test 2");
s.contains("seq");
s.contentEquals(new StringBuilder(s));
s.contentEquals(new StringBuffer(s));
s.endsWith("ng");
s.startsWith("te");
s.startsWith("st", 2);
s.indexOf("st");
s.indexOf("st", 5);
s.lastIndexOf("st");
s.lastIndexOf("st", 4);
s.indexOf('t');
s.indexOf('t', 5);
s.lastIndexOf('t');
s.lastIndexOf('t', 5);
s.substring(1);
s.substring(0, 4);
s.subSequence(0, 4);
s.replace('e', 'i');
s.replace("est", "oast");
s.intern();
s.toLowerCase();
s.toLowerCase(Locale.FRENCH);
s.toUpperCase();
s.toUpperCase(Locale.FRENCH);
s.toString();
s.toCharArray();
}
void specialMethods() throws Exception {
String s = "test string";
s.equals("test");
s.equalsIgnoreCase(
"tesT"
);
s.compareToIgnoreCase("Test");
s.regionMatches(
true,
0,
"TE",
0,
2
);
s.regionMatches(0, "st", 1, 2);
s.matches("\\w+");
s.replaceAll("\\w+", "---")
.replaceFirst("([s-t])", "A$1");
useSplit(s.split("\\s+"));
useSplit(s.split("\\s+", 0));
useSplit(s.split("\\s+", -1));
useSplit(s.split("\\s+", 2));
int limit = 5;
useSplit(s.split("\\s+", limit));
s.trim();
s.concat(" another");
s.getBytes();
s.getBytes(Charset.forName("utf-8"));
s.getBytes("utf-8");
char[] chars = new char[10];
s.getChars(1, 11, chars, 0);
}
void staticMethods() {
String.valueOf(1);
String.valueOf(1L);
String.valueOf('a');
String.valueOf(true);
String.valueOf(1.11F);
String.valueOf(3.14);
String.valueOf(new Object());
String.format(
Locale.FRENCH,
"Je ne mange pas %d jours",
6
);
String.format("Operation completed with %s", "success");
char[] chars = {'a', 'b', 'c'};
String.valueOf(chars);
String.valueOf(chars, 1, 2);
String.copyValueOf(chars);
String.copyValueOf(chars, 1, 2);
Comparator<String> order = String.CASE_INSENSITIVE_ORDER;
}
void unsupportedMethods() {
String s = "test string";
/* TODO:
s.indexOf(32);
s.indexOf(32, 2);
s.lastIndexOf(32);
s.lastIndexOf(32, 2);
*/
}
void useSplit(String[] result) {}
@@ -0,0 +1,8 @@
import java.util.ArrayList
internal class A {
private val field1: List<String?> = ArrayList()
val field2: List<String?> = ArrayList()
val field3: Int = 0
protected val field4: Int = 0
}
@@ -0,0 +1,8 @@
// !specifyLocalVariableTypeByDefault: true
fun foo(list: List<String?>?) {
val array: IntArray = IntArray(10)
for (i: Int in 0..9) {
array[i] = i
}
for (s: String? in list!!) print(s)
}
@@ -0,0 +1,10 @@
class SomeClass {
internal var a = 0
internal var b = 0
internal fun doSomeWhile(i: Int) {
while (i < 0) {
b = i
a = b
}
}
}