mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Fix embarrassing pretty-print bug
* module/ice-9/pretty-print.scm (pretty-print): We were never indenting more than 8 spaces. Doh! * test-suite/tests/print.test (prints?, "pretty-print"): Add test.
This commit is contained in:
parent
19c7969fff
commit
1f724ccd39
2 changed files with 21 additions and 5 deletions
|
@ -106,7 +106,7 @@ port directly after OBJ, like (pretty-print OBJ PORT)."
|
||||||
(when (< 0 n)
|
(when (< 0 n)
|
||||||
(put-string port " " 0 (min 8 n))
|
(put-string port " " 0 (min 8 n))
|
||||||
(when (< 8 n)
|
(when (< 8 n)
|
||||||
(spaces (- 8 n)))))
|
(spaces (- n 8)))))
|
||||||
|
|
||||||
(define (indent to)
|
(define (indent to)
|
||||||
(let ((col (port-column port)))
|
(let ((col (port-column port)))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;;; -*- coding: utf-8; mode: scheme; -*-
|
;;;; -*- coding: utf-8; mode: scheme; -*-
|
||||||
;;;;
|
;;;;
|
||||||
;;;; Copyright (C) 2010, 2013, 2014 Free Software Foundation, Inc.
|
;;;; Copyright (C) 2010, 2013, 2014, 2023 Free Software Foundation, Inc.
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This library is free software; you can redistribute it and/or
|
;;;; This library is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
(define-syntax prints?
|
(define-syntax prints?
|
||||||
;; #t if EXP prints as RESULT.
|
;; #t if EXP prints as RESULT.
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((_ exp result)
|
((_ exp result arg ...)
|
||||||
(string=? result
|
(string=? result
|
||||||
(with-output-to-string
|
(with-output-to-string
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(pretty-print 'exp)))))))
|
(pretty-print 'exp arg ...)))))))
|
||||||
|
|
||||||
(define (with-print-options opts thunk)
|
(define (with-print-options opts thunk)
|
||||||
(let ((saved-options (print-options)))
|
(let ((saved-options (print-options)))
|
||||||
|
@ -111,7 +111,23 @@
|
||||||
|
|
||||||
(pass-if "quasiquote & co."
|
(pass-if "quasiquote & co."
|
||||||
(prints? (define foo `(bar ,(+ 2 3)))
|
(prints? (define foo `(bar ,(+ 2 3)))
|
||||||
"(define foo `(bar ,(+ 2 3)))\n")))
|
"(define foo `(bar ,(+ 2 3)))\n"))
|
||||||
|
|
||||||
|
(pass-if "indent"
|
||||||
|
(prints? (9 (8 (7 (6 (5 (4 (3 (2 (1 (0 0))))))))))
|
||||||
|
(string-append
|
||||||
|
"(9\n"
|
||||||
|
" (8\n"
|
||||||
|
" (7\n"
|
||||||
|
" (6\n"
|
||||||
|
" (5\n"
|
||||||
|
" (4\n"
|
||||||
|
" (3\n"
|
||||||
|
" (2\n"
|
||||||
|
" (1\n"
|
||||||
|
" (0\n"
|
||||||
|
" 0))))))))))\n")
|
||||||
|
#:width 10)))
|
||||||
|
|
||||||
|
|
||||||
(with-test-prefix "truncated-print"
|
(with-test-prefix "truncated-print"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue