[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 60c7431 122/405: Unit tests for gather data a
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 60c7431 122/405: Unit tests for gather data about inline and alternative control structure syntax passes |
Date: |
Sat, 13 Jul 2019 09:59:57 -0400 (EDT) |
branch: externals/phps-mode
commit 60c74316e8909116eca4023eaf01627310d8e113
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Unit tests for gather data about inline and alternative control structure
syntax passes
---
phps-mode-functions.el | 26 +++++++++++++++++---------
phps-mode-test-functions.el | 14 +++++++-------
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index d23d06d..f6175d5 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -313,12 +313,25 @@
(")" (setq end-round-bracket-level (-
end-round-bracket-level 1)))
(_))
+ ;; Do we encounter first token on line?
+ (when (and (not first-token-on-line)
+ (>= token-start line-beginning)
+ (<= token-start line-end))
+ (setq first-token-on-line end-token-number))
+
+
;; Did we encounter end of alternative control structure?
(when (or (equal token 'T_ENDIF)
(equal token 'T_ENDWHILE)
(equal token 'T_ENDFOR)
(equal token 'T_ENDFOREACH)
(equal token 'T_ENDSWITCH))
+
+ ;; If this was the first token on line decrement start
+ (when (and first-token-on-line
+ (= first-token-on-line end-token-number))
+ (setq start-alternative-control-structure-level (-
start-alternative-control-structure-level 1)))
+
(setq end-alternative-control-structure-level (-
end-alternative-control-structure-level 1)))
;; Reduce inline control structure level when we encounter a
semi-colon after it's opening
@@ -329,12 +342,6 @@
)
- ;; Do we encounter first token on line?
- (when (and (not first-token-on-line)
- (>= token-start line-beginning)
- (<= token-start line-end))
- (setq first-token-on-line end-token-number))
-
;; Keep track of general round brace level
(when (string= token "(")
(setq round-brace-level (+ round-brace-level 1)))
@@ -351,10 +358,10 @@
;; Is token not a curly bracket - because that is a ordinary
control structure syntax
(when (not (string= token "{"))
- (message "After special control structure %s in buffer: %s
tokens: %s token-start: %s" token (buffer-substring-no-properties (point-min)
(point-max)) phps-mode-lexer-tokens token-start)
+ ;; (message "After special control structure %s in buffer:
%s tokens: %s token-start: %s" token (buffer-substring-no-properties
(point-min) (point-max)) phps-mode-lexer-tokens token-start)
(if (string= token ":")
(progn
- (message "Was colon")
+ ;; (message "Was colon")
;; Is token at or before line beginning?
(when (<= token-end line-beginning)
@@ -375,7 +382,8 @@
(setq end-inline-control-structure-level (+
end-inline-control-structure-level 1))
(setq end-expecting-semi-colon t))
- (message "Was not colon")))
+ ;; (message "Was not colon")
+ ))
(setq after-special-control-structure nil))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 3902c5e..98101be 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -360,22 +360,22 @@
(phps-mode-test-with-buffer
"<?php\nif ($myCondition):\n echo 'was here';\nendif;\necho 'was here
2';\n"
(goto-char 41)
- (should (equal (list (list t 0 0 0 0 1 4 nil) (list t 0 0 0 0 0 8 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 1 5 nil) (list t 0 0 0 0 1 8 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
- "<?php\nif ($myCondition):\n echo 'was here';\nendif;\necho 'was here
2';\n"
+ "<?php\nif ($myCondition):\n echo 'was here';\nendif;\necho 'was here
3';\n"
(goto-char 52)
- (should (equal (list (list t 0 0 0 0 0 4 nil) (list t 0 0 0 0 0 8 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 0 8 nil) (list t 0 0 0 0 0 10 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
- "<?php\nif ($myCondition): echo 'was here';\nendif;\necho 'was here
2';\n"
+ "<?php\nif ($myCondition): echo 'was here';\nendif;\necho 'was here
4';\n"
(goto-char 32)
- (should (equal (list (list t 0 0 0 1 0 4 nil) (list t 0 0 0 0 0 8 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 0 0 nil) (list t 0 0 0 0 1 8 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
- "<?php\nif ($myCondition): echo 'was here'; endif; echo 'was here 2';\n"
+ "<?php\nif ($myCondition): echo 'was here'; endif; echo 'was here 5';\n"
(goto-char 35)
- (should (equal (list (list t 0 0 0 0 1 4 nil) (list t 0 0 0 0 0 8 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 0 0 nil) (list t 0 0 0 0 0 13 nil))
(phps-mode-functions-get-point-data))))
)
- [elpa] externals/phps-mode 41ef691 112/405: Fixed lint warning of unused variables, (continued)
- [elpa] externals/phps-mode 41ef691 112/405: Fixed lint warning of unused variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 12c22ee 119/405: More work on alternative and inline meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7e2e902 126/405: Fixed a unit test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 80da137 114/405: Preparations for adding alternative and inline syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode baab77a 121/405: Unit tests for inline control structures working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0dc652 143/405: More work on new indentation function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7dca537 105/405: Started work on renaming files, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e11a1fc 123/405: Fine-tuning of logic collecting data about inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e206605 115/405: Adding failing unit tests for inline and alternative syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6aa633 118/405: More work on keeping track of alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 60c7431 122/405: Unit tests for gather data about inline and alternative control structure syntax passes,
Stefan Monnier <=
- [elpa] externals/phps-mode 897f249 124/405: Work on alternative and inline indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be35ed6 127/405: Added sample files for inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7279913 113/405: Improved TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a8eadfa 130/405: Improved sample files inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9996ae0 146/405: More work on indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3776841 138/405: Added new support for tracking doc-comment, HEREDOC and NOWDOC indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 780d065 125/405: Code styling updates, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 314dba1 135/405: Improved articulation of what information get-current-line-data should return, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0523b7 137/405: More work on new function to calculate indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 16d8056 144/405: Foundation for new indentation tests completed, Stefan Monnier, 2019/07/13