mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-28 05:50:30 +02:00
Fix bitvectors and non-zero lower bound arrays in truncated-print
* module/ice-9/arrays.scm (array-print-prefix): New private function. * libguile/arrays.c (scm_i_print_array): Reuse (array-print-prefix) from (ice-9 arrays). Make sure to release the array handle. * module/ice-9/pretty-print.scm (truncated-print): Support bitvectors. Don't try to guess the array prefix but call array-print-prefix from (ice-9 arrays) instead. Fix call to print-sequence to support non-zero lower bound arrays. * test-suite/tests/arrays.test: Test that arrays print properly. * test-suite/tests/print.test: Test truncated-print with bitvectors, non-zero lower bound arrays.
This commit is contained in:
parent
f52fc0566f
commit
e0bcda4ad9
5 changed files with 169 additions and 56 deletions
|
@ -147,6 +147,35 @@
|
|||
(pass-if-equal "#<directory (test-…>"
|
||||
(tprint (current-module) 20 "UTF-8"))
|
||||
|
||||
;; bitvectors
|
||||
|
||||
(let ((testv (bitvector #t #f #f #t #t #f #t #t)))
|
||||
(pass-if-equal "#*10011011"
|
||||
(tprint testv 11 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#*10011011"
|
||||
(tprint testv 11 "ISO-8859-1"))
|
||||
|
||||
(pass-if-equal "#*10011…"
|
||||
(tprint testv 8 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#*100..."
|
||||
(tprint testv 8 "ISO-8859-1"))
|
||||
|
||||
(pass-if-equal "#*10…"
|
||||
(tprint testv 5 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#*..."
|
||||
(tprint testv 5 "ISO-8859-1"))
|
||||
|
||||
(pass-if-equal "#*1…"
|
||||
(tprint testv 4 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#"
|
||||
(tprint testv 4 "ISO-8859-1")))
|
||||
|
||||
;; rank 0 arrays
|
||||
|
||||
(pass-if-equal "#0(#)"
|
||||
(tprint (make-typed-array #t 9.0) 6 "UTF-8"))
|
||||
|
||||
|
@ -162,18 +191,31 @@
|
|||
(pass-if-equal "#"
|
||||
(tprint (make-typed-array 's32 0 20 20) 7 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#2s32(…)"
|
||||
(tprint (make-typed-array 's32 0 20 20) 8 "UTF-8"))
|
||||
;; higher dimensional arrays
|
||||
|
||||
(pass-if-equal "#2s32(# …)"
|
||||
(tprint (make-typed-array 's32 0 20 20) 10 "UTF-8"))
|
||||
(let ((testa (make-typed-array 's32 0 20 20)))
|
||||
(pass-if-equal "#2s32(…)"
|
||||
(tprint testa 8 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#2s32((…) …)"
|
||||
(tprint (make-typed-array 's32 0 20 20) 12 "UTF-8"))
|
||||
(pass-if-equal "#2s32(# …)"
|
||||
(tprint testa 10 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#2s32((0 …) …)"
|
||||
(tprint (make-typed-array 's32 0 20 20) 14 "UTF-8"))
|
||||
(pass-if-equal "#2s32((…) …)"
|
||||
(tprint testa 12 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#2s32((0 …) …)"
|
||||
(tprint testa 14 "UTF-8")))
|
||||
|
||||
;; check that bounds are printed correctly
|
||||
|
||||
(pass-if-equal "#2@-1@0((foo foo foo foo …) …)"
|
||||
(tprint (make-array 'foo '(-1 3) 5) 30 "UTF-8"))
|
||||
|
||||
(pass-if-equal "#3@-1:5@0:0@0:5(() () () # #)"
|
||||
(tprint (make-array 'foo '(-1 3) 0 5) 30 "UTF-8"))
|
||||
|
||||
;; nested objects including arrays
|
||||
|
||||
(pass-if-equal "#2((#(9 9) #(9 9)) (#(9 9) #(9 9)))"
|
||||
(tprint (make-typed-array #t (make-typed-array #t 9 2) 2 2) 40 "UTF-8"))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue