branch: externals/phps-mode commit 3bc2411bdd2165d263a2d8766e3984ae851cdb90 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Moved syntax-table tests to own file, using local electric-pair-mode in PHPs buffers --- Makefile | 8 ++- README.md | 34 ++++++------ phps-mode-syntax-table.el | 2 +- phps-mode-test-functions.el | 69 +------------------------ phps-mode-test-syntax-table.el | 115 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 142 insertions(+), 86 deletions(-) diff --git a/Makefile b/Makefile index a14ed07..8cedd5f 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ ifdef emacs endif EMACS_CMD := $(EMACS) -Q -batch -L . -EL := phps-mode-flymake.el phps-mode-font-lock.el phps-mode-functions.el phps-mode-lexer.el phps-mode-map.el phps-mode-semantic.el phps-mode-syntax-table.el phps-mode-test.el phps-mode-test-functions.el phps-mode-test-integration.el phps-mode-test-lexer.el phps-mode-test-parser.el phps-mode.el +EL := phps-mode-flymake.el phps-mode-font-lock.el phps-mode-functions.el phps-mode-lexer.el phps-mode-map.el phps-mode-semantic.el phps-mode-syntax-table.el phps-mode-test.el phps-mode-test-functions.el phps-mode-test-integration.el phps-mode-test-lexer.el phps-mode-test-parser.el phps-mode-test-syntax-table.el phps-mode.el ELC := $(EL:.el=.elc) .PHONY: clean @@ -16,7 +16,7 @@ compile: $(EMACS_CMD) -f batch-byte-compile $(EL) .PHONY: tests -tests: test-functions test-lexer test-parser test-integration +tests: test-functions test-integration test-lexer test-parser test-syntax-table .PHONY: test-functions test-functions: @@ -33,3 +33,7 @@ test-lexer: .PHONY: test-parser test-parser: $(EMACS_CMD) -l phps-mode-test-parser.el + +.PHONY: test-syntax-table +test-syntax-table: + $(EMACS_CMD) -l phps-mode-test-syntax-table.el diff --git a/README.md b/README.md index f51cab3..230ffc3b 100644 --- a/README.md +++ b/README.md @@ -31,44 +31,48 @@ This mode does not require PHP installed on computer because it has a elisp base If you have emacs at a customized location prefix the commands with your path, i.e. -`export emacs="~/Documents/emacs/src/emacs" && make test-lexer` +`export emacs="~/Documents/emacs/src/emacs" && make tests` -### Lexer +Run all tests with `make tests`. -Semantic token generation. +### Functions + +Indentations, incremental processes, Imenu-support. ``` bash -make test-lexer +make test-functions ``` -### Parser +## Integration -Semantic grammar. Not ready yet. +This should test all other parts in collaboration. ``` bash -make test-parser +make test-integration ``` -### Functions +### Lexer -Indentations, incremental processes, Imenu-support. +Semantic token generation. ``` bash -make test-functions +make test-lexer ``` -## Integration tests +### Parser -This should test all other parts in collaboration. +Semantic grammar. Not ready yet. ``` bash -make test-integration +make test-parser ``` -## All tests +### Syntax-table + +Basic point and region behaviour. ``` bash -make tests +make test-syntax-table ``` ## Compilation diff --git a/phps-mode-syntax-table.el b/phps-mode-syntax-table.el index 23a1413..f278f20 100644 --- a/phps-mode-syntax-table.el +++ b/phps-mode-syntax-table.el @@ -112,7 +112,7 @@ ;; NOTE: These are required for wrapping region functionality (transient-mark-mode) - (electric-pair-mode) + (electric-pair-local-mode) (when (boundp 'electric-pair-pairs) diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index 139705f..982a9d9 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -777,72 +777,6 @@ ) -(defun phps-mode-test-functions-quote-region () - "Test double quotes, single quotes, curly bracket, square bracket, round bracket, back-quotes on regions." - - (phps-mode-test-with-buffer - "<?php\n$var = abc;" - "Double quotes around region" - (goto-char 14) - (push-mark nil t t) - (goto-char 17) - (execute-kbd-macro (kbd "\"")) - (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) - (should (equal buffer-contents "<?php\n$var = \"abc\";")))) - - (phps-mode-test-with-buffer - "<?php\n$var = abc;" - "Single-quotes brackets around region" - (goto-char 14) - (push-mark nil t t) - (goto-char 17) - (execute-kbd-macro (kbd "'")) - (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) - (should (equal buffer-contents "<?php\n$var = 'abc';")))) - - (phps-mode-test-with-buffer - "<?php\n$var = abc;" - "Round brackets around region" - (goto-char 14) - (push-mark nil t t) - (goto-char 17) - (execute-kbd-macro (kbd "(")) - (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) - (should (equal buffer-contents "<?php\n$var = (abc);")))) - - (phps-mode-test-with-buffer - "<?php\n$var = abc;" - "Square brackets around region" - (goto-char 14) - (push-mark nil t t) - (goto-char 17) - (execute-kbd-macro (kbd "[")) - (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) - (should (equal buffer-contents "<?php\n$var = [abc];")))) - - (phps-mode-test-with-buffer - "<?php\n$var = abc;" - "Curly brackets around region" - (goto-char 14) - (push-mark nil t t) - (goto-char 17) - (execute-kbd-macro (kbd "{")) - (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) - (should (equal buffer-contents "<?php\n$var = {abc};")))) - - (phps-mode-test-with-buffer - "<?php\n$var = abc;" - "Backquotes brackets around region" - (goto-char 14) - (push-mark nil t t) - (goto-char 17) - (execute-kbd-macro (kbd "`")) - (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) - (should (equal buffer-contents "<?php\n$var = `abc`;")))) - - - ) - (defun phps-mode-test-functions-comment-uncomment-region () "Test (comment-region) and (uncomment-region)." @@ -876,8 +810,7 @@ (phps-mode-test-functions-get-lines-indent-psr-2) (phps-mode-test-functions-indent-line) (phps-mode-test-functions-imenu) - (phps-mode-test-functions-comment-uncomment-region) - (phps-mode-test-functions-quote-region)) + (phps-mode-test-functions-comment-uncomment-region)) (phps-mode-test-functions) diff --git a/phps-mode-test-syntax-table.el b/phps-mode-test-syntax-table.el new file mode 100644 index 0000000..f274d58 --- /dev/null +++ b/phps-mode-test-syntax-table.el @@ -0,0 +1,115 @@ +;;; phps-mode-test-syntax-table.el --- Tests for syntax-table -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Christian Johansson + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Spathoftware Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + + +;;; Commentary: + + +;; Run from terminal make functions-test + + +;;; Code: + + +(autoload 'phps-mode-test-with-buffer "phps-mode-test") +(autoload 'phps-mode-functions-verbose "phps-mode-functions") +(autoload 'phps-mode-functions-indent-line "phps-mode-functions") +(autoload 'phps-mode-functions-get-lines-indent "phps-mode-functions") +(autoload 'phps-mode-functions-get-imenu "phps-mode-functions") +(autoload 'phps-mode-test-hash-to-list "phps-mode-test") +(autoload 'should "ert") + +(defun phps-mode-test-syntax-table-quote-region () + "Test double quotes, single quotes, curly bracket, square bracket, round bracket, back-quotes on regions." + + (phps-mode-test-with-buffer + "<?php\n$var = abc;" + "Double quotes around region" + (goto-char 14) + (push-mark nil t t) + (goto-char 17) + (execute-kbd-macro (kbd "\"")) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "<?php\n$var = \"abc\";")))) + + (phps-mode-test-with-buffer + "<?php\n$var = abc;" + "Single-quotes brackets around region" + (goto-char 14) + (push-mark nil t t) + (goto-char 17) + (execute-kbd-macro (kbd "'")) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "<?php\n$var = 'abc';")))) + + (phps-mode-test-with-buffer + "<?php\n$var = abc;" + "Round brackets around region" + (goto-char 14) + (push-mark nil t t) + (goto-char 17) + (execute-kbd-macro (kbd "(")) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "<?php\n$var = (abc);")))) + + (phps-mode-test-with-buffer + "<?php\n$var = abc;" + "Square brackets around region" + (goto-char 14) + (push-mark nil t t) + (goto-char 17) + (execute-kbd-macro (kbd "[")) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "<?php\n$var = [abc];")))) + + (phps-mode-test-with-buffer + "<?php\n$var = abc;" + "Curly brackets around region" + (goto-char 14) + (push-mark nil t t) + (goto-char 17) + (execute-kbd-macro (kbd "{")) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "<?php\n$var = {abc};")))) + + (phps-mode-test-with-buffer + "<?php\n$var = abc;" + "Backquotes brackets around region" + (goto-char 14) + (push-mark nil t t) + (goto-char 17) + (execute-kbd-macro (kbd "`")) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "<?php\n$var = `abc`;")))) + + + ) + +(defun phps-mode-test-syntax-table () + "Run test." + (phps-mode-test-syntax-table-quote-region)) + +(phps-mode-test-syntax-table) + + +(provide 'phps-mode-test-syntax-table) + +;;; phps-mode-test-syntax-table.el ends here