unit test introduced:

User should create <test-name>-test.c file in the following manner:
> cat codegen/function/sum-test.c
extern void *resolve_symbol(const char*);

int
run_test() {
  int (*sum)(int, int) = resolve_symbol("kfun:sum");

  if (sum(2, 3) != 5) return 1;

  return 0;
}
and add <test-name> to the TESTS variable in the Makefile
to run tests:
> make clean run
Note: failing tests should return no zero values.
This commit is contained in:
Vasily Levchenko
2016-10-09 20:59:58 +03:00
parent dbdbc9a844
commit 4c32689e1f
6 changed files with 72 additions and 0 deletions
@@ -0,0 +1,10 @@
extern void *resolve_symbol(const char*);
int
run_test() {
int (*sum)(int, int) = resolve_symbol("kfun:sum");
if (sum(2, 3) != 5) return 1;
return 0;
}
@@ -0,0 +1 @@
fun sum(a:Int, b:Int) = a + b
@@ -0,0 +1,3 @@
fun foo():Int = 1
//fun bar():Int = 2
//fun sum():Int = foo() + bar()
@@ -0,0 +1,5 @@
fun sum(a:Int, b:Int):Int {
var c:Int
c = a + b
return c
}