Merge boxWithJava testData into box, delete BoxWithJava test

This commit is contained in:
Alexander Udalov
2016-03-07 16:54:45 +03:00
committed by Alexander Udalov
parent 16a0ddd2fb
commit f8dfaf4599
117 changed files with 723 additions and 815 deletions
@@ -0,0 +1,68 @@
// 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
override fun get(index: Int) = 'z';
override fun subSequence(start: Int, end: Int): CharSequence {
throw UnsupportedOperationException()
}
}
fun box(): String {
val b = J.B()
val a = A()
if (b[0] != 'z') return "fail 6"
if (a[0] != 'z') return "fail 7"
if (b[1] != 'a') return "fail 8"
if (a[0] != 'z') return "fail 9"
if (b.get(0) != 'z') return "fail 10"
if (a.get(0) != 'z') return "fail 11"
if (b.get(1) != 'a') return "fail 12"
if (a.get(1) != 'z') return "fail 13"
var cs: CharSequence = a
if (a.length != 123) return "fail 14"
if (cs.length != 123) return "fail 15"
cs = b
if (b.length != 456) return "fail 16"
if (b.length != 456) return "fail 17"
return J.foo();
}
@@ -0,0 +1,95 @@
// FILE: J.java
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class J extends MyList {
@Override
public int getSize() {
return 55;
}
@Override
public int lastIndexOf(String s) {
return 0;
}
@Override
public int indexOf(String s) {
return 0;
}
@Override
public boolean contains(String s) {
return true;
}
@Override
public boolean isEmpty() {
return false;
}
@NotNull
@Override
public Iterator<String> iterator() {
return null;
}
@Override
public boolean containsAll(Collection<?> c) {
return false;
}
@Override
public String get(int index) {
return null;
}
@Override
public List<String> subList(int i, int i1) {
return super.subList(i, i1);
}
@Override
public ListIterator<String> listIterator(int i) {
return super.listIterator(i);
}
@Override
public ListIterator<String> listIterator() {
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"
}
@@ -0,0 +1,28 @@
// FILE: J.java
public class J {
abstract static public class AImpl {
public char charAt(int index) {
return 'A';
}
public final int length() { return 56; }
}
public static class A extends AImpl implements CharSequence {
public CharSequence subSequence(int start, int end) {
return null;
}
}
}
// 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"
}
@@ -0,0 +1,30 @@
// 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'
}
fun length(): Int {
return 56
}
}
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"
}
@@ -0,0 +1,113 @@
// FILE: J.java
import java.util.*;
public class J {
abstract static public class AImpl {
public final int size() {
return 56;
}
public boolean isEmpty() {
return false;
}
public final boolean contains(Object o) {
return true;
}
public Iterator<String> iterator() {
return null;
}
public Object[] toArray() {
return new Object[0];
}
public <T> T[] toArray(T[] a) {
return null;
}
public boolean add(String s) {
return false;
}
public boolean remove(Object o) {
return false;
}
public boolean containsAll(Collection<?> c) {
return false;
}
public boolean addAll(Collection<? extends String> c) {
return false;
}
public boolean addAll(int index, Collection<? extends String> c) {
return false;
}
public boolean removeAll(Collection<?> c) {
return false;
}
public boolean retainAll(Collection<?> c) {
return false;
}
public void clear() {
}
public String get(int index) {
return null;
}
public String set(int index, String element) {
return null;
}
public void add(int index, String element) {
}
public String remove(int index) {
return null;
}
public int indexOf(Object o) {
return 0;
}
public int lastIndexOf(Object o) {
return 0;
}
public ListIterator<String> listIterator() {
return null;
}
public ListIterator<String> listIterator(int index) {
return null;
}
public List<String> subList(int fromIndex, int toIndex) {
return null;
}
}
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"
}
@@ -0,0 +1,102 @@
// WITH_RUNTIME
// 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()
}
fun remove(element: Any?): Boolean {
throw UnsupportedOperationException()
}
@JvmSuppressWildcards(suppress = false)
fun addAll(elements: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
fun addAll(index: Int, elements: Collection<@JvmWildcard String>): Boolean {
throw UnsupportedOperationException()
}
fun removeAll(elements: Collection<*>): Boolean {
throw UnsupportedOperationException()
}
fun retainAll(elements: Collection<*>): Boolean {
throw UnsupportedOperationException()
}
fun clear() {
throw UnsupportedOperationException()
}
fun set(index: Int, element: String): String {
throw UnsupportedOperationException()
}
fun add(index: Int, element: String) {
throw UnsupportedOperationException()
}
fun remove(index: Int): String {
throw UnsupportedOperationException()
}
fun listIterator(): MutableListIterator<String> {
throw UnsupportedOperationException()
}
fun listIterator(index: Int): MutableListIterator<String> {
throw UnsupportedOperationException()
}
fun subList(fromIndex: Int, toIndex: Int): MutableList<String> {
throw UnsupportedOperationException()
}
fun size(): Int = 56
fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
fun contains(element: Any?) = true
fun containsAll(elements: Collection<*>): Boolean {
throw UnsupportedOperationException()
}
fun get(index: Int): String {
throw UnsupportedOperationException()
}
fun indexOf(element: Any?): Int {
throw UnsupportedOperationException()
}
fun lastIndexOf(element: Any?): Int {
throw UnsupportedOperationException()
}
fun iterator(): MutableIterator<String> {
throw UnsupportedOperationException()
}
}
class X : A()
fun box(): String {
val x = X()
if (x.size != 56) return "fail 1"
if (!x.contains("")) return "fail 2"
return "OK"
}
@@ -0,0 +1,113 @@
// FILE: J.java
import java.util.*;
public class J {
abstract static public class AImpl<E> {
public int size() {
return 56;
}
public boolean isEmpty() {
return false;
}
public final boolean contains(Object o) {
return true;
}
public Iterator<E> iterator() {
return null;
}
public Object[] toArray() {
return new Object[0];
}
public <T> T[] toArray(T[] a) {
return null;
}
public boolean add(E s) {
return false;
}
public boolean remove(Object o) {
return false;
}
public boolean containsAll(Collection<?> c) {
return false;
}
public boolean addAll(Collection<? extends E> c) {
return false;
}
public boolean addAll(int index, Collection<? extends E> c) {
return false;
}
public boolean removeAll(Collection<?> c) {
return false;
}
public boolean retainAll(Collection<?> c) {
return false;
}
public void clear() {
}
public E get(int index) {
return null;
}
public E set(int index, E element) {
return null;
}
public void add(int index, E element) {
}
public E remove(int index) {
return null;
}
public int indexOf(Object o) {
return 0;
}
public int lastIndexOf(Object o) {
return 0;
}
public ListIterator<E> listIterator() {
return null;
}
public ListIterator<E> listIterator(int index) {
return null;
}
public List<E> subList(int fromIndex, int toIndex) {
return null;
}
}
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"
}
@@ -0,0 +1,110 @@
// 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
}
class A : J(), MutableList<String> {
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override val size: Int
get() = throw UnsupportedOperationException()
override fun contains(element: String): Boolean {
throw UnsupportedOperationException()
}
override fun containsAll(elements: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun get(index: Int): String {
throw UnsupportedOperationException()
}
override fun indexOf(element: String): Int {
throw UnsupportedOperationException()
}
override fun lastIndexOf(element: String): Int {
throw UnsupportedOperationException()
}
override fun add(element: String): Boolean {
throw UnsupportedOperationException()
}
override fun remove(element: String): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(elements: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(index: Int, elements: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun removeAll(elements: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun retainAll(elements: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun clear() {
throw UnsupportedOperationException()
}
override fun set(index: Int, element: String): String {
throw UnsupportedOperationException()
}
override fun add(index: Int, element: String) {
throw UnsupportedOperationException()
}
override fun listIterator(): MutableListIterator<String> {
throw UnsupportedOperationException()
}
override fun listIterator(index: Int): MutableListIterator<String> {
throw UnsupportedOperationException()
}
override fun subList(fromIndex: Int, toIndex: Int): MutableList<String> {
throw UnsupportedOperationException()
}
override fun iterator(): MutableIterator<String> {
throw UnsupportedOperationException()
}
}
fun box(): String {
val a = A()
if (a.removeAt(0) != "abc") return "fail 1"
val l: MutableList<String> = a
if (l.removeAt(0) != "abc") return "fail 2"
val anyList: MutableList<Any?> = a as MutableList<Any?>
if (anyList.removeAt(0) != "abc") return "fail 3"
val container: Container = a
if (container.removeAt(0) != "abc") return "fail 4"
return "OK"
}
@@ -0,0 +1,44 @@
// 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
}
class A<T> : J(), Collection<T> {
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override fun contains(element: T): Boolean {
throw UnsupportedOperationException()
}
override fun iterator(): Iterator<T> {
throw UnsupportedOperationException()
}
override fun containsAll(elements: Collection<T>): Boolean {
throw UnsupportedOperationException()
}
}
fun box(): String {
val a = A<String>()
if (a.size != 123) return "fail 1"
val c: Collection<String> = a
if (c.size != 123) return "fail 2"
val sized: Sized = a
if (sized.size != 123) return "fail 3"
return "OK"
}
@@ -0,0 +1,99 @@
// 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()
}
override fun remove(o: E): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(c: Collection<E>): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(index: Int, c: Collection<E>): Boolean {
throw UnsupportedOperationException()
}
override fun removeAll(c: Collection<E>): Boolean {
throw UnsupportedOperationException()
}
override fun retainAll(c: Collection<E>): Boolean {
throw UnsupportedOperationException()
}
override fun clear() {
throw UnsupportedOperationException()
}
override fun set(index: Int, element: E): E {
throw UnsupportedOperationException()
}
override fun add(index: Int, element: E) {
throw UnsupportedOperationException()
}
override fun removeAt(index: Int): E {
throw UnsupportedOperationException()
}
override fun listIterator(): MutableListIterator<E> {
throw UnsupportedOperationException()
}
override fun listIterator(index: Int): MutableListIterator<E> {
throw UnsupportedOperationException()
}
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E> {
throw UnsupportedOperationException()
}
override fun iterator(): MutableIterator<E> {
throw UnsupportedOperationException()
}
override val size: Int
get() = throw UnsupportedOperationException()
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override fun contains(o: E) = true
override fun containsAll(c: Collection<E>) = true
override fun get(index: Int): E {
throw UnsupportedOperationException()
}
override fun indexOf(o: E): Int {
throw UnsupportedOperationException()
}
override fun lastIndexOf(o: E): Int {
throw UnsupportedOperationException()
}
}
fun box() = J.foo()
@@ -0,0 +1,52 @@
// 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()
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override fun contains(o: String): Boolean {
throw UnsupportedOperationException()
}
override fun iterator(): Iterator<String> {
throw UnsupportedOperationException()
}
override fun containsAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
}
fun box(): String {
val mySet = MySet()
// no UnsupportedOperationException thrown
mySet.contains(J.nullValue())
J.nullValue() in mySet
val set: Set<String> = mySet
set.contains(J.nullValue())
J.nullValue() in set
val anySet: Set<Any?> = mySet as Set<Any?>
anySet.contains(J.nullValue())
anySet.contains(null)
J.nullValue() in anySet
null in anySet
return "OK"
}
@@ -0,0 +1,58 @@
// 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()
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override fun contains(o: E) = true
override fun containsAll(c: Collection<E>) = true
override fun iterator(): Iterator<E> {
throw UnsupportedOperationException()
}
override fun get(index: Int): E {
throw UnsupportedOperationException()
}
override fun indexOf(element: E): Int {
throw UnsupportedOperationException()
}
override fun lastIndexOf(element: E): Int {
throw UnsupportedOperationException()
}
override fun listIterator(): ListIterator<E> {
throw UnsupportedOperationException()
}
override fun listIterator(index: Int): ListIterator<E> {
throw UnsupportedOperationException()
}
override fun subList(fromIndex: Int, toIndex: Int): List<E> {
throw UnsupportedOperationException()
}
}
fun box() = J.foo()
@@ -0,0 +1,42 @@
// 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()
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override fun containsKey(key: K) = true
override fun containsValue(value: V) = true
override fun get(key: K): V? {
throw UnsupportedOperationException()
}
override val keys: Set<K>
get() = throw UnsupportedOperationException()
override val values: Collection<V>
get() = throw UnsupportedOperationException()
override val entries: Set<Map.Entry<K, V>>
get() = throw UnsupportedOperationException()
}
fun box() = J.foo()
+104
View File
@@ -0,0 +1,104 @@
// 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()
override fun isEmpty(): Boolean = throw UnsupportedOperationException()
override fun contains(o: Int): Boolean {
throw UnsupportedOperationException()
}
override fun containsAll(c: Collection<Int>): Boolean {
throw UnsupportedOperationException()
}
override fun get(index: Int): Int {
throw UnsupportedOperationException()
}
override fun indexOf(o: Int): Int {
throw UnsupportedOperationException()
}
override fun lastIndexOf(o: Int): Int {
throw UnsupportedOperationException()
}
override fun add(e: Int): Boolean {
throw UnsupportedOperationException()
}
override fun remove(o: Int) = true
override fun removeAt(index: Int): Int = 123
override fun addAll(c: Collection<Int>): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(index: Int, c: Collection<Int>): Boolean {
throw UnsupportedOperationException()
}
override fun removeAll(c: Collection<Int>): Boolean {
throw UnsupportedOperationException()
}
override fun retainAll(c: Collection<Int>): Boolean {
throw UnsupportedOperationException()
}
override fun clear() {
throw UnsupportedOperationException()
}
override fun set(index: Int, element: Int): Int {
throw UnsupportedOperationException()
}
override fun add(index: Int, element: Int) {
throw UnsupportedOperationException()
}
override fun listIterator(): MutableListIterator<Int> {
throw UnsupportedOperationException()
}
override fun listIterator(index: Int): MutableListIterator<Int> {
throw UnsupportedOperationException()
}
override fun subList(fromIndex: Int, toIndex: Int): MutableList<Int> {
throw UnsupportedOperationException()
}
override fun iterator(): MutableIterator<Int> {
throw UnsupportedOperationException()
}
}
fun box() = J.foo()
+99
View File
@@ -0,0 +1,99 @@
// 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()
override fun isEmpty(): Boolean {
throw UnsupportedOperationException()
}
override fun contains(o: String) = true
override fun containsAll(c: Collection<String>) = true
override fun get(index: Int): String {
throw UnsupportedOperationException()
}
override fun indexOf(o: String): Int {
throw UnsupportedOperationException()
}
override fun lastIndexOf(o: String): Int {
throw UnsupportedOperationException()
}
override fun iterator(): MutableIterator<String> {
throw UnsupportedOperationException()
}
override fun add(e: String): Boolean {
throw UnsupportedOperationException()
}
override fun remove(o: String): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun addAll(index: Int, c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun removeAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun retainAll(c: Collection<String>): Boolean {
throw UnsupportedOperationException()
}
override fun clear() {
throw UnsupportedOperationException()
}
override fun set(index: Int, element: String): String {
throw UnsupportedOperationException()
}
override fun add(index: Int, element: String) {
throw UnsupportedOperationException()
}
override fun removeAt(index: Int): String {
throw UnsupportedOperationException()
}
override fun listIterator(): MutableListIterator<String> {
throw UnsupportedOperationException()
}
override fun listIterator(index: Int): MutableListIterator<String> {
throw UnsupportedOperationException()
}
override fun subList(fromIndex: Int, toIndex: Int): MutableList<String> {
throw UnsupportedOperationException()
}
}
fun box() = J.foo()