Fix Frac library and add stdlib compilation test

This commit is contained in:
radrow 2021-06-02 17:03:23 +02:00
parent e2af89287d
commit eadb4e8c83
2 changed files with 20 additions and 0 deletions

View File

@ -1,3 +1,5 @@
include "String.aes"
namespace Frac =
private function gcd(a : int, b : int) =

View File

@ -90,6 +90,24 @@ simple_compile_test_() ->
end} || Backend <- [aevm, fate] ] ++
[].
%% Check if all modules in the standard library compile
stdlib_test_() ->
StdlibDir = filename:append(code:priv_dir(aesophia), "stdlib"),
{ok, Files} = file:list_dir(StdlibDir),
[ { "Testing " ++ File ++ " from the stdlib",
fun() ->
String = "include \"" ++ File ++ "\"\nmain contract Test =\n entrypoint f(x) = x",
Options = [{src_file, File}, {backend, fate}],
case aeso_compiler:from_string(String, Options) of
{ok, #{fate_code := Code}} ->
Code1 = aeb_fate_code:deserialize(aeb_fate_code:serialize(Code)),
?assertMatch({X, X}, {Code1, Code});
{error, Error} -> io:format("\n\n~p\n\n", [Error]), print_and_throw(Error)
end
end} || File <- Files,
lists:suffix(".aes", File)
].
check_errors(no_error, Actual) -> ?assertMatch(#{}, Actual);
check_errors(Expect, #{}) ->
?assertEqual({error, Expect}, ok);