summaryrefslogtreecommitdiff
path: root/test-suite/standalone/test-srfi-1.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-08-27 15:43:30 +0200
committerLudovic Courtès <ludo@gnu.org>2010-08-27 18:59:42 +0200
commitb86d23093284512a6a3c1780e9e5547c9ab34c25 (patch)
treecb6c52c23b3edf548b41658728ea4d926ca0227c /test-suite/standalone/test-srfi-1.c
parentd7418e60a5b427a9d733929cf6ff468402dada1d (diff)
downloadguile-b86d23093284512a6a3c1780e9e5547c9ab34c25.tar.gz
SRFI-1: Rewrite `break' and `break!' in Scheme.
This partially reverts commit 6e9f3c2676c0101590d4229653e9c628cb293064 (Tue May 3 2005). * module/srfi/srfi-1.scm (break, break!): New procedures. * srfi/srfi-1.c (scm_srfi1_break, scm_srfi1_break_x): Rewrite as proxies to the corresponding Scheme procedures. * test-suite/standalone/test-srfi-1.c (failure): New function. (tests): Add `scm_srfi1_break' test. Use `failure'.
Diffstat (limited to 'test-suite/standalone/test-srfi-1.c')
-rw-r--r--test-suite/standalone/test-srfi-1.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/test-suite/standalone/test-srfi-1.c b/test-suite/standalone/test-srfi-1.c
index 215008ddc..995c20e95 100644
--- a/test-suite/standalone/test-srfi-1.c
+++ b/test-suite/standalone/test-srfi-1.c
@@ -27,10 +27,18 @@
#include <stdlib.h>
+static void
+failure (const char *proc, SCM result)
+{
+ scm_simple_format (scm_current_error_port (),
+ scm_from_locale_string ("`~S' failed: ~S~%"),
+ scm_list_2 (scm_from_locale_symbol (proc), result));
+}
+
static void *
tests (void *data)
{
- SCM times, lst, result;
+ SCM times, negative_p, lst, result;
scm_init_srfi_1 ();
@@ -41,9 +49,27 @@ tests (void *data)
result = scm_srfi1_fold (times, scm_from_int (1), lst, scm_list_1 (lst));
if (scm_to_int (result) == 36)
- * (int *) data = EXIT_SUCCESS;
+ {
+ negative_p = SCM_VARIABLE_REF (scm_c_lookup ("negative?"));
+ result = scm_srfi1_break (negative_p,
+ scm_list_3 (scm_from_int (1),
+ scm_from_int (2),
+ scm_from_int (-1)));
+
+ if (SCM_VALUESP (result))
+ /* There's no API to access the values, so assume this is OK. */
+ * (int *) data = EXIT_SUCCESS;
+ else
+ {
+ failure ("break", result);
+ * (int *) data = EXIT_FAILURE;
+ }
+ }
else
- * (int *) data = EXIT_FAILURE;
+ {
+ failure ("fold", result);
+ * (int *) data = EXIT_FAILURE;
+ }
return data;
}