[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
- [elpa] externals/phps-mode de771b5 019/405: Added more unit tests, (continued)
- [elpa] externals/phps-mode de771b5 019/405: Added more unit tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e3a060a 026/405: Handles script breaking single-line comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7fa9fdb 024/405: More unit tests for lexing comments and doc comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 64a3ca8 014/405: Modified start and end for single and double quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3ea8c64 003/405: Added license, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f6e3ce4 027/405: Added another test for comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 4fa9341 030/405: Started with unit tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 184dfa5 034/405: Indentation outside PHP now does nothing, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5c0568b 033/405: Added some basic unit tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 47440dd 036/405: Added test for decreasing indentation with letters, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9d3f644 032/405: Separated indentation tests for lexer tests,
Stefan Monnier <=
- [elpa] externals/phps-mode d839f8a 029/405: More work on indentation support, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode efcefde 035/405: Added support for closing parenthesis and braces, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1b891ea 031/405: More work on indentation and related tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6e5255 038/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3837d9c 001/405: My initial commit, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6776468 037/405: Started worked with adding references to tokens from point meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode feb5724 039/405: Various debug work, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e36d477 045/405: token-number from point now is the same format as (nth), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b437374 040/405: Fixed bug in parsing of object parameters inside double quoted string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7161184 041/405: Handles stacked states better, Stefan Monnier, 2019/07/13