branch: externals/phpinspect
commit 811a9a914135de2ee09091b0cebf6eb53bcf92dd
Author: Hugo Thunnissen <de...@hugot.nl>
Commit: Hugo Thunnissen <de...@hugot.nl>

    Add more tests for the parser code
---
 test/fixtures/Array.el                 |  1 +
 test/fixtures/Array.php                |  4 ++++
 test/fixtures/ShortFunction.el         |  1 +
 test/fixtures/ShortFunction.php        |  4 ++++
 test/fixtures/SmallNamespacedClass.el  |  1 +
 test/fixtures/SmallNamespacedClass.php |  8 +++++++
 test/fixtures/TwoShortFunctions.el     |  1 +
 test/fixtures/TwoShortFunctions.php    |  8 +++++++
 test/fixtures/Variable.el              |  1 +
 test/fixtures/Variable.php             |  2 ++
 test/fixtures/Word.el                  |  1 +
 test/fixtures/Word.php                 |  2 ++
 test/phpinspect-test.el                | 40 +++++++++++++++++++++++++++++++++-
 13 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/test/fixtures/Array.el b/test/fixtures/Array.el
new file mode 100644
index 0000000000..80b28e2ede
--- /dev/null
+++ b/test/fixtures/Array.el
@@ -0,0 +1 @@
+(:root (:array (:string "item1") (:comma ",") (:string "item2") (:comma ",") 
(:string "item3")) (:terminator ";") (:array (:string "item1") (:fat-arrow 
"=>") (:string "item2") (:comma ",") (:string "item3") (:fat-arrow "=>") 
(:string "item4")))
diff --git a/test/fixtures/Array.php b/test/fixtures/Array.php
new file mode 100644
index 0000000000..a36c76d2f2
--- /dev/null
+++ b/test/fixtures/Array.php
@@ -0,0 +1,4 @@
+<?php
+[ 'item1', 'item2', 'item3' ];
+[ 'item1' => 'item2',
+  'item3' => 'item4' ]
diff --git a/test/fixtures/ShortFunction.el b/test/fixtures/ShortFunction.el
new file mode 100644
index 0000000000..48468fa14f
--- /dev/null
+++ b/test/fixtures/ShortFunction.el
@@ -0,0 +1 @@
+(:root (:function (:declaration (:word "function") (:word "work") (:list)) 
(:block (:word "return") (:variable "variable") (:terminator ";"))))
diff --git a/test/fixtures/ShortFunction.php b/test/fixtures/ShortFunction.php
new file mode 100644
index 0000000000..91295e937b
--- /dev/null
+++ b/test/fixtures/ShortFunction.php
@@ -0,0 +1,4 @@
+<?php
+function work() {
+    return $variable;
+}
diff --git a/test/fixtures/SmallNamespacedClass.el 
b/test/fixtures/SmallNamespacedClass.el
new file mode 100644
index 0000000000..39624fc325
--- /dev/null
+++ b/test/fixtures/SmallNamespacedClass.el
@@ -0,0 +1 @@
+(:root (:word "declare") (:list (:word "strict_types") (:assignment "=")) 
(:terminator ";") (:namespace (:word "App\\Controller") (:terminator ";") 
(:class (:declaration (:word "class") (:word "Controller")) (:block))))
diff --git a/test/fixtures/SmallNamespacedClass.php 
b/test/fixtures/SmallNamespacedClass.php
new file mode 100644
index 0000000000..048c6b1b92
--- /dev/null
+++ b/test/fixtures/SmallNamespacedClass.php
@@ -0,0 +1,8 @@
+<?php
+declare(strict_types=1);
+
+namespace App\Controller;
+
+class Controller
+{
+}
diff --git a/test/fixtures/TwoShortFunctions.el 
b/test/fixtures/TwoShortFunctions.el
new file mode 100644
index 0000000000..55f4dec0d8
--- /dev/null
+++ b/test/fixtures/TwoShortFunctions.el
@@ -0,0 +1 @@
+(:root (:function (:declaration (:word "function") (:word "work") (:list)) 
(:block (:word "return") (:variable "variable") (:terminator ";"))) (:function 
(:declaration (:word "function") (:word "work2") (:list)) (:block (:word 
"return") (:variable "paper") (:terminator ";"))))
diff --git a/test/fixtures/TwoShortFunctions.php 
b/test/fixtures/TwoShortFunctions.php
new file mode 100644
index 0000000000..aae01c190a
--- /dev/null
+++ b/test/fixtures/TwoShortFunctions.php
@@ -0,0 +1,8 @@
+<?php
+function work() {
+    return $variable;
+}
+
+function work2() {
+    return $paper;
+}
diff --git a/test/fixtures/Variable.el b/test/fixtures/Variable.el
new file mode 100644
index 0000000000..4388b45d4f
--- /dev/null
+++ b/test/fixtures/Variable.el
@@ -0,0 +1 @@
+(:root (:variable "variable"))
diff --git a/test/fixtures/Variable.php b/test/fixtures/Variable.php
new file mode 100644
index 0000000000..7a9deeed47
--- /dev/null
+++ b/test/fixtures/Variable.php
@@ -0,0 +1,2 @@
+<?php
+$variable
diff --git a/test/fixtures/Word.el b/test/fixtures/Word.el
new file mode 100644
index 0000000000..92ee97613c
--- /dev/null
+++ b/test/fixtures/Word.el
@@ -0,0 +1 @@
+(:root (:word "bareword"))
diff --git a/test/fixtures/Word.php b/test/fixtures/Word.php
new file mode 100644
index 0000000000..88e696bdfa
--- /dev/null
+++ b/test/fixtures/Word.php
@@ -0,0 +1,2 @@
+<?php
+bareword
diff --git a/test/phpinspect-test.el b/test/phpinspect-test.el
index 8e8ceee132..cfd6f88fc5 100644
--- a/test/phpinspect-test.el
+++ b/test/phpinspect-test.el
@@ -45,7 +45,7 @@
 
 (ert-deftest phpinspect-parse-namespaced-class ()
   "Test phpinspect-parse on a namespaced class"
-    (should
+  (should
    (equal (phpinspect-test-read-fixture-tree "NamespacedClass")
           (phpinspect-test-parse-fixture-code "NamespacedClass"))))
 
@@ -67,5 +67,43 @@
    (equal (phpinspect-test-read-fixture-tree "NamespacedFunctions")
           (phpinspect-test-parse-fixture-code "NamespacedFunctions"))))
 
+(ert-deftest phpinspect-parse-variable ()
+  "Test phpinspect-parse for php blocks"
+  (should
+   (equal (phpinspect-test-read-fixture-tree "Variable")
+          (phpinspect-test-parse-fixture-code "Variable"))))
+
+(ert-deftest phpinspect-parse-word ()
+  "Test phpinspect-parse for php blocks"
+  (should
+   (equal (phpinspect-test-read-fixture-tree "Word")
+          (phpinspect-test-parse-fixture-code "Word"))))
+
+(ert-deftest phpinspect-parse-array ()
+  "Test phpinspect-parse for php blocks"
+  (should
+   (equal (phpinspect-test-read-fixture-tree "Array")
+          (phpinspect-test-parse-fixture-code "Array"))))
+
+
+(ert-deftest phpinspect-parse-short-function ()
+  "Test phpinspect-parse for php blocks"
+  (should
+   (equal (phpinspect-test-read-fixture-tree "ShortFunction")
+          (phpinspect-test-parse-fixture-code "ShortFunction"))))
+
+(ert-deftest phpinspect-parse-two-short-functions ()
+  "Test phpinspect-parse for php blocks"
+  (should
+   (equal (phpinspect-test-read-fixture-tree "TwoShortFunctions")
+          (phpinspect-test-parse-fixture-code "TwoShortFunctions"))))
+
+(ert-deftest phpinspect-parse-small-namespaced-class ()
+  "Test phpinspect-parse for php blocks"
+  (should
+   (equal (phpinspect-test-read-fixture-tree "SmallNamespacedClass")
+          (phpinspect-test-parse-fixture-code "SmallNamespacedClass"))))
+
+
 (provide 'phpinspect-test)
 ;;; phpinspect-test.el ends here

Reply via email to