Commit | Line | Data |
---|---|---|
c5e05a1c | 1 | ;;;; -*- coding: utf-8; mode: scheme; -*- |
87a6a236 AW |
2 | ;;;; |
3 | ;;;; Copyright (C) 2010 Free Software Foundation, Inc. | |
4 | ;;;; | |
5 | ;;;; This library is free software; you can redistribute it and/or | |
6 | ;;;; modify it under the terms of the GNU Lesser General Public | |
7 | ;;;; License as published by the Free Software Foundation; either | |
8 | ;;;; version 3 of the License, or (at your option) any later version. | |
c5e05a1c | 9 | ;;;; |
87a6a236 AW |
10 | ;;;; This library is distributed in the hope that it will be useful, |
11 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | ;;;; Lesser General Public License for more details. | |
c5e05a1c | 14 | ;;;; |
87a6a236 AW |
15 | ;;;; You should have received a copy of the GNU Lesser General Public |
16 | ;;;; License along with this library; if not, write to the Free Software | |
17 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | ||
19 | (define-module (test-suite test-print) | |
20 | #:use-module (ice-9 pretty-print) | |
21 | #:use-module (test-suite lib)) | |
22 | ||
23 | (with-test-prefix "truncated-print" | |
24 | (define exp '(a b #(c d e) f . g)) | |
c5e05a1c LC |
25 | |
26 | (define (tprint x width encoding) | |
27 | (with-fluids ((%default-port-encoding encoding)) | |
28 | (with-output-to-string | |
29 | (lambda () | |
30 | (truncated-print x #:width width))))) | |
31 | ||
32 | (pass-if (equal? (tprint exp 10 "ISO-8859-1") | |
33 | "(a b . #)")) | |
34 | ||
35 | (pass-if (equal? (tprint exp 15 "ISO-8859-1") | |
36 | "(a b # f . g)")) | |
37 | ||
38 | (pass-if (equal? (tprint exp 18 "ISO-8859-1") | |
39 | "(a b #(c ...) . #)")) | |
40 | ||
41 | (pass-if (equal? (tprint exp 20 "ISO-8859-1") | |
42 | "(a b #(c d e) f . g)")) | |
43 | ||
44 | (pass-if (equal? (tprint "The quick brown fox" 20 "ISO-8859-1") | |
45 | "\"The quick brown...\"")) | |
46 | ||
47 | (pass-if (equal? (tprint "The quick brown fox" 20 "UTF-8") | |
48 | "\"The quick brown f…\"")) | |
49 | ||
50 | (pass-if (equal? (tprint (current-module) 20 "ISO-8859-1") | |
51 | "#<directory (tes...>")) | |
52 | ||
53 | (pass-if (equal? (tprint (current-module) 20 "UTF-8") | |
54 | "#<directory (test-…>"))) |