branch: externals/csharp-mode commit 628a4e2afa0e9c4672e8654c86240cb7f7bdf444 Author: Tim Van Holder <tim.vanholder@leeloo.anubex.internal> Commit: Jostein Kjønigsen <jost...@kjonigsen.net>
Added testcases for region fontification. Extended test-files/region-fontification.cs with more cases. Added a test to ensure all cases get fontified correctly. --- csharp-mode-tests.el | 11 +++++++++++ test-files/region-fontification.cs | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el index 5fb917c..fb72759 100644 --- a/csharp-mode-tests.el +++ b/csharp-mode-tests.el @@ -386,6 +386,17 @@ (forward-word -1) (should (looking-at "fontifies"))) +(ert-deftest fontification-of-regions () + (require 'assess) + (require 'm-buffer) + (find-file "test-files/region-fontification.cs") + (csharp-mode) + (let ((buf (current-buffer))) + ;; look for 'a region comment' - should always be a comment + (should (assess-face-at= buf 'csharp-mode (lambda (buf) (m-buffer-match buf "a region comment")) 'font-lock-comment-face)) + ;; look for 'string' - should always be a type + (should (assess-face-at= buf 'csharp-mode (lambda (buf) (m-buffer-match buf "string")) 'font-lock-type-face)))) + ;;(ert-run-tests-interactively t) ;; (local-set-key (kbd "<f6>") '(lambda () ;; (interactive) diff --git a/test-files/region-fontification.cs b/test-files/region-fontification.cs index 8012948..0b4fbfb 100644 --- a/test-files/region-fontification.cs +++ b/test-files/region-fontification.cs @@ -4,12 +4,41 @@ public class Test { public void Test() { - #region fontifies correctly + #region fontifies as a region comment string foo = "bar"; #endregion - #region does'nt fontify correctly + #region quotes shouldn't mess up a region comment + string foo = "bar"; + #endregion + + #region any number of spaces are allowed before a region comment + string foo = "bar"; + #endregion + + #region a TAB is also allowed before a region comment + string foo = "bar"; + #endregion + + # region a region comment is fine when there are spaces between the # and the region + string foo = "bar"; + # endregion + + # region a TAB between the # and the region doesn't stop this being a region comment either + string foo = "bar"; + # endregion + + #region --- a region comment doesn't have to start with a word --- + string foo = "bar"; + #endregion + + #region "a region comment can even look like this" + string foo = "bar"; + #endregion + + // This is here just to ensure the commentification doesn't bleed to the next line + #region string foo = "bar"; #endregion } -} \ No newline at end of file +}