branch: externals/phps-mode commit d39152b89bff8f762f8b1b92b9fbbe58de3fb380 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Added unit test for NUM_STRING token inside double-quoted string --- phps-mode-lexer.el | 18 ++++++------------ phps-mode-test-functions.el | 2 +- phps-mode-test-lexer.el | 7 +++++++ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el index 45d7edf..f6e51809 100644 --- a/phps-mode-lexer.el +++ b/phps-mode-lexer.el @@ -1137,18 +1137,12 @@ (phps-mode-lexer-RETURN_TOKEN 'T_DNUMBER start end) (phps-mode-lexer-RETURN_TOKEN 'T_LNUMBER start end))))) - ;; TODO Implement this - ;; (phps-mode-lexer-re2c-rule - ;; (and ST_VAR_OFFSET (looking-at "\\([0]\\|\\([1-9][0-9]*\\)\\)")) - ;; (lambda() - ;; (let* ((start (match-beginning 0)) - ;; (end (match-end 0)) - ;; (data (buffer-substring-no-properties (+ start 2) end)) - ;; (long-number (string-to-number data 16))) - ;; ;; (message "Hexadecimal number %s from %s" long-number data) - ;; (if (> long-number phps-mode-lexer-long-limit) - ;; (phps-mode-lexer-RETURN_TOKEN 'T_DNUMBER start end) - ;; (phps-mode-lexer-RETURN_TOKEN 'T_LNUMBER start end))))) + (phps-mode-lexer-re2c-rule + (and ST_VAR_OFFSET (looking-at "\\([0]\\|[1-9][0-9]*\\)")) + (lambda() + (let ((start (match-beginning 0)) + (end (match-end 0))) + (phps-mode-lexer-RETURN_TOKEN 'T_NUM_STRING start end)))) (phps-mode-lexer-re2c-rule (and ST_VAR_OFFSET (looking-at (concat "\\(" diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index 29c1f35..f93e4d5 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -370,7 +370,7 @@ (phps-mode-test-with-buffer "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) {\necho $title3;\n\n}\n?>\n</title><body>Bla bla</body></html>" "Curly bracket test 4" - (message "Tokens: %s" (phps-mode-lexer-get-tokens)) + ;; (message "Tokens: %s" (phps-mode-lexer-get-tokens)) (goto-char 110) (phps-mode-functions-indent-line) (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) diff --git a/phps-mode-test-lexer.el b/phps-mode-test-lexer.el index e688032..22f6575 100644 --- a/phps-mode-test-lexer.el +++ b/phps-mode-test-lexer.el @@ -168,6 +168,13 @@ (should (equal (phps-mode-lexer-get-tokens) '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 16) ("=" 17 . 18) (T_VARIABLE 19 . 24) ("[" 24 . 25) (T_CONSTANT_ENCAPSED_STRING 25 . 31) ("]" 31 . 32) (T_COALESCE 33 . 35) (T_CONSTANT_ENCAPSED_STRING 36 . 44) (";" 44 . 45) (T_VARIABLE 46 . 51) (T_OBJECT_OPERATOR 51 . 53) (T_STRING 53 . 60) (T_OBJECT_OPERATOR 60 . 62) (T_STRING 62 . 66) ("[" 66 . 67) (T_CONSTANT_ENCAPSED_STRING 67 . 77) ("]" 77 . 78) ("[" 78 . 79) (T_CONSTANT_ENCAPSED_STRING 79 . 88) ("]" 88 . 89) (T_COALESCE_EQUA [...] + (phps-mode-test-with-buffer + "<?php\necho $array['abc'];\necho \"My $array[12] random statement\";\n" + "Long inside array offset" + (message "Tokens: %s" (phps-mode-lexer-get-tokens)) + (should (equal (phps-mode-lexer-get-tokens) + '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_VARIABLE 12 . 18) ("[" 18 . 19) (T_CONSTANT_ENCAPSED_STRING 19 . 24) ("]" 24 . 25) (";" 25 . 26) (T_ECHO 27 . 31) ("\"" 32 . 33) (T_ENCAPSED_AND_WHITESPACE 33 . 36) (T_VARIABLE 36 . 43) (T_NUM_STRING 43 . 45) ("]" 45 . 46) (T_CONSTANT_ENCAPSED_STRING 46 . 63) ("\"" 63 . 64) (";" 64 . 65))))) + ;; TODO Add test for long as var offset ;; (phps-mode-test-with-buffer