[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 00d3568 290/405: Added indentation examples f
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 00d3568 290/405: Added indentation examples from official PSR-2 |
Date: |
Sat, 13 Jul 2019 10:00:34 -0400 (EDT) |
branch: externals/phps-mode
commit 00d356816ba166e84f0d870585c6bb8c801e87cd
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added indentation examples from official PSR-2
---
phps-mode-test-functions.el | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index c0c63be..d176cf3 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -161,6 +161,10 @@
"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-hash-to-list (phps-mode-functions-get-lines-indent)))))
+
+ ;; TODO Fix below
+
+
(phps-mode-test-with-buffer
"<?php\n$myVar = 'blaha'\n . 'ijeije' . __(\n 'okeoke'\n )\n
. 'okeoke';\n?>"
"Concatenated assignment string with function call"
@@ -171,8 +175,34 @@
"Concatenated echo string with function call"
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (1
0)) (7 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ )
+
+(defun phps-mode-test-functions-get-lines-indent-psr-2 ()
+ "Test PSR-2 examples from: https://www.php-fig.org/psr/psr-2/"
+
+ (phps-mode-test-with-buffer
+ "<?php\nnamespace Vendor\\Package;\n\nuse FooInterface;\nuse BarClass as
Bar;\nuse OtherVendor\\OtherPackage\\BazClass;\n\nclass Foo extends Bar
implements FooInterface\n{\n public function sampleMethod($a, $b = null)\n
{\n if ($a === $b) {\n bar();\n } elseif ($a > $b)
{\n $foo->bar($arg1);\n } else {\n
BazClass::bar($arg2, $arg3);\n }\n }\n\n final public static
function bar()\n {\n // method body\n [...]
+ "PSR-2 : 1.1. Example"
+ ;; (message "Indent: %s" (phps-mode-test-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)) (7 (0 0)) (8 (0 0)) (9 (0 0)) (10 (1 0)) (11 (1 0)) (12 (2 0)) (13 (3 0))
(14 (2 0)) (15 (3 0)) (16 (2 0)) (17 (3 0)) (18 (2 0)) (19 (1 0)) (20 (1 0))
(21 (1 0)) (22 (1 0)) (23 (2 0)) (24 (1 0)) (25 (0 0)))
(phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
+
+ (phps-mode-test-with-buffer
+ "<?php\nnamespace Vendor\\Package;\n\nuse FooClass;\nuse BarClass as
Bar;\nuse OtherVendor\\OtherPackage\\BazClass;\n\n// ... additional PHP code
..."
+ "PSR-2 : 3. Namespace and Use Declarations"
+ ;; (message "Indent: %s" (phps-mode-test-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)) (7 (0 0)) (8 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
- ;; TODO Add tests for all examples here: https://www.php-fig.org/psr/psr-2/
+ (phps-mode-test-with-buffer
+ "<?php\nnamespace Vendor\\Package;\n\nuse FooClass;\nuse BarClass as
Bar;\nuse OtherVendor\\OtherPackage\\BazClass;\n\nclass ClassName extends
ParentClass implements \\ArrayAccess, \\Countable\n{\n // constants,
properties, methods\n}"
+ "PSR-2 : 4.1. Extends and Implements : Example 1"
+ ;; (message "Indent: %s" (phps-mode-test-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)) (7 (0 0)) (8 (0 0)) (9 (0 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 Vendor\\Package;\n\nuse FooClass;\nuse BarClass as
Bar;\nuse OtherVendor\\OtherPackage\\BazClass;\n\nclass ClassName extends
ParentClass implements\n \\ArrayAccess,\n \\Countable,\n
\\Serializable\n{\n // constants, properties, methods\n}"
+ "PSR-2 : 4.1. Extends and Implements : Example 2"
+ ;; (message "Indent: %s" (phps-mode-test-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)) (7 (0 0)) (8 (0 0)) (9 (1 0)) (10 (1 0)) (11 (1 0)) (12 (0 0)) (13 (1 0))
(14 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
)
@@ -358,13 +388,13 @@
(phps-mode-test-with-buffer
"<?php\nif (true) {\n switch ($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 endswitch;\n
sprintf(__(\n 'Error: %s',\n $error\n ));\n}\n"
"Alternative switch, case, default with exception after it"
- (message "Indent: %s" (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
+ ;; (message "Indent: %s" (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (3 0)) (6 (3
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (3 0)) (11 (1 0)) (12 (1 0)) (13 (2 0))
(14 (2 0)) (15 (1 0)) (16 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<?php\nif (true) {\n switch ($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
sprintf(__(\n 'Error: %s',\n $error\n ));\n}\n"
"Curly switch, case, default with exception after it"
- (message "Indent: %s" (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
+ ;; (message "Indent: %s" (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (3 0)) (6 (3
0)) (7 (2 0)) (8 (3 0)) (9 (2 0)) (10 (3 0)) (11 (1 0)) (12 (1 0)) (13 (2 0))
(14 (2 0)) (15 (1 0)) (16 (0 0))) (phps-mode-test-hash-to-list
(phps-mode-functions-get-lines-indent)))))
)
@@ -648,13 +678,14 @@
(defun phps-mode-test-functions ()
"Run test for functions."
;; (setq debug-on-error t)
- (setq phps-mode-functions-verbose t)
+ ;; (setq phps-mode-functions-verbose t)
(phps-mode-test-functions-get-lines-lindent-if)
(phps-mode-test-functions-get-lines-indent-classes)
(phps-mode-test-functions-get-lines-indent-inline-if)
(phps-mode-test-functions-get-lines-indent-alternative-if)
(phps-mode-test-functions-get-lines-indent-multi-line-assignments)
(phps-mode-test-functions-get-lines-indent-switch-case)
+ (phps-mode-test-functions-get-lines-indent-psr-2)
(phps-mode-test-functions-get-lines-indent)
(phps-mode-test-functions-indent-line)
(phps-mode-test-functions-imenu))
- [elpa] externals/phps-mode 9069d0a 300/405: Concatenation indentation now uses stack, (continued)
- [elpa] externals/phps-mode 9069d0a 300/405: Concatenation indentation now uses stack, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e639ea3 299/405: Indent passing new concatenation tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5be3560 291/405: Adding more indent examples from PSR-2, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 74ab2a7 294/405: Work on incremental lexer and failing test for indent, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b31f817 292/405: Added all examples from PSR-2 as tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2087abd 282/405: Added two failing tests for switch indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 43c13b4 295/405: Started on new algorithm for concatenation indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b2ff76e 283/405: Started on debugging switch indentation bug, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1aadb1b 285/405: Added failing lexer test for comment vs doc-comment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 95de04b 274/405: New layout for lexer grammar passes unit tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 00d3568 290/405: Added indentation examples from official PSR-2,
Stefan Monnier <=
- [elpa] externals/phps-mode ec3fd41 289/405: Added failing indent test for mixed concatenation and function call, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode cc77604 284/405: Fixed bug with indentation after switch case statements, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode eeffdb2 315/405: Fixed trailing white-space, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 02b69f5 304/405: Tests for PSR-2 now passes with new algorithms, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b251a1e 314/405: Got unit tests for wrapping region in symbols working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 20199b0 307/405: Added byte-compiled Lisp to gitignore, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a0b7695 316/405: Passes unit tests for integration with electric-pair, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7c3a31a 305/405: Fixed bug in indentation with stacked assignment closures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 68422f5 301/405: Restored indentation test for PSR-2 closure, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f3766db 310/405: Fixed byte-compilation in lexer and integration-tests, Stefan Monnier, 2019/07/13