branch: externals/phps-mode commit de771b5dd89820d1b98eb90b3a687b19b468320b Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Added more unit tests --- phps-test-lexer.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phps-test-lexer.el b/phps-test-lexer.el index 781668b..b2744cc 100644 --- a/phps-test-lexer.el +++ b/phps-test-lexer.el @@ -115,6 +115,17 @@ '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) ("[" 14 . 15) ("]" 15 . 16) (";" 16 . 17))))) (phps-mode/with-test-buffer + "<?php $var = ''; $var = 'abc'; " + (should (equal phps-mode/lexer-tokens + '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) (T_CONSTANT_ENCAPSED_STRING 14 . 16) (";" 16 . 17) (T_VARIABLE 18 . 22) ("=" 23 . 24) (T_CONSTANT_ENCAPSED_STRING 25 . 30) (";" 30 . 31))))) + + (phps-mode/with-test-buffer + "<?php $var = \"\"; $var = \"abc\"; $var = \"abc\\def\\ghj\";" + ;; (message "Tokens: %s" phps-mode/lexer-tokens) + (should (equal phps-mode/lexer-tokens + '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) (T_CONSTANT_ENCAPSED_STRING 14 . 16) (";" 16 . 17) (T_VARIABLE 18 . 22) ("=" 23 . 24) (T_CONSTANT_ENCAPSED_STRING 25 . 30) (";" 30 . 31) (T_VARIABLE 32 . 36) ("=" 37 . 38) (T_CONSTANT_ENCAPSED_STRING 39 . 52) (";" 52 . 53))))) + + (phps-mode/with-test-buffer "<?php echo isset($backtrace[1]['file']) ? 'yes' : 'no'; " (should (equal phps-mode/lexer-tokens '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_ISSET 12 . 17) ("(" 17 . 18) (T_VARIABLE 18 . 28) ("[" 28 . 29) (T_LNUMBER 29 . 30) ("]" 30 . 31) ("[" 31 . 32) (T_CONSTANT_ENCAPSED_STRING 32 . 38) ("]" 38 . 39) (")" 39 . 40) ("?" 41 . 42) (T_CONSTANT_ENCAPSED_STRING 43 . 48) (":" 49 . 50) (T_CONSTANT_ENCAPSED_STRING 51 . 55) (";" 55 . 56)))))