add docs and tests for array->list
authorAndy Wingo <wingo@pobox.com>
Wed, 7 Apr 2010 19:04:37 +0000 (21:04 +0200)
committerAndy Wingo <wingo@pobox.com>
Wed, 7 Apr 2010 19:04:37 +0000 (21:04 +0200)
* libguile/generalized-arrays.c (scm_array_to_list): Add docs.
* test-suite/tests/arrays.test ("array->list"): Add tests.

libguile/generalized-arrays.c
test-suite/tests/arrays.test

index ff05151b3ac5f570f25bccbebb23ffd3121ccc69..a04b5faa107b80443487e544414218865b41da35 100644 (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 array),
-           "FIXME description a list consisting of all the elements, in order, of\n"
-           "@var{array}.")
+           "Return a list representation of @var{array}.\n\n"
+            "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
 {
   scm_t_array_handle h;
index 2ce961b14151e6c60f11a0a355e477f58e58a50c..b762f201468029834f2a9115fcc32e3c1657c40c 100644 (file)
   (pass-if "#s16(...)"
     (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!
 ;;;