From: Ben Lynn Date: Wed, 17 Sep 2008 11:42:17 +0000 (-0700) Subject: Converted tests to use tee. X-Git-Url: https://repo.or.cz/w/frac.git/commitdiff_plain/49aa45e781e9da5cd41c9926e022ac41051b9019 Converted tests to use tee. --- diff --git a/bihom_test.c b/bihom_test.c index 10548f1..85dc545 100644 --- a/bihom_test.c +++ b/bihom_test.c @@ -45,18 +45,20 @@ int main() { cf_free(s1); // Check 2 (cos 1)^2 - 1 = cos 2 = - s1 = cf_new_cos1(); // TODO: Implement tee, use that instead. c1 = cf_new_cos1(); + cf_t t[2]; + cf_tee(t, c1); mpz_set_si(addarray[0], 2); mpz_set_si(addarray[3], -1); mpz_set_si(addarray[7], 1); - b = cf_new_bihom(s1, c1, addarray); + b = cf_new_bihom(t[0], t[1], addarray); CF_EXPECT_DEC(b, "-0.41614683654714238699"); + cf_free(t[0]); + cf_free(t[1]); cf_free(b); cf_free(c1); - cf_free(s1); for (int i = 0; i < 8; i++) { mpz_clear(addarray[i]); diff --git a/cf.h b/cf.h index 67c7f27..4c1474d 100644 --- a/cf.h +++ b/cf.h @@ -26,7 +26,7 @@ int cf_wait(cf_t cf); void *cf_data(cf_t cf); void cf_signal(cf_t cf); // For tee. -void cf_waitspecial(cf_t cf); +void cf_wait_special(cf_t cf); // From cf_tee.c: // diff --git a/newton_test.c b/newton_test.c index 1e0655b..52ce9d5 100644 --- a/newton_test.c +++ b/newton_test.c @@ -34,19 +34,21 @@ int main() { // Confirm sqrt(1-(sin 1)^2) = cos 1 x = cf_new_sin1(); - y = cf_new_sin1(); // TODO: Use tee here. + cf_t s1[2]; + cf_tee(s1, x); mpz_t b[8]; for (i = 0; i < 8; i++) mpz_init(b[i]); mpz_set_si(b[0], -1); mpz_set_si(b[3], 1); mpz_set_si(b[7], 1); - cf_t bi = cf_new_bihom(x, y, b); + cf_t bi = cf_new_bihom(s1[0], s1[1], b); cf_t n = cf_new_sqrt(bi); CF_EXPECT_DEC(n, "0.54030230586813971740"); cf_free(x); - cf_free(y); + cf_free(s1[0]); + cf_free(s1[1]); cf_free(bi); cf_free(n); diff --git a/tee.c b/tee.c index 82d2985..bc24add 100644 --- a/tee.c +++ b/tee.c @@ -34,7 +34,7 @@ struct parent_data_s { typedef struct parent_data_s parent_data_t[1]; typedef struct parent_data_s *parent_data_ptr; -// TODO: Destroy after children are destroyed. +// TODO: Join after destruction. static void *parent_loop(cf_t cf) { struct backlog_s { mpz_t z;