diff options
author | Daniel Llorens <daniel.llorens@bluewin.ch> | 2014-02-06 11:17:47 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-02-06 11:17:47 +0100 |
commit | c4aca3b9da9e7777f84efcd304990ad78b883f07 (patch) | |
tree | aceb8b2c5bf77828cbb42990961fc5e71a273383 /test-suite/tests/arrays.test | |
parent | 1fadf369b8eb2eec2011707ef1831c01ae134a37 (diff) | |
download | guile-c4aca3b9da9e7777f84efcd304990ad78b883f07.tar.gz |
Don't use generalized-vector functions in uniform.c
* libguile/uniform.c (scm_is_uniform_vector): Replace
scm_is_generalized_vector and scm_generalized_vector_get_handle by
scm_is_array and manual rank check.
(scm_c_uniform_vector_length): Use scm_c_array_length.
(scm_c_uniform_vector_ref): Use scm_c_array_ref_1.
(scm_c_uniform_vector_set): Use scm_c_array_set_1_x.
(scm_uniform_vector_writable_elements): Use scm_array_get_handle, and
assert that the rank is 1.
* test-suite/test/arrays.test: Rename the uniform-vector-ref block to
uniform-vector. Exercise uniform-vector-length and shared arrays
remaining uniform.
Modifications by Andy Wingo <wingo@pobox.com>.
Diffstat (limited to 'test-suite/tests/arrays.test')
-rw-r--r-- | test-suite/tests/arrays.test | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test index 0b3d57ca2..9d8637122 100644 --- a/test-suite/tests/arrays.test +++ b/test-suite/tests/arrays.test @@ -574,12 +574,12 @@ (eqv? 8 (array-ref s2 2)))))) ;;; -;;; uniform-vector-ref +;;; uniform-vector ;;; -(with-test-prefix "uniform-vector-ref" +(with-test-prefix "uniform-vector" - (with-test-prefix "byte" + (with-test-prefix "uniform-vector-ref byte" (let ((a (make-s8vector 1))) @@ -594,7 +594,23 @@ (pass-if "-128" (begin (array-set! a -128 0) - (= -128 (uniform-vector-ref a 0))))))) + (= -128 (uniform-vector-ref a 0)))))) + + (with-test-prefix "shared with rank 1 remain uniform vectors" + + (let ((a #f64(1 2 3 4))) + + (pass-if "change offset" + (let ((b (make-shared-array a (lambda (i) (list (+ i 1))) 3))) + (and (uniform-vector? b) + (= 3 (uniform-vector-length b)) + (array-equal? b #f64(2 3 4))))) + + (pass-if "change stride" + (let ((c (make-shared-array a (lambda (i) (list (* i 2))) 2))) + (and (uniform-vector? c) + (= 2 (uniform-vector-length c)) + (array-equal? c #f64(1 3)))))))) ;;; ;;; syntax |