branch: externals/phps-mode commit baab77ae322c60e9a14e8471374c3c07fb09081b Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Unit tests for inline control structures working --- phps-mode-functions.el | 18 ++++++++++-------- phps-mode-test-functions.el | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index a443b10..d23d06d 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -226,7 +226,8 @@ (found-line-tokens nil) (after-special-control-structure nil) (round-brace-level 0) - (expecting-semi-colon nil) + (start-expecting-semi-colon nil) + (end-expecting-semi-colon nil) (first-token-on-line nil)) (catch 'stop-iteration (dolist (item phps-mode-lexer-tokens) @@ -277,10 +278,10 @@ (setq start-alternative-control-structure-level (- start-alternative-control-structure-level 1))) ;; Reduce inline control structure level when we encounter a semi-colon after it's opening - (when (and expecting-semi-colon + (when (and start-expecting-semi-colon (string= token ";")) (setq start-inline-control-structure-level (- start-inline-control-structure-level 1)) - (setq expecting-semi-colon nil)) + (setq start-expecting-semi-colon nil)) ) @@ -321,10 +322,10 @@ (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 - (when (and expecting-semi-colon + (when (and end-expecting-semi-colon (string= token ";")) (setq end-inline-control-structure-level (- end-inline-control-structure-level 1)) - (setq expecting-semi-colon nil)) + (setq end-expecting-semi-colon nil)) ) @@ -367,12 +368,13 @@ (when (or (<= token-end line-beginning) (= first-token-on-line end-token-number)) - (setq start-inline-control-structure-level (+ start-inline-control-structure-level 1))) + (setq start-inline-control-structure-level (+ start-inline-control-structure-level 1)) + (setq start-expecting-semi-colon t)) (when (<= token-start line-end) - (setq end-inline-control-structure-level (+ end-inline-control-structure-level 1))) + (setq end-inline-control-structure-level (+ end-inline-control-structure-level 1)) + (setq end-expecting-semi-colon t)) - (setq expecting-semi-colon t) (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 453462e..3902c5e 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -343,17 +343,17 @@ (phps-mode-test-with-buffer "<?php\nif ($myCondition)\n echo 'was here';\necho 'was here 2';\n" (goto-char 60) - (should (equal (list (list t 0 0 0 0 0 4 nil) (list t 0 0 0 0 0 7 nil)) (phps-mode-functions-get-point-data)))) + (should (equal (list (list t 0 0 0 0 0 7 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'; echo 'was here 2';\n" (goto-char 32) - (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 0 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'; echo 'was here 2';\n" (goto-char 55) - (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 0 nil) (list t 0 0 0 0 0 10 nil)) (phps-mode-functions-get-point-data)))) ;; TODO ALTERNATIVE SYNTAX