diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 48ce6bb6f89..b03465588cc 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -88,4 +88,17 @@ task aritmetic(type: KonanTest) { task sum1(type: KonanTest) { source = "codegen/function/sum_foo_bar.kt" -} \ No newline at end of file +} + +task sum2(type: KonanTest) { + source = "codegen/function/sum_imm.kt" +} + +task sum_3const(type: KonanTest) { + source = "codegen/function/sum_3const.kt" +} + +// TODO: waiting for boolean to be implemented +//task bool_yes(type: KonanTest) { +// source = "codegen/function/boolean.kt" +//} \ No newline at end of file diff --git a/backend.native/tests/codegen/function/boolean-test.c b/backend.native/tests/codegen/function/boolean-test.c new file mode 100644 index 00000000000..016ee5c4a2b --- /dev/null +++ b/backend.native/tests/codegen/function/boolean-test.c @@ -0,0 +1,10 @@ +extern void *resolve_symbol(const char*); + +int +run_test() { + int (*bool_yes)() = resolve_symbol("kfun:bool_yes"); + + if (!bool_yes()) return 1; + + return 0; +} diff --git a/backend.native/tests/codegen/function/boolean.kt b/backend.native/tests/codegen/function/boolean.kt new file mode 100644 index 00000000000..846979d9f28 --- /dev/null +++ b/backend.native/tests/codegen/function/boolean.kt @@ -0,0 +1 @@ +fun bool_yes(): Boolean = true diff --git a/backend.native/tests/codegen/function/sum_3const-test.c b/backend.native/tests/codegen/function/sum_3const-test.c new file mode 100644 index 00000000000..f547dc8ca55 --- /dev/null +++ b/backend.native/tests/codegen/function/sum_3const-test.c @@ -0,0 +1,10 @@ +extern void *resolve_symbol(const char*); + +int +run_test() { + int (*sum3)() = resolve_symbol("kfun:sum3"); + + if (sum3() != 36) return 1; + + return 0; +} diff --git a/backend.native/tests/codegen/function/sum_3const.kt b/backend.native/tests/codegen/function/sum_3const.kt new file mode 100644 index 00000000000..a9815b61f6b --- /dev/null +++ b/backend.native/tests/codegen/function/sum_3const.kt @@ -0,0 +1,2 @@ +fun sum3():Int = sum(1, 2, 33) +fun sum(a:Int, b:Int, c:Int): Int = a + b + c diff --git a/backend.native/tests/codegen/function/sum_imm-test.c b/backend.native/tests/codegen/function/sum_imm-test.c new file mode 100644 index 00000000000..0b65df8f1ec --- /dev/null +++ b/backend.native/tests/codegen/function/sum_imm-test.c @@ -0,0 +1,10 @@ +extern void *resolve_symbol(const char*); + +int +run_test() { + int (*sum)(int) = resolve_symbol("kfun:sum"); + + if (sum(2) != 35) return 1; + + return 0; +} diff --git a/backend.native/tests/codegen/function/sum_imm.kt b/backend.native/tests/codegen/function/sum_imm.kt new file mode 100644 index 00000000000..35aa434b854 --- /dev/null +++ b/backend.native/tests/codegen/function/sum_imm.kt @@ -0,0 +1 @@ +fun sum(a:Int): Int = a + 33 \ No newline at end of file