mpfr: improve test

This commit is contained in:
FX Coudert 2017-07-27 11:08:34 +02:00
parent bca91fbe36
commit fe1a86bba1

View file

@ -33,19 +33,24 @@ class Mpfr < Formula
test do
(testpath/"test.c").write <<-EOS.undent
#include <gmp.h>
#include <mpfr.h>
#include <math.h>
#include <stdlib.h>
int main()
{
mpfr_t x;
mpfr_init(x);
mpfr_clear(x);
int main() {
mpfr_t x, y;
mpfr_inits2 (256, x, y, NULL);
mpfr_set_ui (x, 2, MPFR_RNDN);
mpfr_root (y, x, 2, MPFR_RNDN);
mpfr_pow_si (x, y, 4, MPFR_RNDN);
mpfr_add_si (y, x, -4, MPFR_RNDN);
mpfr_abs (y, y, MPFR_RNDN);
if (fabs(mpfr_get_d (y, MPFR_RNDN)) > 1.e-30) abort();
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["gmp"].opt_lib}", "-lgmp",
"-lmpfr", "-o", "test"
system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["gmp"].opt_lib}",
"-lgmp", "-lmpfr", "-o", "test"
system "./test"
end
end