From eadb4e8c8317cf6586bd45bc2860d27b8f7610da Mon Sep 17 00:00:00 2001 From: radrow Date: Wed, 2 Jun 2021 17:03:23 +0200 Subject: [PATCH 1/2] Fix Frac library and add stdlib compilation test --- priv/stdlib/Frac.aes | 2 ++ test/aeso_compiler_tests.erl | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) 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); From 254172e3a31493af75ae0578f0b8297d42277ad6 Mon Sep 17 00:00:00 2001 From: radrow Date: Wed, 2 Jun 2021 17:06:36 +0200 Subject: [PATCH 2/2] Properly refer the stdlib --- test/aeso_compiler_tests.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index d6efe12..eb7969d 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -92,8 +92,7 @@ simple_compile_test_() -> %% 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), + {ok, Files} = file:list_dir(aeso_stdlib:stdlib_include_path()), [ { "Testing " ++ File ++ " from the stdlib", fun() -> String = "include \"" ++ File ++ "\"\nmain contract Test =\n entrypoint f(x) = x",