Use new text accessors.
[geda-gaf/berndj.git] / libgeda / tests / safereflookup.c
blob92ed114b58d9947713d451dd808e7644e7ef82c9
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 magic_value, gensym, x;
12 int exception_caught = 0;
13 char *undefined_name;
15 libgeda_init(TRUE);
17 s_log_init("/dev/null");
19 toplevel = s_toplevel_new();
21 magic_value = scm_from_locale_symbol("magic");
22 scm_c_define("magic-value", magic_value);
24 /* Check that we can look up a known variable. */
25 x = g_scm_safe_ref_lookup("magic-value");
26 if (!scm_is_symbol(x) || !scm_is_eq(x, magic_value)) {
27 exit(1);
30 /* Generate a quasi-unique name that won't be bound. */
31 gensym = scm_gensym(scm_from_locale_string(" safereflookup"));
32 undefined_name = scm_to_locale_string(scm_symbol_to_string(gensym));
34 /* Force an exception. */
35 x = g_scm_safe_ref_lookup(undefined_name);
36 free(undefined_name);
37 if (!scm_is_eq(x, SCM_UNDEFINED)) {
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;