Add more tests for the parser code

remotes/local/master
Hugo Thunnissen 3 years ago
parent f7d88a90f4
commit 811a9a9141

@ -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")))

@ -0,0 +1,4 @@
<?php
[ 'item1', 'item2', 'item3' ];
[ 'item1' => 'item2',
'item3' => 'item4' ]

@ -0,0 +1 @@
(:root (:function (:declaration (:word "function") (:word "work") (:list)) (:block (:word "return") (:variable "variable") (:terminator ";"))))

@ -0,0 +1,4 @@
<?php
function work() {
return $variable;
}

@ -0,0 +1 @@
(:root (:word "declare") (:list (:word "strict_types") (:assignment "=")) (:terminator ";") (:namespace (:word "App\\Controller") (:terminator ";") (:class (:declaration (:word "class") (:word "Controller")) (:block))))

@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
namespace App\Controller;
class Controller
{
}

@ -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 ";"))))

@ -0,0 +1,8 @@
<?php
function work() {
return $variable;
}
function work2() {
return $paper;
}

@ -0,0 +1 @@
(:root (:variable "variable"))

@ -0,0 +1,2 @@
<?php
$variable

@ -0,0 +1 @@
(:root (:word "bareword"))

@ -0,0 +1,2 @@
<?php
bareword

@ -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

Loading…
Cancel
Save