Minor change: reformat code in testData files.

This commit is contained in:
Zalim Bashorov
2014-02-14 15:28:40 +04:00
parent 7374d3ab76
commit 38d1142c39
354 changed files with 2144 additions and 1986 deletions
@@ -1,8 +1,7 @@
package foo
trait A {
class object
{
class object {
val OK: String = "OK"
}
}
@@ -8,8 +8,7 @@ class A {
}
fun box() : String {
fun box(): String {
A.a = 2
if (A.a != 2) return "A.a != 2, it: ${A.a}"
@@ -9,8 +9,7 @@ class A {
}
fun box() : String {
fun box(): String {
if (A.a != 2) return "A.a != 2, it: ${A.a}"
if (A.b != 5) return "A.b != 5, it: ${A.b}"
@@ -15,7 +15,7 @@ class B {
}
}
fun box() : String {
fun box(): String {
if (A.a != 3) return "A.a != 3, it: ${A.a}"
if (A.foo() != 5) return "A.foo() != 5, it: ${A.foo()}"
@@ -1,6 +1,6 @@
package foo
fun run<T>(f: ()->T) = f()
fun run<T>(f: () -> T) = f()
fun funfun(): Boolean {
val result = true
@@ -1,6 +1,6 @@
package foo
fun run<T>(f:()->T) = f()
fun run<T>(f: () -> T) = f()
class Fail(val message: String) : RuntimeException(message) {
val isFail = true // workaround for exception handling
@@ -1,15 +1,15 @@
package foo
fun run<T>(f: ()->T) = f()
fun run<T>(f: () -> T) = f()
fun box(): Boolean {
val t = run {
object {
fun boo(param: String): String {
return run { param }
}
}
object {
fun boo(param: String): String {
return run { param }
}
}
}
return t.boo("OK") == "OK"
}
@@ -1,9 +1,9 @@
package foo
val k = {"K"}
val k = { "K" }
fun test(): String {
val o = {"O"}
val o = { "O" }
val funLit = { o() + k() }
return funLit()
@@ -1,23 +1,23 @@
package foo
class A() {
var i = 0
var i = 0
fun f() {
for (j in 0..2) {
foo {
i += j
}
fun f() {
for (j in 0..2) {
foo {
i += j
}
}
}
}
}
fun foo(f : ()->Unit) {
f()
fun foo(f: () -> Unit) {
f()
}
fun box() : Boolean {
val a = A()
a.f()
fun box(): Boolean {
val a = A()
a.f()
return a.i == 3
}
@@ -11,7 +11,7 @@ object foo {
done = 3
}
val extLambda: Int.()->Unit = {
val extLambda: Int.() -> Unit = {
result = "foo.extLambda OK"
done = this
}
@@ -25,7 +25,7 @@ class Foo {
done = -7
}
val extLambda: Int.()->Unit = {
val extLambda: Int.() -> Unit = {
result = "Foo::extLambda OK"
done = this
}
@@ -2,20 +2,20 @@ package foo
import java.util.*
fun box() : Boolean {
fun box(): Boolean {
val oneTwo = Array(2) {
it + 1
}
val a = ArrayList<()->Int>()
val a = ArrayList<() -> Int>()
for (i in oneTwo) {
for (j in 1..2) {
a.add({
var res = 0
for (t in 0..2) {
res += i * j
}
res
})
var res = 0
for (t in 0..2) {
res += i * j
}
res
})
}
}
var sum = 0
@@ -2,21 +2,21 @@ package foo
import java.util.*
fun box() : Boolean {
fun box(): Boolean {
val oneTwo = Array(2) {
it + 1
}
val a = ArrayList<()->Int>()
val a = ArrayList<() -> Int>()
for (i in oneTwo) {
for (l in 1..2) {
val j = l
a.add({
var res = 0
for (t in 0..2) {
res += i * j
}
res
})
var res = 0
for (t in 0..2) {
res += i * j
}
res
})
}
}
var sum = 0
@@ -1,10 +1,10 @@
package foo
fun Any.foo(n: Int): ()->Boolean {
fun Any.foo(n: Int): () -> Boolean {
var count = n
return { --count >= 0 }
}
fun box(): Boolean {
return 1.foo(3)() && !1.foo(0)()
return 1.foo(3)() && !1.foo(0)()
}
@@ -1,26 +1,26 @@
package foo
fun box() : Boolean {
if (f(0) != -3) {
return false
}
if (f(102) != 201) {
return false;
}
if (f(103) != 100) {
return false
}
if (f(-100) != -100) {
return false
}
if (f(-99) != -201) {
return false
}
fun box(): Boolean {
if (f(0) != -3) {
return false
}
if (f(102) != 201) {
return false;
}
if (f(103) != 100) {
return false
}
if (f(-100) != -100) {
return false
}
if (f(-99) != -201) {
return false
}
return true
return true
}
fun f(i : Int) : Int {
var j = i
return --j + (if (j < -100) return -100 else --j) + (if (j > 100) return 100 else 0)
fun f(i: Int): Int {
var j = i
return --j + (if (j < -100) return -100 else --j) + (if (j > 100) return 100 else 0)
}
@@ -4,6 +4,6 @@ var i = 0
inline fun f() = i * 2
fun box() : Boolean {
return (++i + f()) == 3
fun box(): Boolean {
return (++i + f()) == 3
}
@@ -1,19 +1,22 @@
package foo
fun box() : Boolean {
if (f(0) != 201) {
return false
}
if (f(1) != 104) {
fun box(): Boolean {
if (f(0) != 201) {
return false
}
if (f(-2) != -100) {
return false
}
return true
}
if (f(1) != 104) {
return false
}
if (f(-2) != -100) {
return false
}
return true
}
fun f(i : Int) : Int {
var j = i
return ++j + if (j != 1) {(if (j > 0) 100 else return -100) + 2} else 200
fun f(i: Int): Int {
var j = i
return ++j + if (j != 1) {
(if (j > 0) 100 else return -100) + 2
}
else 200
}
@@ -2,16 +2,16 @@ package foo
var d = 0
fun f() : Int {
d = if (d < 0) -100 else 100
return d
fun f(): Int {
d = if (d < 0) -100 else 100
return d
}
fun box() : Boolean {
d = d-- + f() + when(d) {
-100 -> return true
1 -> 1
else -> return false
}
return false
fun box(): Boolean {
d = d-- + f() + when(d) {
-100 -> return true
1 -> 1
else -> return false
}
return false
}
@@ -1,14 +1,13 @@
package foo
fun box() : Boolean {
var i = 0
val c = sum(++i, if (i == 0) return false else i + 2)
if (c != 4) {
return false
}
return true
fun box(): Boolean {
var i = 0
val c = sum(++i, if (i == 0) return false else i + 2)
if (c != 4) {
return false
}
return true
}
fun sum(a1 : Int, a2 : Int) = a1 + a2
fun sum(a1: Int, a2: Int) = a1 + a2
@@ -1,10 +1,10 @@
package foo
fun box() : Boolean {
var i = 0
var t = ++i + if (i == 0) 0 else 2
if (t != 3) {
return false
}
return true
fun box(): Boolean {
var i = 0
var t = ++i + if (i == 0) 0 else 2
if (t != 3) {
return false
}
return true
}
@@ -1,15 +1,15 @@
package foo
fun box() : Boolean {
var i = 0
var t = ++i + when(i) {
3 -> 4
1 -> 2
0 -> 1
else -> 100
}
if (t != 3) {
return false
}
return true
fun box(): Boolean {
var i = 0
var t = ++i + when(i) {
3 -> 4
1 -> 2
0 -> 1
else -> 100
}
if (t != 3) {
return false
}
return true
}
@@ -9,7 +9,7 @@ fun box(): String {
val a1 = A(1)
if (a0.a != 0) return "a0.a != 0, it: ${a0.a}"
if (a1.a != 1) return "a1.a != 1, it: ${a1.a}"
val b1 = B()
if (b1.a != 0) return "b1.a != 0, it: ${b1.a}"
if (b1.b != "a") return "b1.b != 'a', it: ${b1.b}"
@@ -1,36 +1,36 @@
package foo
class T4(
val c1: Boolean,
val c2: Boolean,
val c3: Boolean,
val c4: String
val c1: Boolean,
val c2: Boolean,
val c3: Boolean,
val c4: String
) {
override fun equals(other: Any?): Boolean {
if (other !is T4) return false;
return c1 == other.c1 &&
c2 == other.c2 &&
c3 == other.c3 &&
c4 == other.c4
}
override fun equals(o: Any?): Boolean {
if (o !is T4) return false;
return c1 == o.c1 &&
c2 == o.c2 &&
c3 == o.c3 &&
c4 == o.c4
}
}
fun reformat(
str : String,
normalizeCase : Boolean = true,
uppercaseFirstLetter : Boolean = true,
divideByCamelHumps : Boolean = true,
wordSeparator : String = " "
str: String,
normalizeCase: Boolean = true,
uppercaseFirstLetter: Boolean = true,
divideByCamelHumps: Boolean = true,
wordSeparator: String = " "
) =
T4(normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator)
T4(normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator)
fun box() : String {
fun box(): String {
val expected = T4(true, true, true, " ")
if(reformat("", true, true, true, " ") != expected) return "fail1"
if(reformat("", true, true, true) != expected) return "fail2"
if(reformat("", true, true) != expected) return "fail3"
if(reformat("", true) != expected) return "fail4"
if(reformat("") != expected) return "fail5"
if (reformat("", true, true, true, " ") != expected) return "fail1"
if (reformat("", true, true, true) != expected) return "fail2"
if (reformat("", true, true) != expected) return "fail3"
if (reformat("", true) != expected) return "fail4"
if (reformat("") != expected) return "fail5"
return "OK"
}
@@ -1,12 +1,13 @@
package foo
enum class A(val a: Int = 1) {
FIRST: A()
SECOND: A(2)
FIRST: A()
SECOND: A(2)
}
fun box(): String {
if (A.FIRST.a == 1 && A.SECOND.a == 2) {
return "OK"
}
return "fail"
if (A.FIRST.a == 1 && A.SECOND.a == 2) {
return "OK"
}
return "fail"
}
@@ -1,11 +1,12 @@
package foo
enum class Foo(val a: Int = 1, val b: String) {
B: Foo(2, "b")
C: Foo(b = "b")
B: Foo(2, "b")
C: Foo(b = "b")
}
fun box(): String {
if (Foo.B.a != 2 || Foo.B.b != "b") return "fail1"
if (Foo.C.a != 1 || Foo.C.b != "b") return "fail2"
return "OK"
if (Foo.B.a != 2 || Foo.B.b != "b") return "fail1"
if (Foo.C.a != 1 || Foo.C.b != "b") return "fail2"
return "OK"
}
@@ -1,15 +1,16 @@
package foo
enum class Foo(val a: Int = 1, val b: String = "a") {
A: Foo()
B: Foo(2, "b")
C: Foo(b = "b")
D: Foo(a = 2)
A: Foo()
B: Foo(2, "b")
C: Foo(b = "b")
D: Foo(a = 2)
}
fun box(): String {
if (Foo.A.a != 1 || Foo.A.b != "a") return "fail1"
if (Foo.B.a != 2 || Foo.B.b != "b") return "fail2"
if (Foo.C.a != 1 || Foo.C.b != "b") return "fail3"
if (Foo.D.a != 2 || Foo.D.b != "a") return "fail4"
return "OK"
if (Foo.A.a != 1 || Foo.A.b != "a") return "fail1"
if (Foo.B.a != 2 || Foo.B.b != "b") return "fail2"
if (Foo.C.a != 1 || Foo.C.b != "b") return "fail3"
if (Foo.D.a != 2 || Foo.D.b != "a") return "fail4"
return "OK"
}
@@ -1,12 +1,12 @@
package foo
fun <T> T.toPrefixedString(prefix: String = "", suffix: String="") = prefix + toString() + suffix
fun <T> T.toPrefixedString(prefix: String = "", suffix: String = "") = prefix + toString() + suffix
fun box() : String {
if("mama".toPrefixedString(suffix="321", prefix="papa") != "papamama321") return "fail1"
if("mama".toPrefixedString(prefix="papa") != "papamama") return "fail2"
if("mama".toPrefixedString("papa", "239") != "papamama239") return "fail3"
if("mama".toPrefixedString("papa") != "papamama") return "fail4"
if("mama".toPrefixedString() != "mama") return "fail5"
fun box(): String {
if ("mama".toPrefixedString(suffix = "321", prefix = "papa") != "papamama321") return "fail1"
if ("mama".toPrefixedString(prefix = "papa") != "papamama") return "fail2"
if ("mama".toPrefixedString("papa", "239") != "papamama239") return "fail3"
if ("mama".toPrefixedString("papa") != "papamama") return "fail4"
if ("mama".toPrefixedString() != "mama") return "fail5"
return "OK"
}
@@ -1,14 +1,14 @@
package foo
open abstract class B() {
fun foo(arg: Int = 239 + 1) : Int = arg
fun foo(arg: Int = 239 + 1): Int = arg
}
class C() : B() {
}
fun box() : String {
if(C().foo(10) != 10) return "fail1"
if(C().foo() != 240) return "fail2"
fun box(): String {
if (C().foo(10) != 10) return "fail1"
if (C().foo() != 240) return "fail2"
return "OK"
}
@@ -1,15 +1,15 @@
package foo
open abstract class B() {
abstract fun foo2(arg: Int = 239) : Int
abstract fun foo2(arg: Int = 239): Int
}
class C() : B() {
override fun foo2(arg: Int) : Int = arg
override fun foo2(arg: Int): Int = arg
}
fun box() : String {
if(C().foo2() != 239) return "fail1"
if(C().foo2(10) != 10) return "fail2"
fun box(): String {
if (C().foo2() != 239) return "fail1"
if (C().foo2(10) != 10) return "fail2"
return "OK"
}
@@ -7,7 +7,7 @@ open class A(open val bar: Int = 2) {
class B(override val bar: Int = 3) : A()
fun box() : String {
fun box(): String {
val b = B()
if (b.bar != 3) return "b.bar != 3, it: " + b.bar
if (b.barA != 2) return "b.barA != 2, it: " + b.barA
@@ -1,22 +1,22 @@
package foo
trait A {
fun bar2(arg: Int = 239) : Int
fun bar2(arg: Int = 239): Int
fun bar(arg: Int = 240) : Int = bar2(arg/2)
fun bar(arg: Int = 240): Int = bar2(arg / 2)
}
open abstract class B() : A {
override fun bar2(arg: Int) : Int = arg
override fun bar2(arg: Int): Int = arg
}
class C() : B() {
}
fun box() : String {
if(C().bar(10) != 5) return "fail1: ${C().bar(10)}"
if(C().bar() != 120) return "fail2: ${C().bar()}"
if(C().bar2() != 239) return "fail3: ${C().bar2()}"
if(C().bar2(10) != 10) return "fail4: ${C().bar2(10)}"
fun box(): String {
if (C().bar(10) != 5) return "fail1: ${C().bar(10)}"
if (C().bar() != 120) return "fail2: ${C().bar()}"
if (C().bar2() != 239) return "fail3: ${C().bar2()}"
if (C().bar2(10) != 10) return "fail4: ${C().bar2(10)}"
return "OK"
}
@@ -1,8 +1,11 @@
package foo
class Delegate {
var inner = 1
fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
fun set(t: Any?, p: PropertyMetadata, i: Int) {
inner = i
}
}
fun foo() = Delegate()
@@ -12,9 +15,9 @@ class A {
}
fun box(): String {
val c = A()
if(c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
val c = A()
if (c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
}
@@ -1,8 +1,11 @@
package foo
class Delegate {
var inner = 1
fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
fun set(t: Any?, p: PropertyMetadata, i: Int) {
inner = i
}
}
val p = Delegate()
@@ -12,9 +15,9 @@ class A {
}
fun box(): String {
val c = A()
if(c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
val c = A()
if (c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
}
@@ -1,6 +1,7 @@
package foo
class Delegate {
fun get(t: A, p: PropertyMetadata): Int = 1
fun get(t: A, p: PropertyMetadata): Int = 1
}
val A.prop: Int by Delegate()
@@ -9,5 +10,5 @@ class A {
}
fun box(): String {
return if(A().prop == 1) "OK" else "fail"
return if (A().prop == 1) "OK" else "fail"
}
@@ -3,7 +3,9 @@ package foo
class Delegate {
var inner = 1
fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
fun set(t: Any?, p: PropertyMetadata, i: Int) {
inner = i
}
}
val p = Delegate()
@@ -13,9 +15,9 @@ class A {
}
fun box(): String {
val c = A()
if(c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
val c = A()
if (c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
}
@@ -1,4 +1,5 @@
package foo
class Delegate {
}
@@ -9,5 +10,5 @@ class A {
}
fun box(): String {
return if(A().prop == 1) "OK" else "fail"
return if (A().prop == 1) "OK" else "fail"
}
@@ -5,7 +5,7 @@ trait WithName {
}
class GetPropertyName() {
fun get(withName: WithName, property: PropertyMetadata) : String {
fun get(withName: WithName, property: PropertyMetadata): String {
return withName.name + ":" + property.name;
}
fun set(withName: WithName, property: PropertyMetadata, value: String) {
@@ -1,19 +1,22 @@
package foo
class Delegate {
var inner = 1
fun get(t: Any?, p: PropertyMetadata): Int = inner
}
fun Delegate.set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
fun Delegate.set(t: Any?, p: PropertyMetadata, i: Int) {
inner = i
}
class A {
var prop: Int by Delegate()
}
fun box(): String {
val c = A()
if(c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
val c = A()
if (c.prop != 1) return "fail get"
c.prop = 2
if (c.prop != 2) return "fail set"
return "OK"
}
@@ -5,7 +5,7 @@ trait WithNumber {
}
class IncNumber(val inc: Int) {
fun get(withNumber: WithNumber, property: PropertyMetadata) : Int {
fun get(withNumber: WithNumber, property: PropertyMetadata): Int {
return withNumber.number + inc;
}
fun set(withNumber: WithNumber, property: PropertyMetadata, value: Int) {
@@ -1,4 +1,5 @@
package foo
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int = 1
}
@@ -6,5 +7,5 @@ class Delegate {
val prop: Int by Delegate()
fun box(): String {
return if(prop == 1) "OK" else "fail"
return if (prop == 1) "OK" else "fail"
}
@@ -1,15 +1,18 @@
package foo
class Delegate {
var inner = 1
fun get(t: Any?, p: PropertyMetadata): Int = inner
fun set(t: Any?, p: PropertyMetadata, i: Int) { inner = i }
fun set(t: Any?, p: PropertyMetadata, i: Int) {
inner = i
}
}
var prop: Int by Delegate()
fun box(): String {
if(prop != 1) return "fail get"
prop = 2
if (prop != 2) return "fail set"
return "OK"
if (prop != 1) return "fail get"
prop = 2
if (prop != 2) return "fail set"
return "OK"
}
@@ -6,7 +6,7 @@ trait Getter<T> {
class Delegate<T>(val getter: Getter<T>) {
var t: T? = null
fun get(obj: Any, property: PropertyMetadata) : T {
fun get(obj: Any, property: PropertyMetadata): T {
if (t != null) {
return t!!
}
@@ -9,7 +9,8 @@ enum class B(open val bar: Int) {
y = 0
}
}
b : B(4){}
b : B(4) {
}
c : B(5)
}
@@ -7,7 +7,8 @@ enum class Simple {
}
enum class A {
a : A() {}
a : A() {
}
b : A()
c
}
@@ -21,8 +22,8 @@ fun box(): String {
if (ok.ordinal() != 0) return "ok = Simple.Ok; ok.ordinal() != 0, it: ${ok.ordinal()}"
val ok2 = Simple.valueOf("OK")
if(!ok2.equals(ok)) return "ok2 not equal ok"
if(!ok2.identityEquals(ok)) return "ok2 not identity equal ok"
if (!ok2.equals(ok)) return "ok2 not equal ok"
if (!ok2.identityEquals(ok)) return "ok2 not identity equal ok"
if (EmptyEnum.values().size != 0) return "EmptyEnum.values().size != 0"
@@ -1,7 +1,7 @@
fun box() : String {
return apply( "OK", {(arg: String) -> arg } )
fun box(): String {
return apply("OK", {(arg: String) -> arg })
}
fun apply(arg : String, f : (p:String) -> String) : String {
fun apply(arg: String, f: (p: String) -> String): String {
return f(arg)
}
@@ -1,18 +1,20 @@
// Changed when traits were introduced. May not make sense any more
open class Base() {
public var v : Int = 0
public var v: Int = 0
}
open class Left() : Base() {}
trait Right : Base {}
open class Left() : Base() {
}
trait Right : Base {
}
class D() : Left(), Right
fun vl(l : Left) : Int = l.v
fun vr(r : Right) : Int = r.v
fun vl(l: Left): Int = l.v
fun vr(r: Right): Int = r.v
fun box() : String {
fun box(): String {
val d = D()
d.v = 42
@@ -1,8 +1,8 @@
fun box(): String {
val cl = 39
return if (sum(200, {val ff = {cl}; ff()}) == 239) "OK" else "FAIL"
return if (sum(200, { val ff = { cl }; ff() }) == 239) "OK" else "FAIL"
}
fun sum(arg: Int, f: ()->Int): Int {
fun sum(arg: Int, f: () -> Int): Int {
return arg + f()
}
@@ -1,8 +1,8 @@
fun box() : String {
fun box(): String {
val cl = 39
return if (sum(200, { val m = { val r = { cl }; r() }; m() }) == 239) "OK" else "FAIL"
}
fun sum(arg:Int, f : () -> Int) : Int {
fun sum(arg: Int, f: () -> Int): Int {
return arg + f()
}
@@ -1,7 +1,7 @@
class Point(val x: Int, val y: Int)
fun box(): String {
val answer = apply(Point(3, 5), { Point.(scalar: Int) : Point ->
val answer = apply(Point(3, 5), { Point.(scalar: Int): Point ->
Point(x * scalar, y * scalar)
})
@@ -1,15 +1,18 @@
open class Base() {
fun n(n : Int) : Int = n + 1
fun n(n: Int): Int = n + 1
}
trait Abstract {}
trait Abstract {
}
class Derived1() : Base(), Abstract {}
class Derived2() : Abstract, Base() {}
class Derived1() : Base(), Abstract {
}
class Derived2() : Abstract, Base() {
}
fun test(s : Base) : Boolean = s.n(238) == 239
fun test(s: Base): Boolean = s.n(238) == 239
fun box() : String {
fun box(): String {
if (!test(Base())) return "Fail #1"
if (!test(Derived1())) return "Fail #2"
if (!test(Derived2())) return "Fail #3"
@@ -1,14 +1,14 @@
class Slot() {
var vitality: Int = 10000
var vitality: Int = 10000
fun increaseVitality(delta: Int) {
vitality = vitality + delta
if (vitality > 65535) vitality = 65535;
}
fun increaseVitality(delta: Int) {
vitality = vitality + delta
if (vitality > 65535) vitality = 65535;
}
}
fun box(): String {
val s = Slot()
s.increaseVitality(1000)
if (s.vitality == 11000) return "OK" else return "fail"
val s = Slot()
s.increaseVitality(1000)
if (s.vitality == 11000) return "OK" else return "fail"
}
@@ -1,13 +1,13 @@
open class Foo() {
fun xyzzy(): String = "xyzzy"
fun xyzzy(): String = "xyzzy"
}
class Bar(): Foo() {
fun test(): String = xyzzy()
class Bar() : Foo() {
fun test(): String = xyzzy()
}
fun box() : String {
val bar = Bar()
val f = bar.test()
return if (f == "xyzzy") "OK" else "fail"
fun box(): String {
val bar = Bar()
val f = bar.test()
return if (f == "xyzzy") "OK" else "fail"
}
@@ -1,13 +1,13 @@
class C() {
public var f: Int
public var f: Int
{
$f = 610
}
{
$f = 610
}
}
fun box(): String {
val c = C()
if (c.f != 610) return "fail"
return "OK"
val c = C()
if (c.f != 610) return "fail"
return "OK"
}
@@ -1,19 +1,27 @@
fun box() : String {
fun box(): String {
val i: Int? = 7
val j: Int? = null
val k = 7
//verify errors
if (i == 7) {}
if (7 == i) {}
if (i == 7) {
}
if (7 == i) {
}
if (j == 7) {}
if (7 == j) {}
if (j == 7) {
}
if (7 == j) {
}
if (i == k) {}
if (k == i) {}
if (i == k) {
}
if (k == i) {
}
if (j == k) {}
if (k == j) {}
if (j == k) {
}
if (k == j) {
}
return "OK"
}
@@ -2,10 +2,10 @@ class SimpleClass() {
fun foo() = 610
}
fun box() : String {
val c = SimpleClass()
if (c.foo() == 610) {
return "OK"
}
return "FAIL"
fun box(): String {
val c = SimpleClass()
if (c.foo() == 610) {
return "OK"
}
return "FAIL"
}
@@ -4,7 +4,7 @@ class ArrayWrapper<T>() {
val contents = ArrayList<T>()
fun add(item: T) {
contents.add(item)
contents.add(item)
}
fun plus(b: ArrayWrapper<T>): ArrayWrapper<T> {
@@ -4,7 +4,7 @@ class ArrayWrapper<T>() {
val contents = ArrayList<T>()
fun add(item: T) {
contents.add(item)
contents.add(item)
}
fun minus(): ArrayWrapper<T> {
@@ -1,21 +1,24 @@
open class Base() {
val plain = 239
public val read : Int
get() = 239
public val read: Int
get() = 239
public var readwrite : Int = 0
get() = $readwrite + 1
set(n : Int) {
$readwrite = n
}
public var readwrite: Int = 0
get() = $readwrite + 1
set(n: Int) {
$readwrite = n
}
}
trait Abstract {}
trait Abstract {
}
class Derived1() : Base(), Abstract {}
class Derived2() : Abstract, Base() {}
class Derived1() : Base(), Abstract {
}
class Derived2() : Abstract, Base() {
}
fun code(s : Base) : Int {
fun code(s: Base): Int {
if (s.plain != 239) return 1
if (s.read != 239) return 2
s.readwrite = 238
@@ -23,9 +26,9 @@ fun code(s : Base) : Int {
return 0
}
fun test(s : Base) : Boolean = code(s) == 0
fun test(s: Base): Boolean = code(s) == 0
fun box() : String {
fun box(): String {
if (!test(Base())) return "Fail #1"
if (!test(Derived1())) return "Fail #2"
if (!test(Derived2())) return "Fail #3"
@@ -1,6 +1,7 @@
// Changed when traits were introduced. May not make sense any more
trait Left {}
trait Left {
}
open class Right() {
open fun f() = 42
}
@@ -9,9 +10,9 @@ class D() : Left, Right() {
override fun f() = 239
}
fun box() : String {
val r : Right = Right()
val d : D = D()
fun box(): String {
val r: Right = Right()
val d: D = D()
if (r.f() != 42) return "Fail #1"
if (d.f() != 239) return "Fail #2"
@@ -1,7 +1,7 @@
fun box() : String {
return invoker( {"OK"} )
fun box(): String {
return invoker({ "OK" })
}
fun invoker(gen : () -> String) : String {
fun invoker(gen: () -> String): String {
return gen()
}
@@ -1,7 +1,7 @@
fun box() : String {
return if (int_invoker( { 7 } ) == 7) "OK" else "fail"
fun box(): String {
return if (int_invoker({ 7 }) == 7) "OK" else "fail"
}
fun int_invoker(gen : () -> Int) : Int {
fun int_invoker(gen: () -> Int): Int {
return gen()
}
@@ -1,16 +1,16 @@
import java.util.ArrayList
trait Tr {
fun extra() : String = "_"
fun extra(): String = "_"
}
class N() : ArrayList<Any>(), Tr {
override fun add(el: Any) : Boolean {
override fun add(el: Any): Boolean {
super<ArrayList>.add(el)
return super<ArrayList>.add(el.toString() + super<Tr>.extra() + el + extra())
}
override fun extra() : String = super<Tr>.extra() + super<Tr>.extra()
override fun extra(): String = super<Tr>.extra() + super<Tr>.extra()
}
fun box(): String {
@@ -3,14 +3,14 @@ open class M() {
}
class N() : M() {
val a : Int
val a: Int
get() {
super.b = super.b + 1
return super.b + 1
}
override var b: Int = a + 1
val superb : Int
val superb: Int
get() = super.b
}
@@ -1,11 +1,11 @@
class C() {
class object {
fun create() = C()
}
class object {
fun create() = C()
}
}
fun box(): String {
val c = C.create()
return if (c is C) "OK" else "fail"
val c = C.create()
return if (c is C) "OK" else "fail"
}
@@ -1,9 +1,10 @@
class C() {
fun getInstance(): Runnable = C
fun getInstance(): Runnable = C
class object: Runnable {
override fun run(): Unit { }
}
class object: Runnable {
override fun run(): Unit {
}
}
}
fun foo() = C().getInstance()
@@ -1,13 +1,13 @@
abstract open class Default {
abstract fun defaultValue(): Int
abstract fun defaultValue(): Int
}
class MyInt() {
class object : Default {
override fun defaultValue(): Int = 610
}
class object : Default {
override fun defaultValue(): Int = 610
}
}
fun toDefault<T: Any>(t: T) where class object T: Default = T.defaultValue()
fun toDefault<T : Any>(t: T) where class object T : Default = T.defaultValue()
fun box(): String = if (toDefault<MyInt>(MyInt()) == 610) "OK" else "fail"
@@ -1,20 +1,20 @@
trait BK {
fun x() : Int = 50
fun x(): Int = 50
}
trait K : BK {
override fun x() : Int = super.x() * 2
override fun x(): Int = super.x() * 2
}
open class M() {
open fun x() : Int = 10
open fun x(): Int = 10
open var y = 500
}
open class N() : M(), K {
override fun x() : Int = 20
override fun x(): Int = 20
override var y = 200
@@ -24,7 +24,7 @@ open class N() : M(), K {
fun test3() = super<K>@N.x()
fun test4() = super<K>.x()
fun test5() = y
fun test6() : Int {
fun test6(): Int {
super<M>@N.y += 200
return super<M>@N.y
}
@@ -33,7 +33,7 @@ open class N() : M(), K {
fun box(): String {
if (N().C().test1() != 100) return "test1 fail";
if (N().C().test2() != 10) return "test2 fail";
if (N().C().test2() != 10) return "test2 fail";
if (N().C().test3() != 100) return "test3 fail";
if (N().C().test4() != 100) return "test4 fail";
if (N().C().test5() != 200) return "test5 fail";
@@ -1,12 +1,14 @@
class Foo() { }
class Bar() { }
class Foo() {
}
class Bar() {
}
fun isInstance<T>(obj: Any?) = obj is T
fun isInstance2<T>(obj: Any?) = isInstance<T>(obj)
fun box(): String {
if (! isInstance2<Foo>(Foo())) return "fail 1"
if (isInstance2<Bar>(Foo())) return "fail 2"
return "OK"
if (!isInstance2<Foo>(Foo())) return "fail 1"
if (isInstance2<Bar>(Foo())) return "fail 2"
return "OK"
}
@@ -1,24 +1,31 @@
// Changed when traits were introduced. May not make sense any more
open class X(val x : Int) {}
open class X(val x: Int) {
}
trait Y {
abstract val y : Int
abstract val y: Int
}
class YImpl(override val y : Int) : Y {}
class Point(x : Int, yy : Int) : X(x) , Y {
override val y : Int = yy
class YImpl(override val y: Int) : Y {
}
trait Abstract {}
class Point(x: Int, yy: Int) : X(x), Y {
override val y: Int = yy
}
class P1(x : Int, yy : Y) : Abstract, X(x), Y by yy {}
class P2(x : Int, yy : Y) : X(x), Abstract, Y by yy {}
class P3(x : Int, yy : Y) : X(x), Y by yy, Abstract {}
class P4(x : Int, yy : Y) : Y by yy, Abstract, X(x) {}
trait Abstract {
}
fun box() : String {
class P1(x: Int, yy: Y) : Abstract, X(x), Y by yy {
}
class P2(x: Int, yy: Y) : X(x), Abstract, Y by yy {
}
class P3(x: Int, yy: Y) : X(x), Y by yy, Abstract {
}
class P4(x: Int, yy: Y) : Y by yy, Abstract, X(x) {
}
fun box(): String {
if (X(239).x != 239) return "FAIL #1"
if (YImpl(239).y != 239) return "FAIL #2"
@@ -1,14 +1,14 @@
class Outer() {
open class InnerBase() {
}
open class InnerBase() {
}
class InnerDerived(): InnerBase() {
}
class InnerDerived() : InnerBase() {
}
public val foo: InnerBase? = InnerDerived()
public val foo: InnerBase? = InnerDerived()
}
fun box() : String {
val o = Outer()
return if (o.foo === null) "fail" else "OK"
fun box(): String {
val o = Outer()
return if (o.foo === null) "fail" else "OK"
}
@@ -2,19 +2,19 @@ import java.util.*
import java.io.*
class World() {
public val items: ArrayList<Item> = ArrayList<Item>
public val items: ArrayList<Item> = ArrayList<Item>
class Item() {
{
items.add(this)
class Item() {
{
items.add(this)
}
}
}
val foo = Item()
val foo = Item()
}
fun box() : String {
val w = World()
if (w.items.size() != 1) return "fail"
return "OK"
fun box(): String {
val w = World()
if (w.items.size() != 1) return "fail"
return "OK"
}
@@ -1,19 +1,19 @@
class Outer(val foo: StringBuilder) {
class Inner() {
fun len() : Int {
return foo.length()
class Inner() {
fun len(): Int {
return foo.length()
}
}
}
fun test() : Inner {
return Inner()
}
fun test(): Inner {
return Inner()
}
}
fun box() : String {
val sb = StringBuilder("xyzzy")
val o = Outer(sb)
val i = o.test()
val l = i.len()
return if (l != 5) "fail" else "OK"
fun box(): String {
val sb = StringBuilder("xyzzy")
val o = Outer(sb)
val i = o.test()
val l = i.len()
return if (l != 5) "fail" else "OK"
}
@@ -1,16 +1,16 @@
class Outer() {
val s = "xyzzy"
val s = "xyzzy"
open class InnerBase(public val name: String) {
}
open class InnerBase(public val name: String) {
}
class InnerDerived(): InnerBase(s) {
}
class InnerDerived() : InnerBase(s) {
}
val x = InnerDerived()
val x = InnerDerived()
}
fun box() : String {
val o = Outer()
return if (o.x.name != "xyzzy") "fail" else "OK"
fun box(): String {
val o = Outer()
return if (o.x.name != "xyzzy") "fail" else "OK"
}
@@ -1,6 +1,6 @@
trait M {
var backingB : Int
var b : Int
var backingB: Int
var b: Int
get() = backingB
set(value: Int) {
backingB = value
@@ -8,16 +8,16 @@ trait M {
}
class N() : M {
override var backingB : Int = 0
override var backingB: Int = 0
val a : Int
val a: Int
get() {
super.b = super.b + 1
return super.b + 1
}
override var b: Int = a + 1
val superb : Int
val superb: Int
get() = super.b
}
@@ -1,7 +1,7 @@
class GameError(msg: String): Exception(msg) {
class GameError(msg: String) : Exception(msg) {
}
fun box(): String {
val e = GameError("foo")
return if (e.getMessage() == "foo") "OK" else "fail"
val e = GameError("foo")
return if (e.getMessage() == "foo") "OK" else "fail"
}
@@ -5,10 +5,10 @@ class A
fun checkCastNullableToNotNull(): Boolean {
val a = null
try {
val s = a as A
val s = a as A
}
catch (e : Exception) {
return true
catch (e: Exception) {
return true
}
return false
}
@@ -7,7 +7,7 @@ fun box(): String {
val s = a as A?
if (s != null) return "Failed when try cast Nullable with null value to Nullable"
val b : A? = A()
val b: A? = A()
val n = b as A?
if (n != b) return "Failed when try cast Nullable with not null value to Nullable"
@@ -10,10 +10,10 @@ class Foo(val name: String) {
}
fun callEqualsMethod(v1: Foo?, v2: Foo?): Boolean {
return v1 == v2
return v1 == v2
}
fun box() : Boolean {
fun box(): Boolean {
val a = Foo("abc")
val b = Foo("abc")
val c = Foo("def")
@@ -10,10 +10,10 @@ class Foo(val name: String) {
}
fun callEqualsMethod(v1: Any?, v2: Any?): Boolean {
return v1 == v2
return v1 == v2
}
fun box() : Boolean {
fun box(): Boolean {
val a = Foo("abc")
val b = Foo("abc")
val c = Foo("def")
@@ -2,24 +2,24 @@ package foo
native val undefined: Any = noImpl
fun box() : String {
fun box(): String {
val a: Int? = null
val r = a == null
if (!r || a != null)
return "wrong result on simple nullable check"
return "wrong result on simple nullable check"
//force using Kotlin.equals
val t = null
if (t != undefined)
return "wrong result when compare null and undefined using Kotlin.equals"
return "wrong result when compare null and undefined using Kotlin.equals"
var i = 0;
fun foo(): Int? = ++i;
if (foo() == null)
return "wrong result on nullable check with side effects"
return "wrong result on nullable check with side effects"
if (i != 1)
return "wrong affects when using nullable check with side effects"
return "wrong affects when using nullable check with side effects"
return "OK"
}
@@ -13,7 +13,7 @@ class Bar() {
}
fun box() : Boolean {
fun box(): Boolean {
val a = Foo("abc")
val b = Foo("abc")
val c = Foo("def")
@@ -1,21 +1,21 @@
package foo
fun box() : Boolean {
val a = 2
if (!(a equals a)) return false
if (!(a equals 2)) return false
if (!(a equals 2.0)) return false
val c = "a"
if (!("a" equals c)) return false
if (!(null equals null)) return false
val d = 5.6
if (!(d.toShort() equals 5.toShort())) return false
if (!(d.toByte() equals 5.toByte())) return false
if (!(d.toFloat() equals 5.6.toFloat())) return false
if (!(d.toInt() equals 5)) return false
if (true equals false) return false
fun box(): Boolean {
val a = 2
if (!(a equals a)) return false
if (!(a equals 2)) return false
if (!(a equals 2.0)) return false
val c = "a"
if (!("a" equals c)) return false
if (!(null equals null)) return false
val d = 5.6
if (!(d.toShort() equals 5.toShort())) return false
if (!(d.toByte() equals 5.toByte())) return false
if (!(d.toFloat() equals 5.6.toFloat())) return false
if (!(d.toInt() equals 5)) return false
if (true equals false) return false
val n: Number = 3
if (!(n equals 3.3.toInt())) return false
return true
val n: Number = 3
if (!(n equals 3.3.toInt())) return false
return true
}
@@ -1,6 +1,7 @@
package foo
import java.util.*
fun box(): Boolean {
val data = ArrayList<String>()
data.add("foo")
@@ -1,6 +1,6 @@
package foo
fun box() : Boolean {
fun box(): Boolean {
val a = "abc"
val b = "abc"
val c = "def"
@@ -2,16 +2,17 @@ package foo
val a1 = arrayOfNulls<Int>(10)
fun box() : Boolean {
fun box(): Boolean {
var c = 0
var d = 0
a1[3] = 3
a1[5] = 5
for (a : Int? in a1) {
for (a: Int? in a1) {
if (a != null) {
c += 1;
} else {
}
else {
d += 1
}
}
@@ -2,7 +2,7 @@ package foo
val a1 = arrayOfNulls<Int>(0)
fun box() : Boolean {
fun box(): Boolean {
for (a in a1) {
return false;
}
@@ -1,33 +1,28 @@
import java.util.*
class Lifetime() {
val attached = ArrayList< Function0<Unit> >()
val attached = ArrayList<Function0<Unit>>()
public fun attach(action : ()->Unit)
{
attached.add(action)
}
public fun attach(action: () -> Unit) {
attached.add(action)
}
fun close()
{
for(x in attached) x()
attached.clear()
}
fun close() {
for (x in attached) x()
attached.clear()
}
}
public class Viewable<T>()
{
val items = ArrayList<T>()
public class Viewable<T>() {
val items = ArrayList<T>()
fun add(item:T)
{
items.add(item)
}
fun add(item: T) {
items.add(item)
}
fun remove(item:T)
{
items.remove(item)
}
fun remove(item: T) {
items.remove(item)
}
fun view(lifetime: Lifetime, viewer: (itemLifetime: Lifetime, item: T) -> Unit) {
for (item in items) {
@@ -36,14 +31,14 @@ public class Viewable<T>()
}
}
fun lifetime(body: (Lifetime)->Unit) {
fun lifetime(body: (Lifetime) -> Unit) {
val l = Lifetime()
body(l)
l.close()
}
fun<T> Dump(items: ArrayList<T>) {
for(item in items) {
for (item in items) {
print(item.toString() + ", ")
}
println("end")
@@ -56,7 +51,7 @@ fun main(args: Array<String>) {
v.add(2)
v.add(3)
lifetime() {
v.view(it) {itemLifetime, item ->
v.view(it) { itemLifetime, item ->
x.add(item)
Dump(x)
itemLifetime.attach() {
@@ -2,7 +2,7 @@ package foo
fun box(): Boolean {
var sum = 0
val adder = {(a: Int) -> sum += a}
val adder = {(a: Int) -> sum += a }
adder(3)
adder(2)
return sum == 5
@@ -1,9 +1,9 @@
package foo
fun box() : String {
return apply( "OK", {(arg: String) -> arg } )
fun box(): String {
return apply("OK", {(arg: String) -> arg })
}
fun apply(arg : String, f : (p:String) -> String) : String {
fun apply(arg: String, f: (p: String) -> String): String {
return f(arg)
}
@@ -1,9 +1,9 @@
package foo
fun box() : String {
return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail"
fun box(): String {
return if (apply(5, {(arg: Int) -> arg + 13 }) == 18) "OK" else "fail"
}
fun apply(arg : Int, f : (p:Int) -> Int) : Int {
fun apply(arg: Int, f: (p: Int) -> Int): Int {
return f(arg)
}
@@ -1,11 +1,10 @@
package foo
fun f(a : Int = 2, b : Int = 3) = a + b
fun f(a: Int = 2, b: Int = 3) = a + b
fun box() : Boolean
{
if (f(1,2) != 3) return false;
if (f(1,3) != 4) return false;
fun box(): Boolean {
if (f(1, 2) != 3) return false;
if (f(1, 3) != 4) return false;
if (f(3) != 6) return false;
if (f() != 5) return false;
@@ -1,8 +1,8 @@
package foo
class Point(val x: Int, val y: Int) {
fun mul(): (scalar: Int)->Point {
return { (scalar: Int):Point -> Point(x * scalar, y * scalar) }
fun mul(): (scalar: Int) -> Point {
return {(scalar: Int): Point -> Point(x * scalar, y * scalar) }
}
}
@@ -2,41 +2,41 @@ package foo
import java.util.*;
val d = {(a : Int) -> a + 1}
val p = {(a : Int) -> a * 3}
val d = {(a: Int) -> a + 1 }
val p = {(a: Int) -> a * 3 }
val list = ArrayList<Function1<Int, Int>>();
fun chain(start : Int) : Int {
var res = start;
for (func in list) {
res = (func)(res);
}
return res;
fun chain(start: Int): Int {
var res = start;
for (func in list) {
res = (func)(res);
}
return res;
}
fun box() : Boolean {
if (chain(0) != 0) {
return false;
}
list.add(d);
if (list.get(0)(0) != 1) {
return false;
}
list.add(p);
if (list.get(1)(10) != 30) {
return false;
}
if (chain(0) != 3) {
return false;
}
list.add({it * it});
list.add({it - 100});
if (chain(2) != -19) {
return false;
}
if (({(a : Int) -> a * a}(3)) != 9) {
return false;
}
return true;
fun box(): Boolean {
if (chain(0) != 0) {
return false;
}
list.add(d);
if (list.get(0)(0) != 1) {
return false;
}
list.add(p);
if (list.get(1)(10) != 30) {
return false;
}
if (chain(0) != 3) {
return false;
}
list.add({ it * it });
list.add({ it - 100 });
if (chain(2) != -19) {
return false;
}
if (({(a: Int) -> a * a }(3)) != 9) {
return false;
}
return true;
}
@@ -1,16 +1,16 @@
package foo
fun box() : Boolean{
fun box(): Boolean {
fun f() = 3
return (((f() + f()) == 6) && (b() == 24))
}
fun b() : Int {
fun b(): Int {
fun a() : Int {
fun a(): Int {
fun c() = 4
return c() * 3
}
@@ -1,8 +1,8 @@
package foo
fun box() : Boolean {
var sum = 0
val addFive = {(a: Int) -> a + 5 }
sum = addFive(sum)
return sum == 5
fun box(): Boolean {
var sum = 0
val addFive = {(a: Int) -> a + 5 }
sum = addFive(sum)
return sum == 5
}
@@ -8,7 +8,7 @@ fun box(): Boolean {
it + 2
} != 3) return false
if (f() {(a: Int) -> a * 300} != 300) return false;
if (f() {(a: Int) -> a * 300 } != 300) return false;
return true
}
@@ -1,10 +1,10 @@
package foo
fun apply(f : (Int) -> Int, t : Int) : Int {
fun apply(f: (Int) -> Int, t: Int): Int {
return f(t)
}
fun box() : Boolean {
return apply({(a: Int) -> a + 5 }, 3) == 8
fun box(): Boolean {
return apply({(a: Int) -> a + 5 }, 3) == 8
}
@@ -1,13 +1,12 @@
package foo
fun box() : Boolean
{
fun box(): Boolean {
return f()
}
fun f() : Boolean {
return true
fun f(): Boolean {
return true
}
@@ -1,9 +1,9 @@
package foo
fun sum(param1 : Int, param2 : Int) : Int {
fun sum(param1: Int, param2: Int): Int {
return param1 + param2;
}
fun box() : Boolean {
fun box(): Boolean {
return (sum(1, 5) == 6)
}
@@ -1,12 +1,12 @@
package foo
fun test(f : (Int) -> Boolean, p : Int) = f(p)
fun test(f: (Int) -> Boolean, p: Int) = f(p)
fun box() : Boolean {
if (!test({it + 1 == 2}, 1)) return false;
fun box(): Boolean {
if (!test({ it + 1 == 2 }, 1)) return false;
if (!test({it > 1}, 3)) return false;
if (!test({ it > 1 }, 3)) return false;
return (test({((it < 1) == false)}, 1))
return (test({ ((it < 1) == false) }, 1))
}
@@ -1,96 +1,138 @@
package foo
public fun public_baz(i: Int) {}
native public fun public_baz(a: String) {}
public fun public_baz(i: Int) {
}
native public fun public_baz(a: String) {
}
fun internal_baz(i: Int) {}
native fun internal_baz(a: String) {}
fun internal_baz(i: Int) {
}
native fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {}
native private fun private_baz(a: String) {}
private fun private_baz(i: Int) {
}
native private fun private_baz(a: String) {
}
public class PublicClass {
public fun public_baz(i: Int) {}
native public fun public_baz(a: String) {}
public fun public_baz(i: Int) {
}
native public fun public_baz(a: String) {
}
fun internal_baz(i: Int) {}
native fun internal_baz(a: String) {}
fun internal_baz(i: Int) {
}
native fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {}
native private fun private_baz(a: String) {}
private fun private_baz(i: Int) {
}
native private fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0)}
val call_private_native_baz = { private_baz("native")}
val call_private_baz = { private_baz(0) }
val call_private_native_baz = { private_baz("native") }
}
class InternalClass {
public fun public_baz(i: Int) {}
native public fun public_baz(a: String) {}
public fun public_baz(i: Int) {
}
native public fun public_baz(a: String) {
}
fun internal_baz(i: Int) {}
native fun internal_baz(a: String) {}
fun internal_baz(i: Int) {
}
native fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {}
native private fun private_baz(a: String) {}
private fun private_baz(i: Int) {
}
native private fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0)}
val call_private_native_baz = { private_baz("native")}
val call_private_baz = { private_baz(0) }
val call_private_native_baz = { private_baz("native") }
}
private class PrivateClass {
public fun public_baz(i: Int) {}
native public fun public_baz(a: String) {}
public fun public_baz(i: Int) {
}
native public fun public_baz(a: String) {
}
fun internal_baz(i: Int) {}
native fun internal_baz(a: String) {}
fun internal_baz(i: Int) {
}
native fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {}
native private fun private_baz(a: String) {}
private fun private_baz(i: Int) {
}
native private fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0)}
val call_private_native_baz = { private_baz("native")}
val call_private_baz = { private_baz(0) }
val call_private_native_baz = { private_baz("native") }
}
open public class OpenPublicClass {
public fun public_baz(i: Int) {}
native public fun public_baz(a: String) {}
public fun public_baz(i: Int) {
}
native public fun public_baz(a: String) {
}
fun internal_baz(i: Int) {}
native fun internal_baz(a: String) {}
fun internal_baz(i: Int) {
}
native fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {}
native private fun private_baz(a: String) {}
private fun private_baz(i: Int) {
}
native private fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0)}
val call_private_native_baz = { private_baz("native")}
val call_private_baz = { private_baz(0) }
val call_private_native_baz = { private_baz("native") }
}
open class OpenInternalClass {
public fun public_baz(i: Int) {}
native public fun public_baz(a: String) {}
public fun public_baz(i: Int) {
}
native public fun public_baz(a: String) {
}
fun internal_baz(i: Int) {}
native fun internal_baz(a: String) {}
fun internal_baz(i: Int) {
}
native fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {}
native private fun private_baz(a: String) {}
private fun private_baz(i: Int) {
}
native private fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0)}
val call_private_native_baz = { private_baz("native")}
val call_private_baz = { private_baz(0) }
val call_private_native_baz = { private_baz("native") }
}
open private class OpenPrivateClass {
public fun public_baz(i: Int) {}
native public fun public_baz(a: String) {}
public fun public_baz(i: Int) {
}
native public fun public_baz(a: String) {
}
fun internal_baz(i: Int) {}
native fun internal_baz(a: String) {}
fun internal_baz(i: Int) {
}
native fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {}
native private fun private_baz(a: String) {}
private fun private_baz(i: Int) {
}
native private fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0)}
val call_private_native_baz = { private_baz("native")}
val call_private_baz = { private_baz(0) }
val call_private_native_baz = { private_baz("native") }
}
// Helpers
@@ -119,7 +161,7 @@ fun Function0<Unit>.extractNames(): Array<String> {
var testGroup = ""
fun test(expected: String, f: ()->Unit){
fun test(expected: String, f: () -> Unit) {
val actual = f.extractNames()
if (expected != actual[1]) {
@@ -127,7 +169,8 @@ fun test(expected: String, f: ()->Unit){
}
}
public fun stable_mangled_baz(i: Int) {}
public fun stable_mangled_baz(i: Int) {
}
val SIMPLE = "baz"
val SIMPLE1 = "${SIMPLE}_1"
@@ -136,12 +179,12 @@ val STABLE = { stable_mangled_baz(0) }.extractNames()[1]
fun box(): String {
testGroup = "Top Level"
test(STABLE) { public_baz(0) }
test(NATIVE) { public_baz("native") }
test(STABLE) { public_baz(0) }
test(NATIVE) { public_baz("native") }
test(SIMPLE1) { internal_baz(0) }
test(NATIVE) { internal_baz("native") }
test(NATIVE) { internal_baz("native") }
test(SIMPLE1) { private_baz(0) }
test(NATIVE) { private_baz("native") }
test(NATIVE) { private_baz("native") }
testGroup = "Public Class"
test(STABLE) { PublicClass().public_baz(0) }

Some files were not shown because too many files have changed in this diff Show More