Test for getters/setters added
This commit is contained in:
committed by
vvlevchenko
parent
f393dc3a03
commit
f80697817e
@@ -142,6 +142,14 @@ task sum (type:UnitKonanTest) {
|
|||||||
source = "codegen/function/sum.kt"
|
source = "codegen/function/sum.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task method_call(type: UnitKonanTest) {
|
||||||
|
source = "codegen/object/method_call.kt"
|
||||||
|
}
|
||||||
|
|
||||||
|
task fields(type: UnitKonanTest) {
|
||||||
|
source = "codegen/object/fields.kt"
|
||||||
|
}
|
||||||
|
|
||||||
/*task objectInitialization(type: UnitKonanTest) {
|
/*task objectInitialization(type: UnitKonanTest) {
|
||||||
source = "codegen/object/initialization.kt"
|
source = "codegen/object/initialization.kt"
|
||||||
}*/
|
}*/
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
extern void *resolve_symbol(const char*);
|
||||||
|
|
||||||
|
int
|
||||||
|
run_test() {
|
||||||
|
int (*globalTest)() = resolve_symbol("kfun:globalTest(Int)");
|
||||||
|
int (*getGlobal)() = resolve_symbol("kfun:<get-globalValue>()");
|
||||||
|
|
||||||
|
if (getGlobal() != 1) return 1;
|
||||||
|
if (globalTest(41) != 42) return 1;
|
||||||
|
if (getGlobal() != 42) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
class fields(a:Int) {
|
private var globalValue = 1
|
||||||
public val b:Int
|
var global:Int
|
||||||
get() = getB()
|
get() = globalValue
|
||||||
|
set(value:Int) {globalValue = value}
|
||||||
|
|
||||||
external fun getB():Int
|
fun globalTest(i:Int):Int {
|
||||||
|
global += i
|
||||||
|
return global
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
extern void *resolve_symbol(const char*);
|
||||||
|
|
||||||
|
int
|
||||||
|
run_test() {
|
||||||
|
int (*fortyTwo)() = resolve_symbol("kfun:fortyTwo()");
|
||||||
|
|
||||||
|
if (fortyTwo() != 42) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class A(val a:Int) {
|
||||||
|
fun foo(i:Int) = a + i
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fortyTwo() = A(41).foo(1)
|
||||||
Reference in New Issue
Block a user