Migrate boxWithJava tests to multi-file framework

This commit is contained in:
Alexander Udalov
2016-03-01 19:18:37 +03:00
parent 0801ae5364
commit 2de7f38427
266 changed files with 2271 additions and 1729 deletions
@@ -1,3 +1,37 @@
// FILE: J.java
import java.util.*;
public class J {
public static class B extends A {
public int getLength() { return 456; }
public char get(int index) {
if (index == 1) return 'a';
return super.get(index);
}
}
public static String foo() {
B b = new B();
CharSequence cs = (CharSequence) b;
if (cs.length() != 456) return "fail 01";
if (b.length() != 456) return "fail 02";
if (b.getLength() != 456) return "fail 03";
if (cs.charAt(0) != 'z') return "fail 1";
if (b.get(0) != 'z') return "fail 2";
if (cs.charAt(1) != 'a') return "fail 3";
if (b.get(1) != 'a') return "fail 4";
return "OK";
}
}
// FILE: test.kt
open class A : CharSequence {
override val length: Int = 123
@@ -1,29 +0,0 @@
import java.util.*;
public class J {
public static class B extends A {
public int getLength() { return 456; }
public char get(int index) {
if (index == 1) return 'a';
return super.get(index);
}
}
public static String foo() {
B b = new B();
CharSequence cs = (CharSequence) b;
if (cs.length() != 456) return "fail 01";
if (b.length() != 456) return "fail 02";
if (b.getLength() != 456) return "fail 03";
if (cs.charAt(0) != 'z') return "fail 1";
if (b.get(0) != 'z') return "fail 2";
if (cs.charAt(1) != 'a') return "fail 3";
if (b.get(1) != 'a') return "fail 4";
return "OK";
}
}
@@ -1,3 +1,5 @@
// FILE: J.java
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -62,3 +64,32 @@ public class J extends MyList {
return super.listIterator();
}
}
// FILE: test.kt
abstract class MyList : List<String>
class ListImpl : J() {
override val size: Int get() = super.size + 1
}
fun box(): String {
val impl = ListImpl()
if (impl.size != 56) return "fail 1"
if (!impl.contains("abc")) return "fail 2"
val l: List<String> = impl
if (l.size != 56) return "fail 3"
if (!l.contains("abc")) return "fail 4"
val anyList: List<Any?> = impl as List<Any?>
if (anyList.size != 56) return "fail 5"
if (!anyList.contains("abc")) return "fail 6"
if (anyList.contains(1)) return "fail 7"
if (anyList.contains(null)) return "fail 8"
return "OK"
}
@@ -1,26 +0,0 @@
abstract class MyList : List<String>
class ListImpl : J() {
override val size: Int get() = super.size + 1
}
fun box(): String {
val impl = ListImpl()
if (impl.size != 56) return "fail 1"
if (!impl.contains("abc")) return "fail 2"
val l: List<String> = impl
if (l.size != 56) return "fail 3"
if (!l.contains("abc")) return "fail 4"
val anyList: List<Any?> = impl as List<Any?>
if (anyList.size != 56) return "fail 5"
if (!anyList.contains("abc")) return "fail 6"
if (anyList.contains(1)) return "fail 7"
if (anyList.contains(null)) return "fail 8"
return "OK"
}
@@ -1,3 +1,5 @@
// FILE: J.java
public class J {
abstract static public class AImpl {
public char charAt(int index) {
@@ -13,3 +15,14 @@ public class J {
}
}
}
// FILE: test.kt
class X : J.A()
fun box(): String {
val x = X()
if (x.length != 56) return "fail 1"
if (x[0] != 'A') return "fail 2"
return "OK"
}
@@ -1,9 +0,0 @@
class X : J.A()
fun box(): String {
val x = X()
if (x.length != 56) return "fail 1"
if (x[0] != 'A') return "fail 2"
return "OK"
}
@@ -1,3 +1,15 @@
// FILE: J.java
public class J {
public static class A extends AImpl implements CharSequence {
public CharSequence subSequence(int start, int end) {
return null;
}
}
}
// FILE: test.kt
abstract class AImpl {
fun charAt(index: Int): Char {
return 'A'
@@ -1,7 +0,0 @@
public class J {
public static class A extends AImpl implements CharSequence {
public CharSequence subSequence(int start, int end) {
return null;
}
}
}
@@ -1,3 +1,5 @@
// FILE: J.java
import java.util.*;
public class J {
abstract static public class AImpl {
@@ -97,3 +99,15 @@ public class J {
public static class A extends AImpl implements List<String> {
}
}
// FILE: test.kt
class X : J.A()
fun box(): String {
val x = X()
if (x.size != 56) return "fail 1"
if (!x.contains("")) return "fail 2"
return "OK"
}
@@ -1,10 +0,0 @@
class X : J.A()
fun box(): String {
val x = X()
if (x.size != 56) return "fail 1"
if (!x.contains("")) return "fail 2"
return "OK"
}
@@ -1,3 +1,12 @@
// FILE: A.java
public class A extends AImpl implements java.util.List<String> {
public <T> T[] toArray(T[] a) {return null;}
public Object[] toArray() {return null;}
}
// FILE: test.kt
public abstract class AImpl {
fun add(element: String): Boolean {
throw UnsupportedOperationException()
@@ -1,4 +0,0 @@
public class A extends AImpl implements java.util.List<String> {
public <T> T[] toArray(T[] a) {return null;}
public Object[] toArray() {return null;}
}
@@ -1,3 +1,5 @@
// FILE: J.java
import java.util.*;
public class J {
abstract static public class AImpl<E> {
@@ -97,3 +99,15 @@ public class J {
public static class A<E> extends AImpl<E> implements List<E> {
}
}
// FILE: test.kt
class X : J.A<Any?>()
fun box(): String {
val x = X()
if (x.size != 56) return "fail 1"
if (!x.contains(null)) return "fail 2"
return "OK"
}
@@ -1,10 +0,0 @@
class X : J.A<Any?>()
fun box(): String {
val x = X()
if (x.size != 56) return "fail 1"
if (!x.contains(null)) return "fail 2"
return "OK"
}
@@ -1,3 +1,13 @@
// FILE: J.java
import java.util.*;
public class J implements Container {
final public String removeAt(int index) { return "abc"; }
}
// FILE: test.kt
interface Container {
fun removeAt(x: Int): String
}
@@ -1,5 +0,0 @@
import java.util.*;
public class J implements Container {
final public String removeAt(int index) { return "abc"; }
}
@@ -1,3 +1,13 @@
// FILE: J.java
import java.util.*;
public class J implements Sized {
final public int getSize() { return 123; }
}
// FILE: test.kt
interface Sized {
val size: Int
}
@@ -1,5 +0,0 @@
import java.util.*;
public class J implements Sized {
final public int getSize() { return 123; }
}
@@ -1,3 +1,21 @@
// FILE: J.java
import java.util.*;
public class J {
private static class MyList<E> extends KList<E> {}
public static String foo() {
Collection<String> collection = new MyList<String>();
if (!collection.contains("ABCDE")) return "fail 1";
if (!collection.containsAll(Arrays.asList(1, 2, 3))) return "fail 2";
return "OK";
}
}
// FILE: test.kt
open class KList<E> : MutableList<E> {
override fun add(e: E): Boolean {
throw UnsupportedOperationException()
@@ -1,13 +0,0 @@
import java.util.*;
public class J {
private static class MyList<E> extends KList<E> {}
public static String foo() {
Collection<String> collection = new MyList<String>();
if (!collection.contains("ABCDE")) return "fail 1";
if (!collection.containsAll(Arrays.asList(1, 2, 3))) return "fail 2";
return "OK";
}
}
@@ -1,3 +1,15 @@
// FILE: J.java
import java.util.*;
public class J {
public static String nullValue() {
return null;
}
}
// FILE: test.kt
class MySet : Set<String> {
override val size: Int
get() = throw UnsupportedOperationException()
@@ -37,4 +49,4 @@ fun box(): String {
null in anySet
return "OK"
}
}
@@ -1,7 +0,0 @@
import java.util.*;
public class J {
public static String nullValue() {
return null;
}
}
@@ -1,3 +1,21 @@
// FILE: J.java
import java.util.*;
public class J {
private static class MyList<E> extends KList<E> {}
public static String foo() {
Collection<String> collection = new MyList<String>();
if (!collection.contains("ABCDE")) return "fail 1";
if (!collection.containsAll(Arrays.asList(1, 2, 3))) return "fail 2";
return "OK";
}
}
// FILE: test.kt
open class KList<E> : List<E> {
override val size: Int
get() = throw UnsupportedOperationException()
@@ -37,4 +55,4 @@ open class KList<E> : List<E> {
}
}
fun box() = J.foo()
fun box() = J.foo()
@@ -1,13 +0,0 @@
import java.util.*;
public class J {
private static class MyList<E> extends KList<E> {}
public static String foo() {
Collection<String> collection = new MyList<String>();
if (!collection.contains("ABCDE")) return "fail 1";
if (!collection.containsAll(Arrays.asList(1, 2, 3))) return "fail 2";
return "OK";
}
}
@@ -1,3 +1,21 @@
// FILE: J.java
import java.util.*;
public class J {
private static class MyMap<K, V> extends KMap<K, V> {}
public static String foo() {
Map<String, Integer> collection = new MyMap<String, Integer>();
if (!collection.containsKey("ABCDE")) return "fail 1";
if (!collection.containsValue(1)) return "fail 2";
return "OK";
}
}
// FILE: test.kt
open class KMap<K, V> : Map<K, V> {
override val size: Int
get() = throw UnsupportedOperationException()
@@ -1,13 +0,0 @@
import java.util.*;
public class J {
private static class MyMap<K, V> extends KMap<K, V> {}
public static String foo() {
Map<String, Integer> collection = new MyMap<String, Integer>();
if (!collection.containsKey("ABCDE")) return "fail 1";
if (!collection.containsValue(1)) return "fail 2";
return "OK";
}
}
@@ -1,3 +1,28 @@
// FILE: J.java
import java.util.*;
public class J {
private static class MyList extends A {}
public static String foo() {
MyList myList = new MyList();
List<Integer> list = (List<Integer>) myList;
if (!list.remove((Integer) 1)) return "fail 1";
if (list.remove((int) 1) != 123) return "fail 2";
if (!myList.remove((Integer) 1)) return "fail 3";
if (myList.remove((int) 1) != 123) return "fail 4";
if (myList.removeAt(1) != 123) return "fail 5";
return "OK";
}
}
// FILE: test.kt
open class A : MutableList<Int> {
override val size: Int
get() = throw UnsupportedOperationException()
@@ -76,4 +101,4 @@ open class A : MutableList<Int> {
}
}
fun box() = J.foo()
fun box() = J.foo()
@@ -1,20 +0,0 @@
import java.util.*;
public class J {
private static class MyList extends A {}
public static String foo() {
MyList myList = new MyList();
List<Integer> list = (List<Integer>) myList;
if (!list.remove((Integer) 1)) return "fail 1";
if (list.remove((int) 1) != 123) return "fail 2";
if (!myList.remove((Integer) 1)) return "fail 3";
if (myList.remove((int) 1) != 123) return "fail 4";
if (myList.removeAt(1) != 123) return "fail 5";
return "OK";
}
}
@@ -1,3 +1,21 @@
// FILE: J.java
import java.util.*;
public class J {
private static class MyList extends KList {}
public static String foo() {
Collection<String> collection = new MyList();
if (!collection.contains("ABCDE")) return "fail 1";
if (!collection.containsAll(Arrays.asList(1, 2, 3))) return "fail 2";
return "OK";
}
}
// FILE: test.kt
abstract class KList : MutableList<String> {
override val size: Int
get() = throw UnsupportedOperationException()
@@ -1,13 +0,0 @@
import java.util.*;
public class J {
private static class MyList extends KList {}
public static String foo() {
Collection<String> collection = new MyList();
if (!collection.contains("ABCDE")) return "fail 1";
if (!collection.containsAll(Arrays.asList(1, 2, 3))) return "fail 2";
return "OK";
}
}