From 97e31820aeaaee57f7d7084ec27d87b500de5c88 Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Mon, 10 Oct 2016 23:13:28 +0300 Subject: [PATCH] inter-procedural call test --- backend.native/tests/Makefile | 3 ++- .../tests/codegen/function/sum_foo_bar-test.c | 10 ++++++++++ backend.native/tests/codegen/function/sum_foo_bar.kt | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 backend.native/tests/codegen/function/sum_foo_bar-test.c create mode 100644 backend.native/tests/codegen/function/sum_foo_bar.kt diff --git a/backend.native/tests/Makefile b/backend.native/tests/Makefile index 33df8c2c53f..eeb38de1d92 100644 --- a/backend.native/tests/Makefile +++ b/backend.native/tests/Makefile @@ -1,4 +1,5 @@ -TESTS := sum +TESTS := sum \ + sum_foo_bar BIN_TESTS=$(foreach t, ${TESTS},${t}_test) diff --git a/backend.native/tests/codegen/function/sum_foo_bar-test.c b/backend.native/tests/codegen/function/sum_foo_bar-test.c new file mode 100644 index 00000000000..325c26b35fb --- /dev/null +++ b/backend.native/tests/codegen/function/sum_foo_bar-test.c @@ -0,0 +1,10 @@ +extern void *resolve_symbol(const char*); + +int +run_test() { + int (*sum)(int, int) = resolve_symbol("kfun:sumFooBar"); + + if (sum(2, 3) != 5) return 1; + + return 0; +} diff --git a/backend.native/tests/codegen/function/sum_foo_bar.kt b/backend.native/tests/codegen/function/sum_foo_bar.kt new file mode 100644 index 00000000000..ce1a0929736 --- /dev/null +++ b/backend.native/tests/codegen/function/sum_foo_bar.kt @@ -0,0 +1,4 @@ +fun foo(a:Int):Int = a +fun bar(a:Int):Int = a + +fun sumFooBar(a:Int, b:Int):Int = foo(a) + bar(b) \ No newline at end of file