1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

add docs and tests for array->list

* libguile/generalized-arrays.c (scm_array_to_list): Add docs.
* test-suite/tests/arrays.test ("array->list"): Add tests.
This commit is contained in:
Andy Wingo 2010-04-07 21:04:37 +02:00
parent f5318d8b18
commit e48a2f8705
2 changed files with 19 additions and 2 deletions

View file

@ -250,8 +250,14 @@ array_to_list (scm_t_array_handle *h, size_t dim, unsigned long pos)
SCM_DEFINE (scm_array_to_list, "array->list", 1, 0, 0, SCM_DEFINE (scm_array_to_list, "array->list", 1, 0, 0,
(SCM array), (SCM array),
"FIXME description a list consisting of all the elements, in order, of\n" "Return a list representation of @var{array}.\n\n"
"@var{array}.") "It is easiest to specify the behavior of this function by\n"
"example:\n"
"@example\n"
"(array->list #0(a)) @result{} 1\n"
"(array->list #1(a b)) @result{} (a b)\n"
"(array->list #2((aa ab) (ba bb)) @result{} ((aa ab) (ba bb))\n"
"@end example\n")
#define FUNC_NAME s_scm_array_to_list #define FUNC_NAME s_scm_array_to_list
{ {
scm_t_array_handle h; scm_t_array_handle h;

View file

@ -206,6 +206,17 @@
(pass-if "#s16(...)" (pass-if "#s16(...)"
(array-equal? #s16(1 2 3) #s16(1 2 3)))) (array-equal? #s16(1 2 3) #s16(1 2 3))))
;;;
;;; array->list
;;;
(with-test-prefix "array->list"
(pass-if (equal? (array->list #s16(1 2 3)) '(1 2 3)))
(pass-if (equal? (array->list #(1 2 3)) '(1 2 3)))
(pass-if (equal? (array->list #2((1 2) (3 4) (5 6))) '((1 2) (3 4) (5 6))))
(pass-if (equal? (array->list #()) '())))
;;; ;;;
;;; array-fill! ;;; array-fill!
;;; ;;;