summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2013-04-03 22:31:47 +0200
committerLudovic Courtès <ludo@gnu.org>2013-04-05 22:54:14 +0200
commitb5159a471a1acbe1ad08ee5365d123912fcc607d (patch)
tree0deacfeb39b01ac65011577fb45922b792530d02
parent55e26a49dbc5fa7ccbf218305d88b0b37db4db3f (diff)
downloadguile-b5159a471a1acbe1ad08ee5365d123912fcc607d.tar.gz
Tests for array-copy!
* test-suite/tests/arrays.test: tests for arguments of rank 0, 1 and 2. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-rw-r--r--test-suite/tests/arrays.test40
1 files changed, 40 insertions, 0 deletions
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test
index d88a1cb8c..aa976311f 100644
--- a/test-suite/tests/arrays.test
+++ b/test-suite/tests/arrays.test
@@ -294,6 +294,46 @@
(pass-if "5/8" (array-fill! a 5/8) #t))))
;;;
+;;; array-copy!
+;;;
+
+(with-test-prefix "array-copy!"
+
+ (pass-if "rank 2"
+ (let ((a #2((1 2) (3 4)))
+ (b (make-array 0 2 2))
+ (c (make-array 0 2 2))
+ (d (make-array 0 2 2))
+ (e (make-array 0 2 2)))
+ (array-copy! a b)
+ (array-copy! a (transpose-array c 1 0))
+ (array-copy! (transpose-array a 1 0) d)
+ (array-copy! (transpose-array a 1 0) (transpose-array e 1 0))
+ (and (equal? a #2((1 2) (3 4)))
+ (equal? b #2((1 2) (3 4)))
+ (equal? c #2((1 3) (2 4)))
+ (equal? d #2((1 3) (2 4)))
+ (equal? e #2((1 2) (3 4))))))
+
+ (pass-if "rank 1"
+ (let* ((a #2((1 2) (3 4)))
+ (b (make-shared-array a (lambda (j) (list 1 j)) 2))
+ (c (make-shared-array a (lambda (i) (list (- 1 i) 1)) 2))
+ (d (make-array 0 2))
+ (e (make-array 0 2)))
+ (array-copy! b d)
+ (array-copy! c e)
+ (and (equal? d #(3 4))
+ (equal? e #(4 2)))))
+
+ (pass-if "rank 0"
+ (let ((a #0(99))
+ (b (make-array 0)))
+ (array-copy! a b)
+ (equal? b #0(99)))))
+
+
+;;;
;;; array-in-bounds?
;;;