1 /* Copyright (C) 2010 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 /* Exercise the compatibility layer of `libguile-srfi-srfi-1'. */
26 #include <srfi/srfi-1.h>
31 failure (const char *proc
, SCM result
)
33 scm_simple_format (scm_current_error_port (),
34 scm_from_locale_string ("`~S' failed: ~S~%"),
35 scm_list_2 (scm_from_locale_symbol (proc
), result
));
41 SCM times
, negative_p
, lst
, result
;
45 times
= SCM_VARIABLE_REF (scm_c_lookup ("*"));
46 lst
= scm_list_3 (scm_from_int (1), scm_from_int (2), scm_from_int (3));
48 /* (fold * 1 '(1 2 3) '(1 2 3)) */
49 result
= scm_srfi1_fold (times
, scm_from_int (1), lst
, scm_list_1 (lst
));
51 if (scm_to_int (result
) == 36)
53 negative_p
= SCM_VARIABLE_REF (scm_c_lookup ("negative?"));
54 result
= scm_srfi1_break (negative_p
,
55 scm_list_3 (scm_from_int (1),
59 if (SCM_VALUESP (result
))
60 /* There's no API to access the values, so assume this is OK. */
61 * (int *) data
= EXIT_SUCCESS
;
64 failure ("break", result
);
65 * (int *) data
= EXIT_FAILURE
;
70 failure ("fold", result
);
71 * (int *) data
= EXIT_FAILURE
;
79 main (int argc
, char *argv
[])
83 scm_with_guile (tests
, &ret
);