summaryrefslogtreecommitdiff
path: root/libguile/gh_test_repl.c
diff options
context:
space:
mode:
authorMark Galassi <mark+savannah@galassi.org>1997-10-13 07:25:31 +0000
committerMark Galassi <mark+savannah@galassi.org>1997-10-13 07:25:31 +0000
commite5eece747e920b3510aa661f3e4483ec440b3b96 (patch)
tree14e89911c131d7ab94530a786d51c78c3abedbaa /libguile/gh_test_repl.c
parentda7f71d7d59969c10b80bd501dbea024318f6d90 (diff)
downloadguile-e5eece747e920b3510aa661f3e4483ec440b3b96.tar.gz
* gh_test_repl.c (c_vector_test): same as gh_test_c.c
* gh_test_c.c (c_vector_test): some improvements on the vector routines test. * gh.h (gh_vector): this used to exist but do the wrong thing. Now it (almost) does the right thing, though it takes a list instead of the individual arguments. I need to see how it could be done right. (gh_list_to_vector): added this function as a macro. Corresponds to Scheme's (list->vector ...). (gh_vector_to_list): added this function as a macro. Corresponds to Scheme's (vector->list ...). * gh_data.c (gh_vector_ref): renamed from gh_vref to gh_vector_ref, so that it resembles the Scheme routines more. (gh_vector_set): renamed from gh_vset to gh_vector_set, so that it resembles the Scheme routines more. (gh_make_vector): this used to be (stupidly) called gh_vector(). This is the right name, since it does the same thing as the Scheme (make-vector ...) procedure.
Diffstat (limited to 'libguile/gh_test_repl.c')
-rw-r--r--libguile/gh_test_repl.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/libguile/gh_test_repl.c b/libguile/gh_test_repl.c
index d220642c9..6de48b606 100644
--- a/libguile/gh_test_repl.c
+++ b/libguile/gh_test_repl.c
@@ -75,9 +75,9 @@ main_prog (int argc, char *argv[])
gh_eval_str ("(display (pair? s))");
/* now define some new primitives in C */
- cf = gh_new_procedure1_0 ("c_factorial", c_factorial);
- gh_new_procedure1_0 ("c_sin", c_sin);
- gh_new_procedure1_0 ("c_vector_test", c_vector_test);
+ cf = gh_new_procedure1_0 ("c-factorial", c_factorial);
+ gh_new_procedure1_0 ("c-sin", c_sin);
+ gh_new_procedure1_0 ("c-vector-test", c_vector_test);
/* now try some (eval ...) action from C */
{
@@ -99,6 +99,7 @@ main_prog (int argc, char *argv[])
printf ("testing the predicates for procedure? and vector?\n");
printf ("gh_procedure_p(c_factorial) is %d, gh_vector_p(c_factorial) is %d\n",
gh_procedure_p (cf), gh_vector_p (cf));
+ gh_eval_str("(c-vector-test 200)");
gh_repl ();
}
@@ -145,12 +146,20 @@ c_vector_test (SCM s_length)
unsigned long c_length;
c_length = gh_scm2ulong (s_length);
- printf ("requested length for vector: %ld\n", c_length);
+ printf ("VECTOR test -- requested length for vector: %ld", c_length);
/* create a vector filled witth 0.0 entries */
- xvec = gh_vector (c_length, gh_double2scm (0.0));
+ xvec = gh_make_vector (s_length, gh_double2scm (0.0));
/* set the second element in it to some floating point value */
- gh_vset (xvec, 2, gh_double2scm (1.9));
+ gh_vector_set (xvec, gh_int2scm(2), gh_double2scm (1.9));
+
+ /* I think I can use == because Scheme's doubles should be the same
+ as C doubles, with no operations in between */
+ if (gh_scm2double(gh_vector_ref (xvec, gh_int2scm(2))) == 1.9) {
+ printf("... PASS\n");
+ } else {
+ printf("... FAIL\n");
+ }
return xvec;
}