Use new text accessors.
[geda-gaf/berndj.git] / libgeda / tests / evalprotected.c
blob86079cbe29b59b0264889a2e6a03798e556b62af
1 #include "config.h"
3 #include <glib.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include "libgeda_priv.h"
8 void main_prog(void *userdata, int argc, char *argv[])
10 TOPLEVEL *toplevel;
11 SCM x;
13 libgeda_init(TRUE);
15 toplevel = s_toplevel_new();
17 s_log_init("/dev/null");
19 /* Check that we get the right return value. */
20 x = g_scm_c_eval_string_protected("(+ 17 42)");
21 if (!scm_is_integer(x) || scm_to_int(x) != (17 + 42)) {
22 exit(1);
25 /* Evaluate just a number as an s-expr rather than a string. */
26 x = g_scm_eval_protected(scm_from_int(42), scm_current_module());
27 if (!scm_is_integer(x) || scm_to_int(x) != 42) {
28 exit(1);
31 /* Force an exception. */
32 x = g_scm_eval_protected(scm_list_3(scm_from_locale_symbol("throw"),
33 scm_list_2(scm_from_locale_symbol("quote"),
34 scm_from_locale_symbol("pro-forma")),
35 scm_from_int(17)),
36 scm_current_module());
37 if (!scm_is_false(x)) {
38 exit(1);
41 exit(0);
44 int main(int argc, char *argv[])
46 scm_boot_guile(argc, argv, &main_prog, NULL);
48 /* scm_boot_guile doesn't return! */
49 return 1;