Some refactoring on test code
This commit is contained in:
parent
1c32cdbf54
commit
f748c25ca8
|
@ -276,21 +276,14 @@ to choose where to display it:
|
||||||
(set-buffer-multibyte t)))))))
|
(set-buffer-multibyte t)))))))
|
||||||
|
|
||||||
(defun plantuml-preview-buffer (prefix)
|
(defun plantuml-preview-buffer (prefix)
|
||||||
"Preview diagram from the PlantUML sources in the current buffer.
|
"Preview diagram from the PlantUML sources in the current
|
||||||
Uses prefix (as PREFIX) to choose where to display it:
|
buffer. See `plantuml-preview-string' for PREFIX usage."
|
||||||
- 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"
|
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(plantuml-preview-string prefix (buffer-string)))
|
(plantuml-preview-string prefix (buffer-string)))
|
||||||
|
|
||||||
(defun plantuml-preview-region (prefix begin end)
|
(defun plantuml-preview-region (prefix begin end)
|
||||||
"Preview diagram from the PlantUML sources in from BEGIN to END.
|
"Preview diagram from the PlantUML sources in from BEGIN to END.
|
||||||
Uses the current region when called interactively.
|
See `plantuml-preview-string' for PREFIX usage."
|
||||||
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"
|
|
||||||
(interactive "p\nr")
|
(interactive "p\nr")
|
||||||
(plantuml-preview-string prefix (concat "@startuml\n"
|
(plantuml-preview-string prefix (concat "@startuml\n"
|
||||||
(buffer-substring-no-properties
|
(buffer-substring-no-properties
|
||||||
|
@ -299,10 +292,7 @@ Uses prefix (as PREFIX) to choose where to display it:
|
||||||
|
|
||||||
(defun plantuml-preview-current-block (prefix)
|
(defun plantuml-preview-current-block (prefix)
|
||||||
"Preview diagram from the PlantUML sources from the previous @startuml to the next @enduml.
|
"Preview diagram from the PlantUML sources from the previous @startuml to the next @enduml.
|
||||||
Uses prefix (as PREFIX) to choose where to display it:
|
See `plantuml-preview-string' for PREFIX usage."
|
||||||
- 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"
|
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(narrow-to-region
|
(narrow-to-region
|
||||||
|
@ -312,10 +302,7 @@ Uses prefix (as PREFIX) to choose where to display it:
|
||||||
(defun plantuml-preview (prefix)
|
(defun plantuml-preview (prefix)
|
||||||
"Preview diagram from the PlantUML sources.
|
"Preview diagram from the PlantUML sources.
|
||||||
Uses the current region if one is active, or the entire buffer otherwise.
|
Uses the current region if one is active, or the entire buffer otherwise.
|
||||||
Uses prefix (as PREFIX) to choose where to display it:
|
See `plantuml-preview-string' for PREFIX usage."
|
||||||
- 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"
|
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(if mark-active
|
(if mark-active
|
||||||
(plantuml-preview-region prefix (region-beginning) (region-end))
|
(plantuml-preview-region prefix (region-beginning) (region-end))
|
||||||
|
|
|
@ -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."
|
"Run the test described in FORMS and eventually cleanup the preview buffer."
|
||||||
`(unwind-protect
|
`(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
|
(setq-local plantuml-jar-path plantuml-test-jar-path)
|
||||||
,@forms)
|
,@forms)
|
||||||
(cleanup-preview)))
|
(cleanup-preview)))
|
||||||
|
|
||||||
(ert-deftest preview-utxt-test ()
|
(ert-deftest preview-utxt-test ()
|
||||||
(test-and-cleanup-preview
|
(test-and-cleanup-preview
|
||||||
(setq-local plantuml-jar-path plantuml-test-jar-path)
|
(assert-preview "a-b.puml" "a-b.txt")
|
||||||
(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 "unicode.puml" "unicode.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)
|
(provide 'plantuml-mode-preview-test)
|
||||||
|
|
||||||
;;; plantuml-mode-preview-test.el ends here
|
;;; plantuml-mode-preview-test.el ends here
|
||||||
|
|
Loading…
Reference in New Issue