Split GenerateNotNullAssertionsTests into standard box and bytecode tests
This commit is contained in:
committed by
Alexander Udalov
parent
dfd0042a5b
commit
dd20b74030
@@ -1,39 +0,0 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class A {
|
||||
@NotNull
|
||||
public final String NULL = null;
|
||||
|
||||
@NotNull
|
||||
public static final String STATIC_NULL = null;
|
||||
|
||||
public String foo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String staticFoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public A plus(A a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public A inc() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object get(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public A a() { return this; }
|
||||
|
||||
public static class B {
|
||||
public static B b() { return null; }
|
||||
}
|
||||
|
||||
public static class C {
|
||||
public static C c() { return null; }
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
class AssertionChecker(val illegalStateExpected: Boolean) {
|
||||
operator fun invoke(name: String, f: () -> Any) {
|
||||
try {
|
||||
f()
|
||||
} catch (e: IllegalStateException) {
|
||||
if (!illegalStateExpected) throw AssertionError("Unexpected IllegalStateException on calling $name")
|
||||
return
|
||||
}
|
||||
if (illegalStateExpected) throw AssertionError("IllegalStateException expected on calling $name")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface Tr {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
class Derived : A(), Tr {
|
||||
override fun foo() = super<A>.foo()
|
||||
}
|
||||
|
||||
class Delegated : Tr by Derived() {
|
||||
}
|
||||
|
||||
|
||||
fun checkAssertions(illegalStateExpected: Boolean) {
|
||||
val check = AssertionChecker(illegalStateExpected)
|
||||
|
||||
// simple call
|
||||
check("foo") { A().foo() }
|
||||
|
||||
// simple static call
|
||||
check("staticFoo") { A.staticFoo() }
|
||||
|
||||
// supercall
|
||||
check("foo") { Derived().foo() }
|
||||
|
||||
// delegated call
|
||||
check("foo") { Delegated().foo() }
|
||||
|
||||
// collection element
|
||||
check("get") { A()[""] }
|
||||
|
||||
// binary expression
|
||||
check("plus") { A() + A() }
|
||||
|
||||
// field
|
||||
check("NULL") { A().NULL }
|
||||
|
||||
// static field
|
||||
check("STATIC_NULL") { A.STATIC_NULL }
|
||||
|
||||
// postfix expression
|
||||
// TODO:
|
||||
// check("inc") { var a = A().a(); a++ }
|
||||
|
||||
// prefix expression
|
||||
check("inc-b") { var a = A.B.b(); a++ }
|
||||
|
||||
// prefix expression
|
||||
check("inc-c") { var a = A.C.c(); a++ }
|
||||
|
||||
// prefix expression
|
||||
check("inc") { var a = A().a(); ++a }
|
||||
|
||||
// prefix expression
|
||||
check("inc-b") { var a = A.B.b(); ++a }
|
||||
|
||||
// prefix expression
|
||||
// TODO:
|
||||
// check("inc-c") { var a = A.C.c(); ++a }
|
||||
}
|
||||
|
||||
operator fun A.C.inc(): A.C = A.C()
|
||||
operator fun <T> T.inc(): T = null as T
|
||||
@@ -1,9 +0,0 @@
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(): Any {
|
||||
val a = ArrayList<String>()
|
||||
return a.get(0)
|
||||
}
|
||||
|
||||
fun bar(a: ArrayList<String>) {
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class A<T> {
|
||||
fun add(element: T) {}
|
||||
}
|
||||
|
||||
public fun <R : Any> foo(x: MutableCollection<in R>, block: java.util.AbstractList<R>) {
|
||||
x.add(block.get(0))
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
fun <T : Any> foo(t: T) = t
|
||||
@@ -1,17 +0,0 @@
|
||||
package test;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class doGenerateParamAssertions<Type> {
|
||||
|
||||
public abstract void doTest(@NotNull Type s);
|
||||
|
||||
public static void runTest(doGenerateParamAssertions a) {
|
||||
try {
|
||||
a.doTest(null);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Fail: IllegalArgumentException expected");
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import test.doGenerateParamAssertions as C
|
||||
|
||||
class TestString : C<String>() {
|
||||
override fun doTest(s: String) { }
|
||||
}
|
||||
|
||||
class TestUnit : C<Unit>() {
|
||||
override fun doTest(s: Unit) { }
|
||||
}
|
||||
|
||||
fun doTest() {
|
||||
C.runTest(TestString())
|
||||
C.runTest(TestUnit())
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
class A {
|
||||
fun foo(s: String) {
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class A<T, U> {
|
||||
@NotNull
|
||||
T foo() { return null; }
|
||||
}
|
||||
|
||||
class B<T> extends A<T, Integer> {
|
||||
@Override
|
||||
@NotNull
|
||||
T foo() { return null; }
|
||||
}
|
||||
|
||||
class C extends B<String> {
|
||||
@Override
|
||||
@NotNull
|
||||
String foo() { return null; }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
internal fun bar(a: A<String, Int>, b: B<String>, c: C) {
|
||||
val sa: String = a.foo()
|
||||
val sb: String = b.foo()
|
||||
val sc: String = c.foo()
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
class A<T> {
|
||||
fun add(element: T) {}
|
||||
}
|
||||
|
||||
public fun <R> foo(x: MutableCollection<in R>, block: () -> R) {
|
||||
x.add(block())
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
fun <T> foo(a: List<T>) {
|
||||
val t: T = a.get(0)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import java.util.HashMap
|
||||
|
||||
class A<T: Any> {
|
||||
fun main() {
|
||||
HashMap<String, T>()[""]
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
class A {
|
||||
private fun foo(s: String) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user