branch: externals/phps-mode
commit b5c64c195f647d81859f33613d2830c5f245fe4e
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Added failing tests for HEREDOC and NOWDOC assignments
---
phps-mode-functions.el | 3 ++-
phps-mode-test-functions.el | 23 +++++++++++++++++++++--
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index eba2a3f..37d38ab 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -129,9 +129,10 @@
(puthash last-line-number `(,column-level ,tuning-level)
line-indents))
(when (> token-end-line-number token-start-line-number)
- ;; (message "Token %s starts at %s and ends at %s" token
token-start-line-number token-end-line-number)
+ (message "Token %s starts at %s and ends at %s" token
token-start-line-number token-end-line-number)
(when (equal token 'T_DOC_COMMENT)
(setq tuning-level 1))
+
(let ((token-line-number-diff (1- (-
token-end-line-number token-start-line-number))))
(while (>= token-line-number-diff 0)
(puthash (- token-end-line-number
token-line-number-diff) `(,column-level ,tuning-level) line-indents)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 476869a..d0d6d5d 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -89,12 +89,31 @@
;; (message "Tokens: %s" phps-mode-lexer-tokens)
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (1 0)) (6 (1
0)) (7 (1 0)) (8 (1 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (phps-mode-test-with-buffer
+ "<?php\n$str = <<<'EOD'\nExample of string\nspanning multiple lines\nusing
nowdoc syntax.\nEOD;\n"
+ "Multi-line NOWDOC string"
+ (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)))))
+
+ (phps-mode-test-with-buffer
+ "<?php\n$str = <<<EOD\nExample of string\nspanning multiple lines\nusing
heredoc syntax.\nEOD;\n"
+ "Multi-line HEREDOC string"
+ (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)))))
;; TODO NOWDOC
- ;; TODO HEREDOC
+(phps-mode-test-with-buffer
+ "<?php\n$var = \"A line\nmore text here\nlast line here\";"
+ "Multi-line double-quoted string"
+ (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 Multi-line single-quoted string
+ (phps-mode-test-with-buffer
+ "<?php\n$var = 'A line\nmore text here\nlast line here';"
+ "Multi-line single-quoted string"
+ (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 Multi-line double-quoted strings