emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode 9d3f644 032/405: Separated indentation tests


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 9d3f644 032/405: Separated indentation tests for lexer tests
Date: Sat, 13 Jul 2019 09:59:34 -0400 (EDT)

branch: externals/phps-mode
commit 9d3f6447e56650765d29c9e03c7ddabb8b758385
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    Separated indentation tests for lexer tests
---
 Makefile               | 12 ++++++--
 README.md              | 10 +++++--
 phps-test-functions.el | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
 phps-test-lexer.el     | 44 ++---------------------------
 phps-test.el           | 54 +++++++++++++++++++++++++++++++++++
 5 files changed, 150 insertions(+), 46 deletions(-)

diff --git a/Makefile b/Makefile
index 1beb44f..64b18c6 100644
--- a/Makefile
+++ b/Makefile
@@ -7,17 +7,23 @@ ELC := $(EL:.el=.elc)
 clean:
        rm -f $(ELC)
 
-compile: $(ELC)
+compile:
+       $(ELC)
 
 %.elc: %.el
        $(EMACS_CMD) -f batch-byte-compile $<
 
-test: clean lexer-test parser-test
+test:
+       clean test-functions test-lexer test-parser
+
+test-functions:
+       $(EMACS_CMD) -l phps-test-functions.el
 
 test-lexer:
        $(EMACS_CMD) -l phps-test-lexer.el
 
+
 test-parser:
        $(EMACS_CMD) -l phps-test-parser.el
 
-.PHONY: clean compile test test-lexer test-parser
+.PHONY: clean compile test test-functions test-lexer test-parser
diff --git a/README.md b/README.md
index 51e9237..8f8fc3e 100644
--- a/README.md
+++ b/README.md
@@ -10,12 +10,12 @@ With current progress estimates:
 * Lexer based on official PHP re2c lexer (100%)
 * Syntax coloring based on lexer tokens (100%)
 * Incremental lexer and syntax coloring after changes (0%)
-* PSR based indentation based on lexer tokens (20%)
+* PSR based indentation based on lexer tokens (50%)
 * Wisent LALR parser based on official PHP yacc parser automatically converted 
(60%)
 * Flymake support (0%)
 * Full integration with Emacs Semantic subsystem (0%)
 
-## Unit testing
+## Unit tests
 
 Not ready yet.
 
@@ -30,3 +30,9 @@ make test-lexer
 ``` bash
 make test-parser
 ```
+
+### Indentation
+
+``` bash
+make test-functions
+```
diff --git a/phps-test-functions.el b/phps-test-functions.el
new file mode 100644
index 0000000..c25f820
--- /dev/null
+++ b/phps-test-functions.el
@@ -0,0 +1,76 @@
+;;; phps-test-functions.el --- Tests for functions
+
+;; Author: Christian Johansson <github.com/cjohansson>
+;; Maintainer: Christian Johansson <github.com/cjohansson>
+;; Created: 3 Mar 2018
+;; Modified: .
+;; Version: 0.1
+;; Keywords: tools, convenience
+;; URL: -
+
+;; Copyright (C) 2018 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/with-test-buffer "phps-test")
+(autoload 'should "ert")
+
+(defun phps-mode/test-indentation ()
+  "Test for indentation."
+  (phps-mode/with-test-buffer
+   "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
+   (goto-char 69)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
+     (should (equal buffer-contents  "<html><head><title><?php if 
($myCondition) {\n    if ($mySeconCondition) {\necho $title;\n\n} 
?></title><body>Bla bla</body></html>"))))
+
+  (phps-mode/with-test-buffer
+   "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
+   (goto-char 80)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
+     (should (equal buffer-contents  "<html><head><title><?php if 
($myCondition) {\nif ($mySeconCondition) {\n        echo $title;\n\n} 
?></title><body>Bla bla</body></html>"))))
+
+  (phps-mode/with-test-buffer
+   "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
+   (goto-char 98)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
+     (should (equal buffer-contents  "<html><head><title><?php if  
($myCondition) {\nif ($mySeconCondition) {\necho $title;\n\n} 
?></title><body>Bla bla</body></html>"))))
+
+  )
+
+(defun phps-mod/test-functions ()
+  "Run test for functions."
+  (phps-mode/test-indentation))
+
+(phps-mod/test-functions)
+
+(provide 'phps-mod/test-functions)
+
+;;; phps-test-functions.el ends here
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 225a426..997b96b 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -37,22 +37,10 @@
 ;;; Code:
 
 
-(autoload 'phps-mode "phps-mode")
+(autoload 'phps-mode/with-test-buffer "phps-test")
 (autoload 'phps-mode/lexer-init "phps-lexer")
-
-(require 'ert)
-
-(defmacro phps-mode/with-test-buffer (source &rest body)
-  "Set up test buffer with SOURCE and BODY."
-  `(let ((test-buffer (generate-new-buffer "test")))
-     (switch-to-buffer test-buffer)
-     (insert ,source)
-     (goto-char 0)
-     ;;,(message "\nTesting buffer:\n'%s'\n" source)
-     (phps-mode)
-     ,@body
-     (kill-buffer test-buffer)
-     ))
+(autoload 'phps-mode/lexer-get-point-data "phps-lexer")
+(autoload 'should "ert")
 
 (defun phps-mode/test-lexer--script-boundaries ()
   "Run test for lexer."
@@ -308,31 +296,6 @@
 
   )
 
-(defun phps-mode/test-indentation ()
-  "Test for indentation."
-  (phps-mode/with-test-buffer
-   "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
-   (goto-char 69)
-   (phps-mode/indent-line)
-   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
-     (should (equal buffer-contents  "<html><head><title><?php if 
($myCondition) {\n    if ($mySeconCondition) {\necho $title;\n\n} 
?></title><body>Bla bla</body></html>"))))
-
-  (phps-mode/with-test-buffer
-   "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
-   (goto-char 80)
-   (phps-mode/indent-line)
-   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
-     (should (equal buffer-contents  "<html><head><title><?php if 
($myCondition) {\nif ($mySeconCondition) {\n        echo $title;\n\n} 
?></title><body>Bla bla</body></html>"))))
-
-  (phps-mode/with-test-buffer
-   "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
-   (goto-char 98)
-   (phps-mode/indent-line)
-   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
-     (should (equal buffer-contents  "<html><head><title><?php if 
($myCondition) {\nif ($mySeconCondition) {\necho $title;\n\n} 
?></title><body>Bla bla</body></html>"))))
-
-  )
-
 (defun phps-mode/test-lexer ()
   "Run test for lexer."
   ;; (message "-- Running all tests for lexer... --\n")
@@ -343,7 +306,6 @@
   (phps-mode/test-lexer--namespaces)
   (phps-mode/test-lexer--errors)
   (phps-mode/test-lexer--get-point-data)
-  (phps-mode/test-indentation)
   ;; (message "\n-- Ran all tests for lexer. --")
   )
 
diff --git a/phps-test.el b/phps-test.el
new file mode 100644
index 0000000..60b73b2
--- /dev/null
+++ b/phps-test.el
@@ -0,0 +1,54 @@
+;;; phps-test.el --- Commons for tests
+
+;; Author: Christian Johansson <github.com/cjohansson>
+;; Maintainer: Christian Johansson <github.com/cjohansson>
+;; Created: 3 Mar 2018
+;; Modified: .
+;; Version: 0.1
+;; Keywords: tools, convenience
+;; URL: -
+
+;; Copyright (C) 2018 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:
+
+
+;;; Code:
+
+
+(autoload 'phps-mode "phps-mode")
+
+(defmacro phps-mode/with-test-buffer (source &rest body)
+  "Set up test buffer with SOURCE and BODY."
+  `(let ((test-buffer (generate-new-buffer "test")))
+     (switch-to-buffer test-buffer)
+     (insert ,source)
+     (goto-char 0)
+     ;;,(message "\nTesting buffer:\n'%s'\n" source)
+     (phps-mode)
+     ,@body
+     (kill-buffer test-buffer)
+     ))
+
+
+(provide 'phps-mode/test)
+
+;;; phps-test.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]