aboutsummaryrefslogtreecommitdiff
path: root/tests/style.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-01-02 18:14:00 +0100
committerLudovic Courtès <ludo@gnu.org>2022-01-10 14:59:26 +0100
commit5d9a5e230189347ba6f5b78a3d74b36a867aa9e6 (patch)
tree68360d1d116fa767274eae10043a5dd41a505293 /tests/style.scm
parentc4fe13c294cc1e31dd8a49ce3981f603fb169e0a (diff)
downloadguix-5d9a5e230189347ba6f5b78a3d74b36a867aa9e6.tar
guix-5d9a5e230189347ba6f5b78a3d74b36a867aa9e6.tar.gz
style: '-S format' canonicalizes comments.
* guix/scripts/style.scm (canonicalize-comment): New procedure. (pretty-print-with-comments): Add #:format-comment. and honor it. (object->string*): Add 'args' and honor them. (format-package-definition): Pass #:format-comment to 'object->string*'. * tests/style.scm ("pretty-print-with-comments, canonicalize-comment"): New test.
Diffstat (limited to 'tests/style.scm')
-rw-r--r--tests/style.scm25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/style.scm b/tests/style.scm
index 7dae543860..8c6d37a661 100644
--- a/tests/style.scm
+++ b/tests/style.scm
@@ -485,6 +485,31 @@ mnopqrstuvwxyz.\")"
'(#:phases %standard-phases
#:tests? #f)))")
+(test-equal "pretty-print-with-comments, canonicalize-comment"
+ "\
+(list abc
+ ;; Not a margin comment.
+ ;; Ditto.
+ ;;
+ ;; There's a blank line above.
+ def ;margin comment
+ ghi)"
+ (let ((sexp (call-with-input-string
+ "\
+(list abc
+ ;Not a margin comment.
+ ;;; Ditto.
+ ;;;;;
+ ; There's a blank line above.
+ def ;; margin comment
+ ghi)"
+ read-with-comments)))
+ (call-with-output-string
+ (lambda (port)
+ (pretty-print-with-comments port sexp
+ #:format-comment
+ canonicalize-comment)))))
+
(test-end)
;; Local Variables: