[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 310521b 254/405: Started with first integrati
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 310521b 254/405: Started with first integration-test |
Date: |
Sat, 13 Jul 2019 10:00:26 -0400 (EDT) |
branch: externals/phps-mode
commit 310521b9ccc6d66780b637ca6917fa6e85835fff
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Started with first integration-test
---
phps-mode-test-functions.el | 103 ++++++++++++++++++++----------------------
phps-mode-test-integration.el | 34 +++++++++++++-
phps-mode-test.el | 9 ++++
3 files changed, 89 insertions(+), 57 deletions(-)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index e0ffb1a..995bcab 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -33,16 +33,9 @@
(autoload 'phps-mode-functions-verbose "phps-mode-functions")
(autoload 'phps-mode-functions-indent-line "phps-mode-functions")
(autoload 'phps-mode-functions-get-lines-indent "phps-mode-functions")
+(autoload 'phps-mode-test-hash-to-list "phps-mode-test")
(autoload 'should "ert")
-(defun phps-mode-test-functions--hash-to-list (hash-table)
- "Return a list that represent the HASH-TABLE. Each element is a list: (list
key value)."
- (let (result)
- (maphash
- (lambda (k v)
- (push (list k v) result))
- hash-table)
- (sort (nreverse result) (lambda (a b) (< (car a) (car b))))))
(defun phps-mode-test-functions-get-lines-indent ()
"Test `phps-mode-functions-get-lines-indent' function."
@@ -50,119 +43,119 @@
(phps-mode-test-with-buffer
"<?php\n/**\n * Bla\n */"
"DOC-COMMENT"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nmyFunction(array(\n 23,\n [\n 25\n ]\n )\n);"
"Round and square bracket expressions"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (2 0)) (6 (1
0)) (7 (1 0)) (8 (0 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (2 0)) (6 (1
0)) (7 (1 0)) (8 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nvar_dump(array(<<<EOD\nfoobar!\nEOD\n));\n?>"
"HEREDOC in arguments example"
;; (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)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-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)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(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 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(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 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho \"A line\" .\n \"more text here\" .\n \"last line
here\";"
"Concatenated double-quoted-string spanning multiple-lines"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho myFunction(\"A line\" .\n \"more text here\" .\n \"last
line here\");"
"Concatenated double-quoted-string spanning multiple-lines inside function"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho \"A line\"\n . \"more text here\"\n . \"last line
here\";"
"Concatenated double-quoted-string spanning multiple-lines 2"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho myFunction(\"A line\" .\n \"more text here\" .\n \"last
line here\");"
"Concatenated double-quoted-string spanning multiple-lines inside function
2"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho 'A line' .\n 'more text here' .\n 'last line here';"
"Concatenated single-quoted-string spanning multiple-lines"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho myFunction('A line' .\n 'more text here' .\n 'last line
here');"
"Concatenated single-quoted-string spanning multiple-lines inside function"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho 'A line'\n . 'more text here'\n . 'last line here';"
"Concatenated single-quoted-string spanning multiple-lines 2"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho myFunction('A line'\n . 'more text here'\n . 'last line
here');"
"Concatenated single-quoted-string spanning multiple-lines inside function
2"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\necho <<<EOD\nExample of string\nspanning multiple lines\nusing
heredoc syntax.\nEOD;\n"
"Multi-line HEREDOC string outside assignment"
;; (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)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\n/**\n * @var string\n */\necho 'was here';\n"
"Statement after doc-comment"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)) (5 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)) (5 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\n/** @define _SYSTEM_START_TIME_ Startup time for system
*/\ndefine('_SYSTEM_START_TIME_', microtime(true));\necho 'statement';\n"
"Statement after a define() with a doc-comment"
- (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)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nfunction myFunction($parameters = null)\n{\n echo
'statement';\n}\n"
"Statement after one-lined function declaration with optional argument"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php if (true) { ?>\n <?php echo 'here'; ?>\n<?php } ?>"
"Regular if-expression but inside scripting tags"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (1 0)) (3 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (1 0)) (3 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\ndo {\n echo 'true';\n} while ($number > 0\n && $letter >
0\n);"
"Do while loop with multi-line condition"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
)
@@ -173,31 +166,31 @@
"<?php\n$variable = array(\n 'random4'\n);\n$variable = true;\n"
"Array assignment on three lines"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\n$variable = array(\n 'random4');\n$variable = true;\n"
"Array assignment on two lines"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) )
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) )
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\n$var = 'A line' .\n 'more text here' .\n 'last line here';"
"Concatenated single-quoted-string multiple-lines in assignment"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)))
(phps-mode-test-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 in assignment"
;; (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)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\n$var =\n 500 .\n \"200\" .\n 100.0 .\n '200' .\n
$this->getTail()\n ->getBottom();"
"Multi-line assignments"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (2
0)) (7 (2 0)) (8 (1 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (2
0)) (7 (2 0)) (8 (1 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
)
@@ -207,17 +200,17 @@
(phps-mode-test-with-buffer
"<?php\nif (true)\n echo 'Something';\nelse\n echo 'Something
else';\necho true;\n"
"Inline control structures if else"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (true)\n echo 'Something';\nelse if (true)\n echo
'Something else';\necho true;\n"
"Inline control structures if else if"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nwhile (true)\n echo 'Something';"
"Inline control structures while"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
)
@@ -227,17 +220,17 @@
(phps-mode-test-with-buffer
"<?php\nif (true):\n echo 'Something';\nelseif (true):\n echo
'Something';\nelse:\n echo 'Something else';\n echo 'Something else
again';\nendif;\necho true;\n"
"Alternative control structures"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0)) (7 (1 0)) (8 (1 0)) (9 (0 0)) (10 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0)) (7 (1 0)) (8 (1 0)) (9 (0 0)) (10 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (true):\n echo 'Something';\nelseif (true\n && true\n):\n
echo 'Something';\nelse:\n echo 'Something else';\n echo 'Something
else again';\nendif;\necho true;\n"
"Alternative control structures with multi-line elseif 1"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0)) (7 (1 0)) (8 (0 0)) (9 (1 0)) (10 (1 0)) (11 (0 0)) (12 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0)) (7 (1 0)) (8 (0 0)) (9 (1 0)) (10 (1 0)) (11 (0 0)) (12 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (true):\n echo 'Something';\nelseif (true\n && true):\n
echo 'Something';\nelse:\n echo 'Something else';\n echo 'Something else
again';\nendif;\necho true;\n"
"Alternative control structures with multi-line elseif 2"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (1
0)) (7 (0 0)) (8 (1 0)) (9 (1 0)) (10 (0 0)) (11 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (1
0)) (7 (0 0)) (8 (1 0)) (9 (1 0)) (10 (0 0)) (11 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
)
@@ -247,30 +240,30 @@
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace\n{\n class myClass\n {\n public
function myFunction()\n {\n echo 'my statement';\n }\n
}\n}\n"
"Regular PHP with namespaces, classes and functions"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (2
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (2
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace\n{\n class myClass {\n public
function myFunction()\n {\n echo 'my statement';\n }\n
}\n}\n"
"Regular PHP with namespaces, classes and functions"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (2 0)) (6 (2
0)) (7 (3 0)) (8 (2 0)) (9 (1 0)) (10 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (2 0)) (6 (2
0)) (7 (3 0)) (8 (2 0)) (9 (1 0)) (10 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nclass MyClass extends MyAbstract implements\n myInterface,\n
myInterface2\n{\n}\n"
"Class multi-line implements"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nclass MyClass\n extends MyAbstract\n implements myInterface,
myInterface2\n{\n}\n"
"Class multi-line extends and implements"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\n/**\n *\n */\nnamespace Aomebo\n{\n /**\n *\n */\n
class Base\n {\n }\n}\n"
"Namespace and class with doc-comments"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)) (5 (0 0)) (6 (0
0)) (7 (1 0)) (8 (1 1)) (9 (1 1)) (10 (1 0)) (11 (1 0)) (12 (1 0)) (13 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)) (5 (0 0)) (6 (0
0)) (7 (1 0)) (8 (1 1)) (9 (1 1)) (10 (1 0)) (11 (1 0)) (12 (1 0)) (13 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
)
@@ -281,54 +274,54 @@
"<?php\nif (\n true\n && true\n) {\n echo 'was here';\n}\n"
"If expression spanning multiple lines 1"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (0 0)) (6 (1
0)) (7 (0 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (0 0)) (6 (1
0)) (7 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\n// Can we load configuration?\nif ($configuration::load(\n
self::getParameter(self::PARAMETER_CONFIGURATION_INTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_CONFIGURATION_EXTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_STRUCTURE_INTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_STRUCTURE_EXTERNAL_FILENAME)\n)) {\n echo
'was here';\n}\n"
"If expression spanning multiple lines 2"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (1
0)) (7 (1 0)) (8 (0 0)) (9 (1 0)) (10 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (1
0)) (7 (1 0)) (8 (0 0)) (9 (1 0)) (10 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (true) {\n if ($configuration::load(\n
self::getParameter(self::PARAMETER_CONFIGURATION_INTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_CONFIGURATION_EXTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_STRUCTURE_INTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_STRUCTURE_EXTERNAL_FILENAME))\n ) {\n
echo 'was here';\n }\n}\n"
"If expression spanning multiple lines 3"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (2
0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (2
0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (myFunction(true)\n) {\n echo 'was here';\n}\n"
"If expression spanning multiple lines 4"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (myFunction(\n true)\n) {\n echo 'was here';\n}\n"
"If expression spanning multiple lines 5"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (true) {\n if (myFunction(\n true)\n ) {\n
echo 'was here';\n }\n}\n"
"Nested if expression spanning multiple lines 6"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (2
0)) (7 (1 0)) (8 (0 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (2
0)) (7 (1 0)) (8 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<html><head><title><?php if ($myCondition) {\n if ($mySeconCondition)
{\n echo $title2;\n\n } ?></title><body>Bla bla</body></html>"
"Mixed HTML/PHP with if expression and token-less lines"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (4 (2 0)) (5 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (4 (2 0)) (5 (1 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<html><head><title><?php\nif ($myCondition) {\n if ($mySecondCondition)
{\n echo $title;\n } else if ($mySecondCondition) {\n echo
$title4;\n } else {\n echo $title2;\n echo $title3;\n }\n}
?></title><body>Bla bla</body></html>"
"Mixed HTML/PHP with if expression 2"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (2
0)) (7 (1 0)) (8 (2 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (2
0)) (7 (1 0)) (8 (2 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (myFirstCondition()) {\n $this->var = 'abc123';\n} else {\n
$this->var = 'def456';\n}\n"
"Regular else expression indent calculation"
;; (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (0 0)) (5 (1 0)) (6 (0
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
)
@@ -338,12 +331,12 @@
(phps-mode-test-with-buffer
"<?php\nswitch ($condition) {\n case true:\n echo 'here';\n
echo 'here 2';\n case false:\n echo 'here 4';\n default:\n
echo 'here 3';\n}\n"
"Switch, case, default"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (1
0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (1
0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nswitch ($condition):\n case true:\n echo 'here';\n
echo 'here 2';\n case false:\n echo 'here 4';\n default:\n
echo 'here 3';\nendswitch;\n"
"Switch, case, default with alternative control structure"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (1
0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (1
0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
)
diff --git a/phps-mode-test-integration.el b/phps-mode-test-integration.el
index 662526e..9d865e7 100644
--- a/phps-mode-test-integration.el
+++ b/phps-mode-test-integration.el
@@ -30,17 +30,47 @@
(autoload 'phps-mode-test-with-buffer "phps-mode-test")
-(autoload 'phps-mode-functions-verbose "phps-mode-functions")
(autoload 'phps-mode-functions-indent-line "phps-mode-functions")
(autoload 'phps-mode-functions-get-lines-indent "phps-mode-functions")
+(autoload 'phps-mode-functions-get-imenu "phps-mode-functions")
+(autoload 'phps-mode-test-hash-to-list "phps-mode-test")
(autoload 'should "ert")
+(defun phps-mode-test-integration-incremental ()
+ "Test for object-oriented PHP file."
+
+ (phps-mode-test-with-buffer
+ "<?php\nnamespace myNamespace\n{\n class myClass\n {\n public
function myFunction()\n {\n echo 'my statement';\n }\n
}\n}\n"
+ "Regular PHP with namespaces, classes and functions"
+
+ ;; Tokens
+ (when (and (boundp 'phps-mode-lexer-tokens)
+ phps-mode-lexer-tokens)
+ ;; (message "Tokens %s" phps-mode-lexer-tokens)
+ (should (equal phps-mode-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_NAMESPACE 7
. 16) (T_STRING 17 . 28) ("{" 29 . 30) (T_CLASS 35 . 40) (T_STRING 41 . 48)
("{" 53 . 54) (T_PUBLIC 63 . 69) (T_FUNCTION 70 . 78) (T_STRING 79 . 89) ("("
89 . 90) (")" 90 . 91) ("{" 100 . 101) (T_ECHO 114 . 118)
(T_CONSTANT_ENCAPSED_STRING 119 . 133) (";" 133 . 134) ("}" 143 . 144) ("}" 149
. 150) ("}" 151 . 152)))))
+
+ ;; Indentation
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (2
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (1 0)) (11 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))))
+
+ ;; Imenu
+ (should (equal (phps-mode-functions-get-imenu) '(("\\myNamespace" . 17)
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunction()" . 79))))
+
+ ;; TODO Make changes
+
+ ;; TODO New test for tokens
+ ;; TODO New test for indentation
+ ;; TODO new test for Imenu
+ )
+
+)
+
(defun phps-mode-test-integration ()
"Run test for integration."
;; (setq debug-on-error t)
;; (setq phps-mode-functions-verbose t)
- (message "Integration tests here")
+ (phps-mode-test-integration-incremental)
+
)
(phps-mode-test-integration)
diff --git a/phps-mode-test.el b/phps-mode-test.el
index 482df9d..1fd37a9 100644
--- a/phps-mode-test.el
+++ b/phps-mode-test.el
@@ -43,6 +43,15 @@
(when ,title
(message "\nPassed tests for '%s'\n" ,title))))
+(defun phps-mode-test-hash-to-list (hash-table)
+ "Return a list that represent the HASH-TABLE. Each element is a list: (list
key value)."
+ (let (result)
+ (maphash
+ (lambda (k v)
+ (push (list k v) result))
+ hash-table)
+ (sort (nreverse result) (lambda (a b) (< (car a) (car b))))))
+
(provide 'phps-mode-test)
;;; phps-mode-test.el ends here
- [elpa] externals/phps-mode c2db7d3 250/405: Preparations for integration test, (continued)
- [elpa] externals/phps-mode c2db7d3 250/405: Preparations for integration test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 11309b8 256/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode fcc920f 258/405: More preparations for merging indent and Imenu into one function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 41c12c1 251/405: Updated paths for byte-compilation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0e927e8 252/405: Fixed compilation command in makefile, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6593242 257/405: Preparations for doing indentation and imenu in one pass, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 318001e 259/405: Merged Imenu and indentation generation into one iteration of tokens, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5bb45ce 253/405: Added lexer test for properties inside heredoc, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode caafeba 260/405: Changed idle interval for incremental lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c7ad55c 255/405: Passed first integration-test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 310521b 254/405: Started with first integration-test,
Stefan Monnier <=
- [elpa] externals/phps-mode d39152b 279/405: Added unit test for NUM_STRING token inside double-quoted string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 44a997e 270/405: Added syntax coloring for "." tokens, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode aa0c23d 263/405: Updated font-locks for token color syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b86dd54 262/405: Indentation now supports new lexer token T_INLINE HTML, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2c8f28c 275/405: Added docstrings to variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c9f0254 271/405: Fixed some minor flycheck complains in lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 68ef657 280/405: Removed debugging output from unit tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 40bffbc 265/405: Added syntax coloring for [ )( ,, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9deb882 266/405: Added syntax coloring for ? ! < > :, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 969a4d1 278/405: Fixed syntax for coalesce assignment operator, Stefan Monnier, 2019/07/13