diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index c883e1e2dba..21924a72ced 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -172,12 +172,13 @@ task hello1(type: RunKonanTest) { source = "runtime/basic/hello1.kt" } -/* TODO: enable, once calling plus operator is implemented. +/* task hello2(type: RunKonanTest) { - goldValue = "Hello World" + goldValue = "you entered 'Hello World'" testData = "Hello World" source = "runtime/basic/hello2.kt" -} */ +} +*/ /* TODO: enable, once can call toString() on Int. task hello3(type: RunKonanTest) { diff --git a/backend.native/tests/codegen/function/eqeq-test.c b/backend.native/tests/codegen/function/eqeq-test.c new file mode 100644 index 00000000000..0365823c3ce --- /dev/null +++ b/backend.native/tests/codegen/function/eqeq-test.c @@ -0,0 +1,20 @@ +#include +extern void *resolve_symbol(const char*); + +int +run_test() { + int (*eqeqB)(uint8_t, uint8_t) = resolve_symbol("kfun:eqeqB"); + int (*eqeqS)(int16_t, int16_t) = resolve_symbol("kfun:eqeqS"); + int (*eqeqI)(int , int ) = resolve_symbol("kfun:eqeqI"); + int (*eqeqL)(int64_t, int64_t) = resolve_symbol("kfun:eqeqL"); + int (*eqeqF)(float , float ) = resolve_symbol("kfun:eqeqF"); + int (*eqeqD)(double , double ) = resolve_symbol("kfun:eqeqD"); + if (!eqeqB(3 , 3 )) return 1; + if (!eqeqS(3 , 3 )) return 1; + if (!eqeqI(3 , 3 )) return 1; + if (!eqeqL(3ll , 3ll )) return 1; + if (!eqeqF(3.0f, 3.0f)) return 1; + if (!eqeqD(3.0 , 3.0 )) return 1; + + return 0; +} diff --git a/backend.native/tests/codegen/function/eqeq.kt b/backend.native/tests/codegen/function/eqeq.kt new file mode 100644 index 00000000000..cc80c896970 --- /dev/null +++ b/backend.native/tests/codegen/function/eqeq.kt @@ -0,0 +1,8 @@ +fun eqeqB(a:Byte, b:Byte ) = a == b +fun eqeqS(a:Short, b:Short ) = a == b +fun eqeqI(a:Int, b:Int ) = a == b +fun eqeqL(a:Long, b:Long ) = a == b +fun eqeqF(a:Float, b:Float ) = a == b +fun eqeqD(a:Double, b:Double) = a == b + +//fun eqeqStr(a:String, b:String) = a == b diff --git a/backend.native/tests/codegen/function/sum-test.c b/backend.native/tests/codegen/function/sum-test.c index 2658fe58131..d378419609f 100644 --- a/backend.native/tests/codegen/function/sum-test.c +++ b/backend.native/tests/codegen/function/sum-test.c @@ -1,10 +1,22 @@ +#include extern void *resolve_symbol(const char*); int run_test() { - int (*sum)(int, int) = resolve_symbol("kfun:sum"); - - if (sum(2, 3) != 5) return 1; + int (*sumIB)(int, uint8_t) = resolve_symbol("kfun:sumIB"); + int (*sumIS)(int, int16_t) = resolve_symbol("kfun:sumIS"); + int (*sumII)(int, int ) = resolve_symbol("kfun:sumII"); + int64_t (*sumIL)(int, int64_t) = resolve_symbol("kfun:sumIL"); + float (*sumIF)(int, float ) = resolve_symbol("kfun:sumIF"); + double (*sumID)(int, double ) = resolve_symbol("kfun:sumID"); + double (*modID)(int, double ) = resolve_symbol("kfun:modID"); + if (sumIB(2, 3) != 5) return 1; + if (sumIS(2, 3) != 5) return 1; + if (sumII(2, 3) != 5) return 1; + if (sumIL(2, 3l) != 5l) return 1; + if (sumIF(2, 3.0f) != 5.0f) return 1; + if (sumID(2, 3.0) != 5.0) return 1; + if (modID(5, 3.0) != 2.0) return 1; return 0; } diff --git a/backend.native/tests/codegen/function/sum.kt b/backend.native/tests/codegen/function/sum.kt index 38215fdce2d..ee578b707a0 100644 --- a/backend.native/tests/codegen/function/sum.kt +++ b/backend.native/tests/codegen/function/sum.kt @@ -1 +1,8 @@ -fun sum(a:Int, b:Int) = a + b \ No newline at end of file +fun sumIB(a:Int, b:Byte ) = a + b +fun sumIS(a:Int, b:Short ) = a + b +fun sumII(a:Int, b:Int ) = a + b +fun sumIL(a:Int, b:Long ) = a + b +fun sumIF(a:Int, b:Float ) = a + b +fun sumID(a:Int, b:Double) = a + b + +fun modID(a:Int, b:Double) = a % b \ No newline at end of file diff --git a/backend.native/tests/codegen/function/sum_mixed.kt b/backend.native/tests/codegen/function/sum_mixed.kt new file mode 100644 index 00000000000..66d23047854 --- /dev/null +++ b/backend.native/tests/codegen/function/sum_mixed.kt @@ -0,0 +1 @@ +fun sum(a:Float, b:Int) = a + b \ No newline at end of file