summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Llorens <daniel.llorens@bluewin.ch>2013-04-10 14:53:10 +0200
committerAndy Wingo <wingo@pobox.com>2014-01-27 21:45:17 +0100
commit82c481dd116d68da74920e4a0598b8a39f3a3b51 (patch)
treee01c5761568d6a05884b7e8c793e233cc0a2c2b9
parentaaeb4e5bfba2782215eb408fe68874bc1fdbf471 (diff)
downloadguile-82c481dd116d68da74920e4a0598b8a39f3a3b51.tar.gz
Tests for transpose-array
* test-suite/tests/arrays.test: test transpose-array for ranks 1, 2, 3.
-rw-r--r--test-suite/tests/arrays.test32
1 files changed, 32 insertions, 0 deletions
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test
index 135392797..c3a28c5ec 100644
--- a/test-suite/tests/arrays.test
+++ b/test-suite/tests/arrays.test
@@ -603,6 +603,38 @@
(eq? (shared-array-root a) (shared-array-root b) (array-contents a)))))
;;;
+;;; transpose-array
+;;;
+
+(with-test-prefix "transpose-array"
+
+ (pass-if "rank 1"
+ (let* ((a #(1 2 3))
+ (b (transpose-array a 0)))
+ (and (array-equal? a b)
+ (eq? (shared-array-root a) (shared-array-root b)))))
+
+ (pass-if "rank 2"
+ (let* ((a #2((1 2 3) (4 5 6)))
+ (b (transpose-array a 1 0))
+ (c (transpose-array a 0 1)))
+ (and (array-equal? b #2((1 4) (2 5) (3 6)))
+ (array-equal? c a)
+ (eq? (shared-array-root a)
+ (shared-array-root b)
+ (shared-array-root c)))))
+
+ ; rank > 2 is needed to check against the inverted axis index logic.
+ (pass-if "rank 3"
+ (let* ((a #3(((0 1 2 3) (4 5 6 7) (8 9 10 11))
+ ((12 13 14 15) (16 17 18 19) (20 21 22 23))))
+ (b (transpose-array a 1 2 0)))
+ (and (array-equal? b #3(((0 4 8) (12 16 20)) ((1 5 9) (13 17 21))
+ ((2 6 10) (14 18 22)) ((3 7 11) (15 19 23))))
+ (eq? (shared-array-root a)
+ (shared-array-root b))))))
+
+;;;
;;; uniform-vector
;;;