Rename tests: boxWithJava -> boxAgainstJava

This commit is contained in:
Alexander Udalov
2014-06-25 03:42:42 +04:00
parent 544cf4f28d
commit 09863445bb
163 changed files with 125 additions and 125 deletions

View File

@@ -0,0 +1,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@interface JavaAnn {
String value();
}

View File

@@ -0,0 +1,8 @@
JavaAnn("value") class MyClass
fun box(): String {
val ann = javaClass<MyClass>().getAnnotation(javaClass<JavaAnn>())
if (ann == null) return "fail: cannot find Ann on MyClass}"
if (ann.value() != "value") return "fail: annotation parameter i should be 'value', but was ${ann.value()}"
return "OK"
}

View File

@@ -0,0 +1,18 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@interface JavaAnn {
String value() default "default";
}
@Retention(RetentionPolicy.RUNTIME)
@interface JavaAnn2 {
int a() default 1;
byte b() default 1;
short c() default 1;
double d() default 1;
float e() default 1;
long j() default 1;
String f() default "default";
}

View File

@@ -0,0 +1,20 @@
JavaAnn class MyClass
JavaAnn2 class MyClass2
fun box(): String {
val ann = javaClass<MyClass>().getAnnotation(javaClass<JavaAnn>())
if (ann == null) return "fail: cannot find Ann on MyClass}"
if (ann.value() != "default") return "fail: annotation parameter i should be 'default', but was ${ann.value()}"
val ann2 = javaClass<MyClass2>().getAnnotation(javaClass<JavaAnn2>())
if (ann2 == null) return "fail: cannot find Ann on MyClass}"
if (ann2.a() != 1) return "fail for a: expected = 1, but was ${ann2.a()}"
if (ann2.b() != 1.toByte()) return "fail for b: expected = 1, but was ${ann2.b()}"
if (ann2.c() != 1.toShort()) return "fail for c: expected = 1, but was ${ann2.c()}"
if (ann2.d() != 1.0) return "fail for d: expected = 1, but was ${ann2.d()}"
if (ann2.e() != 1F) return "fail for e: expected = 1, but was ${ann2.e()}"
if (ann2.j() != 1L) return "fail for j: expected = 1, but was ${ann2.j()}"
if (ann2.f() != "default") return "fail for f: expected = default, but was ${ann2.f()}"
return "OK"
}

View File

@@ -0,0 +1,8 @@
class Foo {
public static final int i = -2;
public static final short s = -2;
public static final float f = -2f;
public static final double d = -2.0;
public static final long l = -2L;
public static final byte b = -2;
}

View File

@@ -0,0 +1,26 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b) class MyClass
fun box(): String {
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
if (ann == null) return "fail: cannot find Ann on MyClass}"
if (ann.i != -2) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.s != (-2).toShort()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.f != -2.toFloat()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.d != -2.toDouble()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.l != -2.toLong()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.b != (-2).toByte()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
val i: Int,
val s: Short,
val f: Float,
val d: Double,
val l: Long,
val b: Byte
)

View File

@@ -0,0 +1,11 @@
class Foo {
public static final int i = 2;
public static final short s = 2;
public static final float f = 2f;
public static final double d = 2.0;
public static final long l = 2L;
public static final byte b = 2;
public static final boolean bool = true;
public static final char c = 'c';
public static final String str = "str";
}

View File

@@ -0,0 +1,32 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str) class MyClass
fun box(): String {
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
if (ann == null) return "fail: cannot find Ann on MyClass}"
if (ann.i != 2) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.s != 2.toShort()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.f != 2.toFloat()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.d != 2.toDouble()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.l != 2.toLong()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.b != 2.toByte()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (!ann.bool) return "fail: annotation parameter i should be true, but was ${ann.i}"
if (ann.c != 'c') return "fail: annotation parameter i should be c, but was ${ann.i}"
if (ann.str != "str") return "fail: annotation parameter i should be str, but was ${ann.i}"
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
val i: Int,
val s: Short,
val f: Float,
val d: Double,
val l: Long,
val b: Byte,
val bool: Boolean,
val c: Char,
val str: String
)

View File

@@ -0,0 +1,9 @@
class Foo {
public static final int i = 2;
public static final short s = 2;
public static final float f = 2;
public static final double d = 2;
public static final long l = 2;
public static final byte b = 2;
public static final char c = 99;
}

View File

@@ -0,0 +1,28 @@
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.c) class MyClass
fun box(): String {
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
if (ann == null) return "fail: cannot find Ann on MyClass}"
if (ann.i != 2) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.s != 2.toShort()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.f != 2.toFloat()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.d != 2.toDouble()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.l != 2.toLong()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.b != 2.toByte()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
if (ann.c != 'c') return "fail: annotation parameter i should be c, but was ${ann.i}"
return "OK"
}
Retention(RetentionPolicy.RUNTIME)
annotation class Ann(
val i: Int,
val s: Short,
val f: Float,
val d: Double,
val l: Long,
val b: Byte,
val c: Char
)

View File

@@ -0,0 +1,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.CLASS)
@interface Foo {
}

View File

@@ -0,0 +1,8 @@
import java.lang.annotation.*
Foo class Bar
fun box(): String {
Bar()
return "OK"
}