branch: externals/csharp-mode commit 3050139511c51cbb74482ff9e12677efada4bf10 Author: Jostein Kjønigsen <jost...@kjonigsen.net> Commit: Jostein Kjønigsen <jost...@kjonigsen.net>
Add fontification-test. --- csharp-mode-tests.el | 45 +++++++++++++++++++++++++++++++++++++++++++-- makefile | 4 ++-- test-files/test.cs | 4 ++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/csharp-mode-tests.el b/csharp-mode-tests.el index 4e028b7..5ab0a45 100644 --- a/csharp-mode-tests.el +++ b/csharp-mode-tests.el @@ -1,12 +1,53 @@ - (require 'ert) (require 'csharp-mode) +;;; test-helper functions + +(defun move-to-line-after (text) + (search-forward text) + (move-beginning-of-line 1) + (forward-line 1)) + +(defun get-current-line-contents () + (let* ((start) + (end)) + (move-beginning-of-line 1) + (setq start (point)) + (move-end-of-line 1) + (setq end (point)) + (buffer-substring start end))) + +;;; actual tests + (ert-deftest activating-mode-doesnt-cause-failure () (with-temp-buffer (csharp-mode) (should (equal 'csharp-mode major-mode)))) -;;(ert-run-tests-interactively t) +(setq debug-res nil) +(ert-deftest fontification-of-literals-detects-end-of-strings () + ;; this test needs a double which also writes and generates the actual + ;; test-content itself by inserting into a new temp buffer. + (let* ((buffer (find-file-read-only "d:/Throwaway/test.cs"))) + ;; double-ensure mode is active + (csharp-mode) + (goto-char (point-min)) + (let* ((buffer1) + (buffer2)) + ;; get reference string + (move-to-line-after "Literal1") + (setq buffer1 (get-current-line-contents)) + + ;; get verification string + (move-to-line-after "Literal2") + (setq buffer2 (get-current-line-contents)) + + ;; check equality + (setq debug-res (list buffer1 buffer2)) + (should + (equal buffer1 buffer2))))) + + +;;(ert-run-tests-interactively t) diff --git a/makefile b/makefile index e26452f..a095924 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -VERSION=$(shell grep ";; Version " csharp-mode.el | cut -d ":" -f2 | cut -c2-) +VERSION=$(shell grep -a ";; Version " csharp-mode.el | cut -d ":" -f2 | cut -c2-) PACKAGE_SHORTNAME=csharp-mode PACKAGE_NAME:=$(PACKAGE_SHORTNAME)-$(VERSION) PACKAGE_DIR:=./.tmp/$(PACKAGE_NAME) @@ -9,7 +9,7 @@ ELS = csharp-mode.el csharp-mode-tests.el ELCS = $(ELS:.el=.elc) package: $(PACKAGE_DIR) - tar cvf ../$(PACKAGE_NAME).tar --exclude="*#" --exclude="*~" --exclude="*tests*" --exclude "*-pkg.el.template*" --exclude="makefile" --exclude="run-travis-ci.sh" -C $(PACKAGE_DIR)/.. $(PACKAGE_NAME) + tar cvf ../$(PACKAGE_NAME).tar --exclude="*#" --exclude="*~" --exclude="*tests*" --exclude="test-files" --exclude "*-pkg.el.template*" --exclude="makefile" --exclude="run-travis-ci.sh" -C $(PACKAGE_DIR)/.. $(PACKAGE_NAME) $(PACKAGE_DIR): mkdir -p $@ diff --git a/test-files/test.cs b/test-files/test.cs new file mode 100644 index 0000000..c743ede --- /dev/null +++ b/test-files/test.cs @@ -0,0 +1,4 @@ +public const string Literal1 = @"literal without trailing slash"; +public const bool Reference = true; +public const string Literal2 = @"literal with trailing slash\"; +public const bool Reference = true;