Test cases

- Added two new checks for checking the return type of a function and matching a `ReturnStmt`'s expression's type to it
This commit is contained in:
Tristan B. Velloza Kildaire 2023-07-12 11:02:56 +02:00
parent 0a4cec2013
commit dd66d2e47e
3 changed files with 25 additions and 0 deletions

View File

@ -355,6 +355,19 @@ jobs:
else
exit 1
fi
- name: Function return expression coercion (good)
run: ./tlang typecheck source/tlang/testing/simple_function_return_type_check_good.t
- name: Function return expression coercion (bad)
run:
set +e
./tlang typecheck source/tlang/testing/simple_function_return_type_check_bad.t
if [ $? = 255 ]
then
exit 0
else
exit 1
fi
emit:
needs: [build, unittests]

View File

@ -0,0 +1,6 @@
module simple_function_return_type_check_bad;
ubyte factorial(ubyte i)
{
return 256;
}

View File

@ -0,0 +1,6 @@
module simple_function_return_type_check_good;
ubyte factorial(ubyte i)
{
return 1;
}