1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00

Changes from arch/CVS synchronization

This commit is contained in:
Ludovic Courtès 2006-11-29 09:25:32 +00:00
parent 25ee3008f7
commit 51785a23a8
4 changed files with 20 additions and 8 deletions

View file

@ -1,4 +1,4 @@
2006-11-29 Ludovic Courtès <ludovic.courtes@laas.fr>
2006-11-29 Ludovic Courtès <ludovic.courtes@laas.fr>
* libguile/vectors.c (scm_vector_to_list): Fixed list
construction: elements were not copied when INC is zero (see

View file

@ -392,15 +392,15 @@ SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0,
SCM res = SCM_EOL;
const SCM *data;
scm_t_array_handle handle;
size_t i, len;
size_t i, count, len;
ssize_t inc;
data = scm_vector_elements (v, &handle, &len, &inc);
for (i = len*inc; i > 0;)
{
i -= inc;
res = scm_cons (data[i], res);
}
for (i = (len - 1) * inc, count = 0;
count < len;
i -= inc, count++)
res = scm_cons (data[i], res);
scm_array_handle_release (&handle);
return res;
}

View file

@ -1,4 +1,4 @@
2006-11-29 Ludovic Courtès <ludovic.courtes@laas.fr>
2006-11-29 Ludovic Courtès <ludovic.courtes@laas.fr>
* test-suite/tests/vectors.test: Use `define-module'.
(vector->list): New test prefix. "Shared array" test contributed

View file

@ -17,6 +17,8 @@
;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;;;; Boston, MA 02110-1301 USA
(define-module (test-suite vectors)
:use-module (test-suite lib))
;; FIXME: As soon as guile supports immutable vectors, this has to be
;; replaced with the appropriate error type and message.
@ -29,3 +31,13 @@
(expect-fail-exception "vector constant"
exception:immutable-vector
(vector-set! '#(1 2 3) 0 4)))
(with-test-prefix "vector->list"
(pass-if "simple vector"
(equal? '(1 2 3) (vector->list #(1 2 3))))
(pass-if "shared array"
(let ((b (make-shared-array #(1) (lambda (x) '(0)) 2)))
(equal? b (list->vector (vector->list b))))))