mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Fix tests for 'scm_c_bind_keyword_arguments'.
* test-suite/standalone/test-scm-c-bind-keyword-arguments.c (error_handler): Remove function. (unrecognized_keyword_error_handler, invalid_keyword_error_handler, odd_length_error_handler): New functions. (test_scm_c_bind_keyword_arguments): Use new error handler functions.
This commit is contained in:
parent
79a9a2c271
commit
8b12a34c8f
1 changed files with 48 additions and 17 deletions
|
@ -24,20 +24,6 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
static SCM
|
|
||||||
error_handler (void *data, SCM key, SCM args)
|
|
||||||
{
|
|
||||||
SCM expected_args = scm_list_n (scm_from_utf8_string ("test"),
|
|
||||||
scm_from_utf8_string ((char *) data),
|
|
||||||
SCM_EOL, SCM_BOOL_F,
|
|
||||||
SCM_UNDEFINED);
|
|
||||||
|
|
||||||
assert (scm_is_eq (key, scm_from_utf8_symbol ("keyword-argument-error")));
|
|
||||||
assert (scm_is_true (scm_equal_p (args, expected_args)));
|
|
||||||
|
|
||||||
return SCM_BOOL_T;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
test_unrecognized_keyword (void *data)
|
test_unrecognized_keyword (void *data)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +43,21 @@ test_unrecognized_keyword (void *data)
|
||||||
assert (0);
|
assert (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
unrecognized_keyword_error_handler (void *data, SCM key, SCM args)
|
||||||
|
{
|
||||||
|
SCM expected_args = scm_list_n
|
||||||
|
(scm_from_utf8_string ("test"),
|
||||||
|
scm_from_utf8_string ("Unrecognized keyword"),
|
||||||
|
SCM_EOL, scm_list_1 (scm_from_utf8_keyword ("baz")),
|
||||||
|
SCM_UNDEFINED);
|
||||||
|
|
||||||
|
assert (scm_is_eq (key, scm_from_utf8_symbol ("keyword-argument-error")));
|
||||||
|
assert (scm_is_true (scm_equal_p (args, expected_args)));
|
||||||
|
|
||||||
|
return SCM_BOOL_T;
|
||||||
|
}
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
test_invalid_keyword (void *data)
|
test_invalid_keyword (void *data)
|
||||||
{
|
{
|
||||||
|
@ -75,6 +76,21 @@ test_invalid_keyword (void *data)
|
||||||
assert (0);
|
assert (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
invalid_keyword_error_handler (void *data, SCM key, SCM args)
|
||||||
|
{
|
||||||
|
SCM expected_args = scm_list_n
|
||||||
|
(scm_from_utf8_string ("test"),
|
||||||
|
scm_from_utf8_string ("Invalid keyword"),
|
||||||
|
SCM_EOL, scm_list_1 (SCM_INUM0),
|
||||||
|
SCM_UNDEFINED);
|
||||||
|
|
||||||
|
assert (scm_is_eq (key, scm_from_utf8_symbol ("keyword-argument-error")));
|
||||||
|
assert (scm_is_true (scm_equal_p (args, expected_args)));
|
||||||
|
|
||||||
|
return SCM_BOOL_T;
|
||||||
|
}
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
test_odd_length (void *data)
|
test_odd_length (void *data)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +109,21 @@ test_odd_length (void *data)
|
||||||
assert (0);
|
assert (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SCM
|
||||||
|
odd_length_error_handler (void *data, SCM key, SCM args)
|
||||||
|
{
|
||||||
|
SCM expected_args = scm_list_n
|
||||||
|
(scm_from_utf8_string ("test"),
|
||||||
|
scm_from_utf8_string ("Odd length of keyword argument list"),
|
||||||
|
SCM_EOL, SCM_BOOL_F,
|
||||||
|
SCM_UNDEFINED);
|
||||||
|
|
||||||
|
assert (scm_is_eq (key, scm_from_utf8_symbol ("keyword-argument-error")));
|
||||||
|
assert (scm_is_true (scm_equal_p (args, expected_args)));
|
||||||
|
|
||||||
|
return SCM_BOOL_T;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_scm_c_bind_keyword_arguments ()
|
test_scm_c_bind_keyword_arguments ()
|
||||||
{
|
{
|
||||||
|
@ -174,17 +205,17 @@ test_scm_c_bind_keyword_arguments ()
|
||||||
/* Test unrecognized keyword error. */
|
/* Test unrecognized keyword error. */
|
||||||
scm_internal_catch (SCM_BOOL_T,
|
scm_internal_catch (SCM_BOOL_T,
|
||||||
test_unrecognized_keyword, NULL,
|
test_unrecognized_keyword, NULL,
|
||||||
error_handler, "Unrecognized keyword");
|
unrecognized_keyword_error_handler, NULL);
|
||||||
|
|
||||||
/* Test invalid keyword error. */
|
/* Test invalid keyword error. */
|
||||||
scm_internal_catch (SCM_BOOL_T,
|
scm_internal_catch (SCM_BOOL_T,
|
||||||
test_invalid_keyword, NULL,
|
test_invalid_keyword, NULL,
|
||||||
error_handler, "Invalid keyword");
|
invalid_keyword_error_handler, NULL);
|
||||||
|
|
||||||
/* Test odd length error. */
|
/* Test odd length error. */
|
||||||
scm_internal_catch (SCM_BOOL_T,
|
scm_internal_catch (SCM_BOOL_T,
|
||||||
test_odd_length, NULL,
|
test_odd_length, NULL,
|
||||||
error_handler, "Odd length of keyword argument list");
|
odd_length_error_handler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue