ef4eecefae
* fix version * split indentation rexgexs Split the regexs as a preparation for improvement and enhancement. No explicit enhancement was intended, although the `plantuml-indent-regexp-block-start' covers more blocks now. * enhance and test regexs for groups Changed `plantuml-indent-regexp-group-start' to cover all cases mentioned on sequence diagram page of the plantuml website. Added tests for all elements-with and without label (text following the keyword). * add support and test for box/end box blocks * indentation test for a nested interface block * correction of () at end of file * indentation test for deployment diagram * file “Cask”: added dependency to dash * indentation tests for diagram commons * add indentation tests for component diagrams * regex corrections and added indentation tests for class diagrams correct indentation regexs found by tests for class diagrams * add indentation tests for object diagrams * add indentation tests for state diagrams * enhance indentation class diagram test: abstract class and interface * move indentation tests to diagram test files * mv test/plantuml-indentation-test.el -> test/plantuml-indentation-basics-test.el * add indentation sequence diagram tests and mv basics tests to diagram tests * add indentation for ref-groups * improved indentation for ref-groups * support indentation for activity diagrams - current/old style * indentation support for notes * rm not used regexs * indentation support for plantuml macros * correction: … → etc.
76 lines
2 KiB
EmacsLisp
76 lines
2 KiB
EmacsLisp
;;; test-helper.el --- PlantUML Mode test initialization -*- lexical-binding: t; -*-
|
|
|
|
;; Author: Carlo Sciolla (skuro)
|
|
;; Maintainer: Carlo Sciolla (skuro)
|
|
;; URL: https://github.com/skuro/plantuml-mode
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
(require 'f)
|
|
|
|
(defvar package-test-path
|
|
(f-dirname (f-this-file)))
|
|
|
|
(defvar package-code-path
|
|
(f-parent package-test-path))
|
|
|
|
(defvar plantuml-test-resources-path
|
|
(f-join package-code-path "test/resources"))
|
|
|
|
(defvar plantuml-test-jar-path
|
|
(f-join package-code-path "bin/plantuml.jar"))
|
|
|
|
(defun read-buffer (bufname)
|
|
(with-current-buffer (get-buffer bufname)
|
|
(buffer-string)))
|
|
|
|
(defun read-preview-buffer ()
|
|
(read-buffer plantuml-preview-buffer))
|
|
|
|
(defun read-test-file (path)
|
|
(f-read (f-join plantuml-test-resources-path path) 'utf-8))
|
|
|
|
(defun load-plantuml-mode ()
|
|
(require 'plantuml-mode (f-expand "plantuml-mode.el" package-code-path)))
|
|
|
|
(defun format-preview-output (s)
|
|
"Make the preview output as S more readable in test output."
|
|
(concat "\n" s))
|
|
|
|
(defun plantuml-test-indent-block (before after)
|
|
"The common code for the block indentation tests.
|
|
|
|
BEFORE is the text block to be inserted into a temporary buffer.
|
|
AFTER is the expected text block after indentation.
|
|
|
|
The temporary buffer will be put into `plantuml-mode'. The whole buffer
|
|
will be indented with two spaces for each level of indentation.
|
|
|
|
Finally, the indented text in the buffer will be compared with AFTER."
|
|
|
|
(with-temp-buffer
|
|
;; fix the JAR location prior to mode initialization
|
|
;; for some reason, plantuml-mode disregards the setq-local
|
|
(setq-local plantuml-jar-path plantuml-test-jar-path)
|
|
(plantuml-init-once)
|
|
|
|
(insert before)
|
|
(goto-char (point-min))
|
|
(plantuml-mode)
|
|
;; use 2 spaces instead of one tab for indentation
|
|
(setq-local indent-tabs-mode nil)
|
|
(setq-local tab-width 2)
|
|
|
|
(indent-region (point-min) (point-max))
|
|
(should (equal (buffer-string) after))))
|
|
|
|
;; enable code coverage
|
|
(when (require 'undercover nil t)
|
|
(undercover "plantuml-mode.el"))
|
|
|
|
(load-plantuml-mode)
|
|
|
|
;;; test-helper.el ends here
|