From f748c25ca8a8b40d6e02772a489cb322e6fd9e16 Mon Sep 17 00:00:00 2001 From: Carlo Sciolla Date: Sun, 27 Aug 2017 13:02:55 +0200 Subject: [PATCH] Some refactoring on test code --- plantuml-mode.el | 23 +++++------------------ test/plantuml-preview-test.el | 16 ++-------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index d4763ed..38b833f 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -276,21 +276,14 @@ to choose where to display it: (set-buffer-multibyte t))))))) (defun plantuml-preview-buffer (prefix) - "Preview diagram from the PlantUML sources in the current buffer. -Uses prefix (as PREFIX) to choose where to display it: -- 4 (when prefixing the command with C-u) -> new window -- 16 (when prefixing the command with C-u C-u) -> new frame. -- else -> new buffer" + "Preview diagram from the PlantUML sources in the current +buffer. See `plantuml-preview-string' for PREFIX usage." (interactive "p") (plantuml-preview-string prefix (buffer-string))) (defun plantuml-preview-region (prefix begin end) "Preview diagram from the PlantUML sources in from BEGIN to END. -Uses the current region when called interactively. -Uses prefix (as PREFIX) to choose where to display it: -- 4 (when prefixing the command with C-u) -> new window -- 16 (when prefixing the command with C-u C-u) -> new frame. -- else -> new buffer" + See `plantuml-preview-string' for PREFIX usage." (interactive "p\nr") (plantuml-preview-string prefix (concat "@startuml\n" (buffer-substring-no-properties @@ -299,10 +292,7 @@ Uses prefix (as PREFIX) to choose where to display it: (defun plantuml-preview-current-block (prefix) "Preview diagram from the PlantUML sources from the previous @startuml to the next @enduml. -Uses prefix (as PREFIX) to choose where to display it: -- 4 (when prefixing the command with C-u) -> new window -- 16 (when prefixing the command with C-u C-u) -> new frame. -- else -> new buffer" + See `plantuml-preview-string' for PREFIX usage." (interactive "p") (save-restriction (narrow-to-region @@ -312,10 +302,7 @@ Uses prefix (as PREFIX) to choose where to display it: (defun plantuml-preview (prefix) "Preview diagram from the PlantUML sources. Uses the current region if one is active, or the entire buffer otherwise. -Uses prefix (as PREFIX) to choose where to display it: -- 4 (when prefixing the command with C-u) -> new window -- 16 (when prefixing the command with C-u C-u) -> new frame. -- else -> new buffer" + See `plantuml-preview-string' for PREFIX usage." (interactive "p") (if mark-active (plantuml-preview-region prefix (region-beginning) (region-end)) diff --git a/test/plantuml-preview-test.el b/test/plantuml-preview-test.el index d87ea19..1bbac6a 100644 --- a/test/plantuml-preview-test.el +++ b/test/plantuml-preview-test.el @@ -27,27 +27,15 @@ equal to OUTPUT. Can choose the output FORMAT (default: utxt)." "Run the test described in FORMS and eventually cleanup the preview buffer." `(unwind-protect (progn + (setq-local plantuml-jar-path plantuml-test-jar-path) ,@forms) (cleanup-preview))) (ert-deftest preview-utxt-test () (test-and-cleanup-preview - (setq-local plantuml-jar-path plantuml-test-jar-path) - (assert-preview "a-b.puml" "a-b.txt"))) - -(ert-deftest preview-unicode-test () - (test-and-cleanup-preview - (setq-local plantuml-jar-path plantuml-test-jar-path) - (setq-local plantuml-output-type "utxt") + (assert-preview "a-b.puml" "a-b.txt") (assert-preview "unicode.puml" "unicode.txt"))) -(ert-deftest preview-new-window() - (test-and-cleanup-preview - (save-window-excursion - (open-test-file-in-buf "a-b.puml") - (plantuml-preview nil) - (sleep-for 3)))) - (provide 'plantuml-mode-preview-test) ;;; plantuml-mode-preview-test.el ends here