diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-08-02 17:08:53 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-08-08 11:22:32 +0200 |
commit | 9b00c97de41165beefe3eff936470f8e081ca600 (patch) | |
tree | 618b5533951927f672dfee73ec1e980800ec3e87 /tests | |
parent | 077324a16fd6c7d2307bfa52a9863ca25cfc6a52 (diff) | |
download | guix-9b00c97de41165beefe3eff936470f8e081ca600.tar guix-9b00c97de41165beefe3eff936470f8e081ca600.tar.gz |
read-print: Add code to read and write sequences of expressions/blanks.
* guix/read-print.scm (read-with-comments): Add #:blank-line? and honor it.
(read-with-comments/sequence, pretty-print-with-comments/splice): New
procedures.
* tests/read-print.scm (test-pretty-print/sequence): New macro.
Add tests using it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/read-print.scm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/read-print.scm b/tests/read-print.scm index 70be7754f8..94f018dd44 100644 --- a/tests/read-print.scm +++ b/tests/read-print.scm @@ -33,6 +33,16 @@ read-with-comments))) (pretty-print-with-comments port exp args ...)))))) +(define-syntax-rule (test-pretty-print/sequence str args ...) + "Likewise, but read and print entire sequences rather than individual +expressions." + (test-equal str + (call-with-output-string + (lambda (port) + (let ((lst (call-with-input-string str + read-with-comments/sequence))) + (pretty-print-with-comments/splice port lst args ...)))))) + (test-begin "read-print") @@ -251,6 +261,33 @@ mnopqrstuvwxyz.\")" ;; page break above end)") +(test-pretty-print/sequence "\ +;;; This is a top-level comment. + + +;; Above is a page break. +(this is an sexp + ;; with a comment + !!) + +;; The end.\n") + +(test-pretty-print/sequence " +;;; Hello! + +(define-module (foo bar) + #:use-module (guix) + #:use-module (gnu)) + + +;; And now, the OS. +(operating-system + (host-name \"komputilo\") + (locale \"eo_EO.UTF-8\") + + (services + (cons (service mcron-service-type) %base-services)))\n") + (test-equal "pretty-print-with-comments, canonicalize-comment" "\ (list abc |