From 204b96fe6c857c32b6c22f20cf02f7556f434002 Mon Sep 17 00:00:00 2001 From: Robert Wright Date: Mon, 17 May 2021 13:18:00 +0100 Subject: [PATCH] Add RefC math library linking --- src/Compiler/RefC/CC.idr | 3 ++- tests/Main.idr | 2 +- tests/refc/doubles/TestDoubles.idr | 21 +++++++++++++++++++++ tests/refc/doubles/expected | 11 +++++++++++ tests/refc/doubles/run | 4 ++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/refc/doubles/TestDoubles.idr create mode 100644 tests/refc/doubles/expected create mode 100644 tests/refc/doubles/run diff --git a/src/Compiler/RefC/CC.idr b/src/Compiler/RefC/CC.idr index b70345289..528249689 100644 --- a/src/Compiler/RefC/CC.idr +++ b/src/Compiler/RefC/CC.idr @@ -61,7 +61,8 @@ compileCFile {asShared} objectFile outFile = fullprefix_dir dirs "lib" "libidris2_support.a" ++ " " ++ "-lidris2_refc " ++ "-L" ++ fullprefix_dir dirs "refc " ++ - clibdirs (lib_dirs dirs) + clibdirs (lib_dirs dirs) ++ + "-lm" log "compiler.refc.cc" 10 runcc 0 <- coreLift $ system runcc diff --git a/tests/Main.idr b/tests/Main.idr index fcc358b92..c635e1f4d 100644 --- a/tests/Main.idr +++ b/tests/Main.idr @@ -223,7 +223,7 @@ chezTests = MkTestPool "Chez backend" [Chez] refcTests : TestPool refcTests = MkTestPool "Reference counting C backend" [C] [ "refc001" , "refc002" - , "strings" + , "strings", "doubles" ] racketTests : TestPool diff --git a/tests/refc/doubles/TestDoubles.idr b/tests/refc/doubles/TestDoubles.idr new file mode 100644 index 000000000..e2724aa7b --- /dev/null +++ b/tests/refc/doubles/TestDoubles.idr @@ -0,0 +1,21 @@ +module TestDoubles + +put : Double -> IO () +put = putStrLn . show + +main : IO () +main = do + put $ exp 1 + put $ log 1 + + put $ sin 1 + put $ cos 1 + put $ tan 1 + put $ asin 1 + put $ acos 1 + put $ atan 1 + + put $ sqrt 2 + + put $ floor 1.5 + put $ ceiling 1.5 diff --git a/tests/refc/doubles/expected b/tests/refc/doubles/expected new file mode 100644 index 000000000..0ca3ac279 --- /dev/null +++ b/tests/refc/doubles/expected @@ -0,0 +1,11 @@ +2.718282 +0.000000 +0.841471 +0.540302 +1.557408 +1.570796 +0.000000 +0.785398 +1.414214 +1.000000 +2.000000 diff --git a/tests/refc/doubles/run b/tests/refc/doubles/run new file mode 100644 index 000000000..6c0710b3d --- /dev/null +++ b/tests/refc/doubles/run @@ -0,0 +1,4 @@ +$1 --no-banner --no-color --console-width 0 --cg refc -o refc_doubles TestDoubles.idr > /dev/null +./build/exec/refc_doubles + +rm -rf build