[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 253839f 170/405: Added indentation unit tests
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 253839f 170/405: Added indentation unit tests for concatenated strings outside assignments |
Date: |
Sat, 13 Jul 2019 10:00:06 -0400 (EDT) |
branch: externals/phps-mode
commit 253839f43e96871e877d6e11b229613de48abb1c
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added indentation unit tests for concatenated strings outside assignments
---
phps-mode-functions.el | 5 ++++-
phps-mode-test-functions.el | 39 ++++++++++++++++++++++++++++++++-------
2 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 52a1240..2de738d 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -94,7 +94,10 @@
(progn
;; Flag when last token was on a new line
- (when (= token-number last-token-number)
+ (when (and
+ (= token-number last-token-number)
+ (> token-start-line-number last-line-number))
+ ;; (message "Token %s was first on line and last last
token" token)
(setq last-token-was-first-on-new-line t))
;; Calculate indentation level at end of line
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index aa035ed..27763fb 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -97,7 +97,7 @@
(phps-mode-test-with-buffer
"<?php\n$str = <<<EOD\nExample of string\nspanning multiple lines\nusing
heredoc syntax.\nEOD;\n"
- "Multi-line HEREDOC string"
+ "Multi-line HEREDOC string in assignment"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
@@ -119,14 +119,39 @@
;; (message "Tokens: %s" phps-mode-lexer-tokens)
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
- ;; TODO Test concatenated string outside assignments
- ;; TODO Test HEREDOC outside assignment
- ;; TODO Test multi-line single-quoted string outside assignment
- ;; TODO Test multi-line double-quoted string outside assignment
+ (phps-mode-test-with-buffer
+ "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition)
{\necho $title2;\n\n} ?></title><body>Bla bla</body></html>"
+ "Mixed HTML/PHP 2"
+ (message "Tokens: %s" phps-mode-lexer-tokens)
+ (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (5 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
- )
+ ;; NOTE Maybe concatenated strings spanning multiple lines outside
assignments should have indentation?
+
+ (phps-mode-test-with-buffer
+ "<?php\necho \"A line\" .\n \"more text here\" .\n \"last line
here\";"
+ "Concatenated double-quoted-string spanning multiple-lines"
+ ;; (message "Tokens: %s" phps-mode-lexer-tokens)
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
-;; TODO Add unit tests for HEREDOC and NOWDOC regions as well
+ (phps-mode-test-with-buffer
+ "<?php\necho 'A line' .\n 'more text here' .\n 'last line here';"
+ "Concatenated single-quoted-string spanning multiple-lines"
+ ;; (message "Tokens: %s" phps-mode-lexer-tokens)
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+
+ (phps-mode-test-with-buffer
+ "<?php\n$var = 'A line' .\n 'more text here' .\n 'last line here';"
+ "Concatenated single-quoted-string multiple-lines in assignment"
+ ;; (message "Tokens: %s" phps-mode-lexer-tokens)
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+
+ (phps-mode-test-with-buffer
+ "<?php\necho <<<EOD\nExample of string\nspanning multiple lines\nusing
heredoc syntax.\nEOD;\n"
+ "Multi-line HEREDOC string outside assignment"
+ ;; (message "Tokens: %s" phps-mode-lexer-tokens)
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+
+ )
(defun phps-mode-test-functions-indent-line ()
"Test for indentation."
- [elpa] externals/phps-mode 0286660 224/405: Indentation passes new tests for concatenated strings, (continued)
- [elpa] externals/phps-mode 0286660 224/405: Indentation passes new tests for concatenated strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f05d40a 230/405: Tests for lexer passes again after close_tag modification, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1bc5713 227/405: New tests for concatenation passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c71a97d 178/405: Started on refactored indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8bb3918 249/405: Clean-up of unit test logging, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9201d1c 246/405: Imenu index now handles functions with optional arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2c3239a 187/405: Adding new failing tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d9a0119 183/405: Optimized indentation code by removing unused variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a0cbcd1 186/405: More work on indentation of multi-line IF-expressions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d7c5f67 190/405: More work on nesting-stack, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 253839f 170/405: Added indentation unit tests for concatenated strings outside assignments,
Stefan Monnier <=
- [elpa] externals/phps-mode e38794b0 197/405: More conceptual work on algorithm for inline control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9db28d9 185/405: Added verbose flag for unit tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2a1ed52 196/405: Optimized algorithm for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a30c3f6 177/405: More work on indentation tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e8a8d41 204/405: Merged remote changes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode faa4e00 201/405: Started on conceptually describing algorithm for multi-line assignment indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 874701d 195/405: Work on alternative and inline control structure syntax with new algorithm, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ec69d07 193/405: Added a failing class declaration indentation case, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 164b77e 205/405: Unit test for alternative control syntax passes with new algorithm, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e8658c8 192/405: New indentation algorithm now passes class unit tests, started on indentation document, Stefan Monnier, 2019/07/13