diff --git a/priv/stdlib/Frac.aes b/priv/stdlib/Frac.aes index 64cec1e..c6febd9 100644 --- a/priv/stdlib/Frac.aes +++ b/priv/stdlib/Frac.aes @@ -1,3 +1,5 @@ +include "String.aes" + namespace Frac = private function gcd(a : int, b : int) = diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index 00df6ac..d6efe12 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -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);