* Makefile.am (DEFS): Added. automake adds -I options to DEFS,
[bpt/guile.git] / libguile / gh_test_repl.c
index 5ef7a44..670d335 100644 (file)
@@ -1,4 +1,4 @@
-/*      Copyright (C) 1995,1996 Free Software Foundation, Inc.
+/*      Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -12,7 +12,8 @@
  * 
  * You should have received a copy of the GNU General Public License
  * along with this software; see the file COPYING.  If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
  *
  * As a special exception, the Free Software Foundation gives permission
  * for additional uses of the text contained in its release of GUILE.
@@ -36,8 +37,7 @@
  *
  * If you write modifications of your own for GUILE, it is your choice
  * whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice.  
- */
+ * If you do not wish that, delete this exception notice.  */
 \f
 
 /* gh_test_repl -- a program that demonstrates starting Guile, adding
@@ -46,7 +46,7 @@
 #include <stdio.h>
 #include <math.h>
 
-#include <gh.h>
+#include "libguile/gh.h"
 
 SCM c_factorial (SCM s_n);
 SCM c_sin (SCM s_x);
@@ -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,8 +99,9 @@ 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 ();
+  gh_repl (argc, argv);
 }
 
 int 
@@ -145,12 +146,26 @@ 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_x (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;
 }
+
+/*
+  Local Variables:
+  c-file-style: "gnu"
+  End:
+*/