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:
parent
25ee3008f7
commit
51785a23a8
4 changed files with 20 additions and 8 deletions
|
@ -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
|
* libguile/vectors.c (scm_vector_to_list): Fixed list
|
||||||
construction: elements were not copied when INC is zero (see
|
construction: elements were not copied when INC is zero (see
|
||||||
|
|
|
@ -392,15 +392,15 @@ SCM_DEFINE (scm_vector_to_list, "vector->list", 1, 0, 0,
|
||||||
SCM res = SCM_EOL;
|
SCM res = SCM_EOL;
|
||||||
const SCM *data;
|
const SCM *data;
|
||||||
scm_t_array_handle handle;
|
scm_t_array_handle handle;
|
||||||
size_t i, len;
|
size_t i, count, len;
|
||||||
ssize_t inc;
|
ssize_t inc;
|
||||||
|
|
||||||
data = scm_vector_elements (v, &handle, &len, &inc);
|
data = scm_vector_elements (v, &handle, &len, &inc);
|
||||||
for (i = len*inc; i > 0;)
|
for (i = (len - 1) * inc, count = 0;
|
||||||
{
|
count < len;
|
||||||
i -= inc;
|
i -= inc, count++)
|
||||||
res = scm_cons (data[i], res);
|
res = scm_cons (data[i], res);
|
||||||
}
|
|
||||||
scm_array_handle_release (&handle);
|
scm_array_handle_release (&handle);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'.
|
* test-suite/tests/vectors.test: Use `define-module'.
|
||||||
(vector->list): New test prefix. "Shared array" test contributed
|
(vector->list): New test prefix. "Shared array" test contributed
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
;;;; Boston, MA 02110-1301 USA
|
;;;; 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
|
;; FIXME: As soon as guile supports immutable vectors, this has to be
|
||||||
;; replaced with the appropriate error type and message.
|
;; replaced with the appropriate error type and message.
|
||||||
|
@ -29,3 +31,13 @@
|
||||||
(expect-fail-exception "vector constant"
|
(expect-fail-exception "vector constant"
|
||||||
exception:immutable-vector
|
exception:immutable-vector
|
||||||
(vector-set! '#(1 2 3) 0 4)))
|
(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))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue