indentation tests for diagram commons

This commit is contained in:
René Schmelzer 2019-03-09 08:27:26 +01:00
parent 5ef5ea4302
commit 1b6562a1a2
3 changed files with 329 additions and 21 deletions

View File

@ -358,15 +358,22 @@ Two variants for groups: keyword is either followed by whitespace and some text
or it is followed by line end.")
(defvar plantuml-indent-regexp-activate-start "^\s*activate\s+.+$")
(defvar plantuml-indent-regexp-box-start "^\s*box\s+.+$")
(defvar plantuml-indent-regexp-title-start "^\s*title$")
(defvar plantuml-indent-regexp-header-start "^\s*\\(?:\\(?:center\\|left\\|right\\)\s+header\\|header\\)$")
(defvar plantuml-indent-regexp-footer-start "^\s*\\(?:\\(?:center\\|left\\|right\\)\s+footer\\|footer\\)$")
(defvar plantuml-indent-regexp-legend-start "^\s*\\(?:legend\\|legend\s+\\(?:bottom\\|top\\)\\|legend\s+\\(?:center\\|left\\|right\\)\\|legend\s+\\(?:bottom\\|top\\)\s+\\(?:center\\|left\\|right\\)\\)$")
(defvar plantuml-indent-regexp-if-start "^\s*\\(\\(?:.*\\)?\s*\\(?:[<>.*a-z-|]+\\)?\s*\\(?:\\[[a-zA-Z]+\\]\\)?\s+if\s+.*\\)")
(defvar plantuml-indent-regexp-start (list plantuml-indent-regexp-block-start
plantuml-indent-regexp-note-start
plantuml-indent-regexp-group-start
plantuml-indent-regexp-activate-start
plantuml-indent-regexp-box-start
plantuml-indent-regexp-title-start
plantuml-indent-regexp-header-start
plantuml-indent-regexp-footer-start
plantuml-indent-regexp-legend-start
plantuml-indent-regexp-if-start))
(defvar plantuml-indent-regexp-end "^\s*\\(endif\\|else\\|end\\|end\s+note\\|end\s+box\\|.*}\\|deactivate\s+.+\\)")
(defvar plantuml-indent-regexp-end "^\s*\\(?:endif\\|else\s*.*\\|end\\|end\s+note\\|end\s+box\\|.*}\\|deactivate\s+.+\\|end\s+title\\|endheader\\|endfooter\\|endlegend\\)")
(setq plantuml-font-lock-keywords
`(
(,plantuml-types-regexp . font-lock-type-face)

View File

@ -0,0 +1,319 @@
;;; plantuml-indentation-commons-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation of structures and elements that are common
;; to many/all diagrams.
;;; Code:
(ert-deftest plantuml-test-indentation/commons/skinparam ()
"Test correct indentation of skinparam elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
skinparam roundcorner 20
skinparam rectangle {
roundCorner<<Concept>> 25
}
"
"
skinparam roundcorner 20
skinparam rectangle {
roundCorner<<Concept>> 25
}
"))
(ert-deftest plantuml-test-indentation/commons/rectangle ()
"Test correct indentation of rectangle elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"
"
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"))
(ert-deftest plantuml-test-indentation/commons/title ()
"Test correct indentation of title elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
title
<font color=red>Warning:</font>
Do not use in production.
end title
"
"
title
<font color=red>Warning:</font>
Do not use in production.
end title
" ))
(ert-deftest plantuml-test-indentation/commons/header ()
"Test correct indentation of header elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
header
this is a header
endheader
center header
this is a centered header
endheader
right header
this is a header on right
endheader
left header
this is a header on left
endheader
center left header
this is no correct header
endheader
header left
this is no correct a header
endheader
"
"
header
this is a header
endheader
center header
this is a centered header
endheader
right header
this is a header on right
endheader
left header
this is a header on left
endheader
center left header
this is no correct header
endheader
header left
this is no correct a header
endheader
" ))
(ert-deftest plantuml-test-indentation/commons/footer ()
"Test correct indentation of footer elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
footer
this is a footer
endfooter
center footer
this is a centered footer
endfooter
right footer
this is a footer on right
endfooter
left footer
this is a footer on left
endfooter
center left footer
this is no correct footer
endfooter
footer left
this is no correct a footer
endfooter
"
"
footer
this is a footer
endfooter
center footer
this is a centered footer
endfooter
right footer
this is a footer on right
endfooter
left footer
this is a footer on left
endfooter
center left footer
this is no correct footer
endfooter
footer left
this is no correct a footer
endfooter
" ))
(ert-deftest plantuml-test-indentation/commons/legend ()
"Test correct indentation of legend elements, which are common to many plantuml diagrams:"
(plantuml-test-indent-block
"
legend
Short legend
endlegend
legend bottom
bottom legend
endlegend
legend top
top legend
endlegend
legend center
centered legend
endlegend
legend right
legend on right
endlegend
legend left
legend on left
endlegend
legend bottom left
legend on bottom left
endlegend
legend top left
legend on top left
endlegend
legend bottom right
legend on bottom right
endlegend
legend top right
legend on top right
endlegend
"
"
legend
Short legend
endlegend
legend bottom
bottom legend
endlegend
legend top
top legend
endlegend
legend center
centered legend
endlegend
legend right
legend on right
endlegend
legend left
legend on left
endlegend
legend bottom left
legend on bottom left
endlegend
legend top left
legend on top left
endlegend
legend bottom right
legend on bottom right
endlegend
legend top right
legend on top right
endlegend
" ))
(ert-deftest plantuml-test-indentation/commons/legend-noindent ()
"Test the not-indentation of false legend elements."
(plantuml-test-indent-block
"
legend bottom top
this is no correct legend
endlegend
legend right bottom
this is no correct legend
endlegend
legend left top
this is no correct legend
endlegend
legend center right
this is no correct legend
endlegend
legend center left
this is no correct legend
endlegend
legend right left
this is no correct legend
endlegend
"
"
legend bottom top
this is no correct legend
endlegend
legend right bottom
this is no correct legend
endlegend
legend left top
this is no correct legend
endlegend
legend center right
this is no correct legend
endlegend
legend center left
this is no correct legend
endlegend
legend right left
this is no correct legend
endlegend
"))
(provide 'plantuml-indentation-commons-test)
;;; plantuml-indentation-commons-test.el ends here

View File

@ -6,7 +6,7 @@
;;; Commentary:
;; Test indentation for class diagrams.
;; Test indentation for deployment diagrams.
;; Most plantuml code examples are taken from www.plantuml.com
;;; Code:
@ -49,15 +49,6 @@
storage Foo7 {
storage Foo8
}
skinparam rectangle {
roundCorner<<Concept>> 25
}
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"
"
artifact Foo1 {
@ -93,15 +84,6 @@ database Foo5 {
storage Foo7 {
storage Foo8
}
skinparam rectangle {
roundCorner<<Concept>> 25
}
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"))
(provide 'plantuml-indentation-deployment-test)