[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 365d739 324/405: Changed structure of integra
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 365d739 324/405: Changed structure of integration tests |
Date: |
Sat, 13 Jul 2019 10:00:41 -0400 (EDT) |
branch: externals/phps-mode
commit 365d739857caa158ee93514c06e94924377e71d0
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Changed structure of integration tests
---
phps-mode-test-integration.el | 61 ++++++++--------------------------------
phps-mode-test.el | 65 +++++++++++++++++++++++++++++++++++++++++--
2 files changed, 75 insertions(+), 51 deletions(-)
diff --git a/phps-mode-test-integration.el b/phps-mode-test-integration.el
index 999679b..2c80f8b 100644
--- a/phps-mode-test-integration.el
+++ b/phps-mode-test-integration.el
@@ -30,6 +30,7 @@
(autoload 'phps-mode-test-with-buffer "phps-mode-test")
+(autoload 'phps-mode-test-incremental-vs-intial-buffer "phps-mode-test")
(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")
@@ -42,71 +43,33 @@
(defun phps-mode-test-integration-incremental ()
"Test for object-oriented PHP file."
- (phps-mode-test-with-buffer
+ (phps-mode-test-incremental-vs-intial-buffer
"<?php\nnamespace myNamespace\n{\n class myClass\n {\n public
function myFunction()\n {\n echo 'my statement';\n }\n
}\n}\n"
- "Integration-test for regular PHP with namespaces, classes and functions"
+ "Integration-test 1 for regular PHP with namespaces, classes and functions"
- ;; Tokens
- ;; (message "Tokens %s" phps-mode-lexer-tokens)
- (should (equal (phps-mode-lexer-get-tokens) '((T_OPEN_TAG 1 . 7)
(T_NAMESPACE 7 . 16) (T_STRING 17 . 28) ("{" 29 . 30) (T_CLASS 35 . 40)
(T_STRING 41 . 48) ("{" 53 . 54) (T_PUBLIC 63 . 69) (T_FUNCTION 70 . 78)
(T_STRING 79 . 89) ("(" 89 . 90) (")" 90 . 91) ("{" 100 . 101) (T_ECHO 114 .
118) (T_CONSTANT_ENCAPSED_STRING 119 . 133) (";" 133 . 134) ("}" 143 . 144)
("}" 149 . 150) ("}" 151 . 152))))
-
- ;; Indentation
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (2
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))))
+ ;; Make changes
+ (goto-char 144)
+ (insert "\n\n public function myFunctionB()\n {\n
echo 'my second statement';\n }\n")
+ (should (equal (phps-mode-functions-get-buffer-changes-start) 144)))
- ;; Imenu
- (should (equal (phps-mode-functions-get-imenu) '(("\\myNamespace" . 17)
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunction()" . 79))))
+ (phps-mode-test-incremental-vs-intial-buffer
+ "<?php\nnamespace myNamespace\n{\n class myClass\n {\n public
function myFunction()\n {\n echo 'my statement';\n }\n
}\n}\n"
+ "Integration-test 2 for regular PHP with namespaces, classes and functions"
;; Make changes
(goto-char 144)
(insert "\n\n public function myFunctionB()\n {\n
echo 'my second statement';\n }\n")
-
- ;; Verify stored point of change
(should (equal (phps-mode-functions-get-buffer-changes-start) 144))
-
- ;; Run incremental lexer
(phps-mode-lexer-run-incremental)
- ;; TODO Should maybe change this to a more more simpler way
- ;; like compare lexer tokens, indent and imenu with same contents in a new
buffer
-
- ;; Tokens
- ;; (message "Tokens %s" (phps-mode-lexer-get-tokens))
- (should (equal (phps-mode-lexer-get-tokens) '((T_OPEN_TAG 1 . 7)
(T_NAMESPACE 7 . 16) (T_STRING 17 . 28) ("{" 29 . 30) (T_CLASS 35 . 40)
(T_STRING 41 . 48) ("{" 53 . 54) (T_PUBLIC 63 . 69) (T_FUNCTION 70 . 78)
(T_STRING 79 . 89) ("(" 89 . 90) (")" 90 . 91) ("{" 100 . 101) (T_ECHO 114 .
118) (T_CONSTANT_ENCAPSED_STRING 119 . 133) (";" 133 . 134) (";" 133 . 134)
("}" 143 . 144) (T_PUBLIC 154 . 160) (T_FUNCTION 161 . 169) (T_STRING 170 .
181) ("(" 181 . 182) (")" 182 . 183) ("{" 192 . 19 [...]
-
- ;; Indentation
- ;; (message "indent: %s" (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (2
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (2 0)) (11 (2 0)) (12 (2 0)) (13 (3 0))
(14 (2 0)) (15 (2 0)) (16 (1 0)) (17 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent))))
-
- ;; Imenu
- (should (equal (phps-mode-functions-get-imenu) '(("\\myNamespace" . 17)
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunction()" . 79)
("\\myNamespace\\myClass->myFunctionB()" . 170))))
-
;; Remove first function
(goto-char 55)
(push-mark nil t t)
(goto-char 145)
(execute-kbd-macro (kbd "<backspace>"))
+ (should (equal (phps-mode-functions-get-buffer-changes-start) 55)))
- ;; Verify stored point of change
- (should (equal (phps-mode-functions-get-buffer-changes-start) 55))
-
- ;; Run incremental lexer
- (phps-mode-lexer-run-incremental)
-
- ;; Tokens
- ;; (message "Tokens %s" (phps-mode-lexer-get-tokens))
- (should (equal (phps-mode-lexer-get-tokens) '((T_OPEN_TAG 1 . 7)
(T_NAMESPACE 7 . 16) (T_STRING 17 . 28) ("{" 29 . 30) (T_CLASS 35 . 40)
(T_STRING 41 . 48) ("{" 53 . 54) ("{" 53 . 54) (T_PUBLIC 64 . 70) (T_FUNCTION
71 . 79) (T_STRING 80 . 91) ("(" 91 . 92) (")" 92 . 93) ("{" 102 . 103) (T_ECHO
116 . 120) (T_CONSTANT_ENCAPSED_STRING 121 . 142) (";" 142 . 143) ("}" 152 .
153) ("}" 159 . 160) ("}" 161 . 162))))
-
- ;; Imenu
- (should (equal (phps-mode-functions-get-imenu) '(("\\myNamespace" . 17)
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunctionB()" . 80)
)))
-
- ;; Indentation
- (message "indent: %s" (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (2
0)) (7 (2 0)) (8 (2 0)) (9 (3 0)) (10 (2 0)) (11 (2 0)) (12 (1 0)) (13 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))))
-
-
- )
-
-)
+ )
(defun phps-mode-test-integration ()
"Run test for integration."
diff --git a/phps-mode-test.el b/phps-mode-test.el
index 1fd37a9..c95027b 100644
--- a/phps-mode-test.el
+++ b/phps-mode-test.el
@@ -1,6 +1,6 @@
;;; phps-mode-test.el --- Commons for tests -*- lexical-binding: t -*-
-;; Copyright (C) 2018 Christian Johansson
+;; Copyright (C) 2018-2019 Christian Johansson
;; This file is not part of GNU Emacs.
@@ -27,6 +27,67 @@
(autoload 'phps-mode "phps-mode")
+(autoload 'phps-mode-lexer-get-tokens "phps-mode-lexer")
+(autoload 'phps-mode-functions-get-imenu "phps-mode-functions")
+(autoload 'phps-mode-functions-get-lines-indent "phps-mode-functions")
+(autoload 'should "ert")
+
+(defmacro phps-mode-test-incremental-vs-intial-buffer (source &optional title
&rest change)
+ "Set up test buffer with SOURCE, TITLE, apply CHANGE and compare incremental
values with initial values."
+ `(let ((test-buffer-incremental (generate-new-buffer "test-incremental"))
+ (incremental-tokens nil)
+ (incremental-imenu nil)
+ (incremental-indent nil)
+ (incremental-buffer nil)
+ (test-buffer-initial (generate-new-buffer "test-initial"))
+ (initial-tokens nil)
+ (initial-imenu nil)
+ (initial-indent nil)
+ (initial-buffer nil))
+
+ ;; Setup incremental buffer
+ (switch-to-buffer test-buffer-incremental)
+ (insert ,source)
+ (goto-char 0)
+ (when (and (boundp 'phps-mode-functions-verbose)
+ phps-mode-functions-verbose)
+ (message "\nTesting incremental buffer '%s':\n'%s'\n" ,title ,source))
+ (phps-mode)
+ ,@change
+ (phps-mode-lexer-run-incremental)
+ (setq incremental-tokens (phps-mode-lexer-get-tokens))
+ (setq incremental-imenu (phps-mode-functions-get-imenu))
+ (setq incremental-indent (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
+ (setq incremental-buffer (buffer-substring-no-properties (point-min)
(point-max)))
+ (kill-buffer test-buffer-incremental)
+
+ ;; Setup incremental buffer
+ (switch-to-buffer test-buffer-initial)
+ (insert incremental-buffer)
+ (goto-char 0)
+ (when (and (boundp 'phps-mode-functions-verbose)
+ phps-mode-functions-verbose)
+ (message "\nTesting initial buffer '%s':\n'%s'\n" ,title
incremental-buffer))
+ (phps-mode)
+ (setq initial-tokens (phps-mode-lexer-get-tokens))
+ (setq initial-imenu (phps-mode-functions-get-imenu))
+ (setq initial-indent (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
+ (setq initial-buffer (buffer-substring-no-properties (point-min)
(point-max)))
+ (kill-buffer test-buffer-initial)
+
+ ;; Run tests
+ (when (and (boundp 'phps-mode-functions-verbose)
+ phps-mode-functions-verbose)
+ (message "\nComparing tokens, lines indent and imenu between
buffer:\n\n'%s'\n\nand:\n\n'%s'\n" initial-buffer incremental-buffer))
+ (should (equal initial-buffer incremental-buffer))
+ ;; (message "Initial tokens: %s\n" initial-tokens)
+ ;; (message "Incremental tokens: %s\n" incremental-tokens)
+ (should (equal initial-tokens incremental-tokens))
+ (should (equal initial-indent incremental-indent))
+ (should (equal initial-imenu incremental-imenu))
+
+ (when ,title
+ (message "\nPassed incremental tests for '%s'\n" ,title))))
(defmacro phps-mode-test-with-buffer (source &optional title &rest body)
"Set up test buffer with SOURCE, TITLE and BODY."
@@ -36,7 +97,7 @@
(goto-char 0)
(when (and (boundp 'phps-mode-functions-verbose)
phps-mode-functions-verbose)
- (message "\nTesting buffer:\n'%s'\n" ,source))
+ (message "\nTesting buffer '%s':\n'%s'\n" ,title ,source))
(phps-mode)
,@body
(kill-buffer test-buffer)
- [elpa] externals/phps-mode a30e5ff 331/405: Run incremental lexer when processing file if buffer change, (continued)
- [elpa] externals/phps-mode a30e5ff 331/405: Run incremental lexer when processing file if buffer change, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e9475f7 321/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 55b3087 333/405: Optimized lexer calling, do not call when using (indent-line), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a309998 326/405: Integration tests passes with new function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c37b234 334/405: Added failing test for indent in concatenated string inside function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8109c1a 328/405: (uncomment-region) working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9e62157 338/405: (comment-region) and (uncomment-region) now handles part of lines as well as full lines, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 091ab21 340/405: Passes new unit test for indentation of concatenated equal and multiplication equal assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d27af61 327/405: Fixed bug with incremental lexer were states are missing, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 32f9808 329/405: indent and imenu now triggers incremental lexer if buffer changed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 365d739 324/405: Changed structure of integration tests,
Stefan Monnier <=
- [elpa] externals/phps-mode 2807902 343/405: Added syntax coloring for %, =, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1bac28a 352/405: Updated readme with decreased percent for indent, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2801604 350/405: Added TODO item, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c80aa68 351/405: Added a new failing test for indentation of else expression inside switch, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a8fbe7d 344/405: Improved syntax coloring of =, % and more, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 64e1789 356/405: Fixed indentation were assignments end at next line, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 83d5de8 355/405: Removed uneccesary debug output in unit test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode abd78a0 359/405: Work on incremental newline logic, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d8ad25b 341/405: Passes new test indentation of multi-line double-arrow inside assignment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e7cb803 346/405: Added another indentation test, Stefan Monnier, 2019/07/13