[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode d16c8a4e93 099/135: Passing some tests now wi
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode d16c8a4e93 099/135: Passing some tests now with integrated bookkeeping and imenu-generation |
Date: |
Sun, 29 Jan 2023 03:11:08 -0500 (EST) |
branch: externals/phps-mode
commit d16c8a4e93ad3ea16c5359400521a735e853cd51
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing some tests now with integrated bookkeeping and imenu-generation
---
phps-mode-ast.el | 3 +
phps-mode-parser-sdt.el | 30 +++----
test/phps-mode-test-ast.el | 201 ++++++++++++++-------------------------------
3 files changed, 80 insertions(+), 154 deletions(-)
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index 7fd9d7a1eb..668fd3f9b6 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -69,6 +69,9 @@
(message "\nTranslation:\n%S\n\n" translation)
+ (setq
+ phps-mode-parser-sdt-symbol-imenu
+ (nreverse phps-mode-parser-sdt-symbol-imenu))
(setq
phps-mode-ast--tree
translation)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 590e7a3821..4cbecdba29 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -850,13 +850,13 @@
symbol-name
symbol-scope)))
- (message
- "assign symbol uri: %S from %S + %S, start: %S, end: %S"
- symbol-uri
- symbol-name
- symbol-scope
- symbol-start
- symbol-end)
+ ;; (message
+ ;; "assign symbol uri: %S from %S + %S, start: %S, end: %S"
+ ;; symbol-uri
+ ;; symbol-name
+ ;; symbol-scope
+ ;; symbol-start
+ ;; symbol-end)
(setq
phps-mode-parser-sdt-symbol-table-index
@@ -961,14 +961,14 @@
symbol-hit
phps-mode-parser-sdt-bookkeeping)
- (message
- "reference symbol uri: %S from %S + %S, start: %S, end: %S, hit?: %S"
- symbol-uri
- symbol-name
- symbol-scope
- symbol-start
- symbol-end
- symbol-hit)
+ ;; (message
+ ;; "reference symbol uri: %S from %S + %S, start: %S, end: %S, hit?:
%S"
+ ;; symbol-uri
+ ;; symbol-name
+ ;; symbol-scope
+ ;; symbol-start
+ ;; symbol-end
+ ;; symbol-hit)
))
(setq
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index c3c847b008..38ec7d2925 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -19,70 +19,68 @@
(require 'phps-mode-lex-analyzer)
(require 'phps-mode-test)
-(defun phps-mode-test-ast--should-bookkeep (buffer-contents name bookkeeping)
+(defun phps-mode-test-ast--should-bookkeep
+ (buffer-contents name expected-bookkeeping &optional expected-imenu)
(phps-mode-test-ast--buffer-contents
buffer-contents
name
(lambda()
- (let ((parse (phps-mode-parser-parse)))
- (message "Left-to-right with right-most derivation:\n%S\n" parse)
- (dolist (production-number parse)
- (let ((production
- (phps-mode-parser--get-grammar-production-by-number
- production-number)))
- (message
- "%d: %S -> %S"
- production-number
- (car (car production))
- (car (cdr production))))))
- (message "\n")
- (phps-mode-ast--generate)
- (phps-mode-ast-bookkeeping--generate)
-
- (message "imenu: \n%S\n" phps-mode-parser-sdt-symbol-imenu)
- (message "symbol-table: \n%S\n" phps-mode-parser-sdt-symbol-table)
- (message "phps-mode-parser-sdt-symbol-table-by-uri: \n%S\n"
phps-mode-parser-sdt-symbol-table-by-uri)
-
- (message
- "expected-bookkeeping:\n%S\n"
- bookkeeping)
- (message
- "actual-bookkeeping:\n%S\n"
- (phps-mode-test--hash-to-list
- phps-mode-ast-bookkeeping--index
- t))
-
- (should
- (equal
+ (let ((parse (phps-mode-parser-parse)))
+ (message "Left-to-right with right-most derivation:\n%S\n" parse)
+ (dolist (production-number parse)
+ (let ((production
+ (phps-mode-parser--get-grammar-production-by-number
+ production-number)))
+ (message
+ "%d: %S -> %S"
+ production-number
+ (car (car production))
+ (car (cdr production))))))
+ (message "\n")
+ (phps-mode-ast--generate)
+ (phps-mode-ast-bookkeeping--generate)
+
+ ;; (message "symbol-table: \n%S\n" phps-mode-parser-sdt-symbol-table)
+ ;; (message "phps-mode-parser-sdt-symbol-table-by-uri: \n%S\n"
phps-mode-parser-sdt-symbol-table-by-uri)
+
+ (unless
+ (equal
+ (phps-mode-test--hash-to-list
+ phps-mode-parser-sdt-bookkeeping
+ t)
+ expected-bookkeeping)
+ (message
+ "expected-bookkeeping:\n%S\n"
+ expected-bookkeeping)
+ (message
+ "actual-bookkeeping:\n%S\n"
(phps-mode-test--hash-to-list
- phps-mode-ast-bookkeeping--index
- t)
- bookkeeping)))))
+ phps-mode-parser-sdt-bookkeeping
+ t)))
-(defun phps-mode-test-ast--should-imenu (buffer-contents name imenu)
- (phps-mode-test-ast--buffer-contents
- buffer-contents
- name
- (lambda()
- (let ((parse (phps-mode-parser-parse)))
- (message "Left-to-right with right-most derivation:\n%S\n" parse)
- (dolist (production-number parse)
- (let ((production
- (phps-mode-parser--get-grammar-production-by-number
- production-number)))
- (message
- "%d: %S -> %S"
- production-number
- (car (car production))
- (car (cdr production))))))
- (message "\n")
- (phps-mode-ast--generate)
- (phps-mode-ast-imenu--generate)
- (message "imenu: %S" phps-mode-ast-imenu--index)
- (should
- (equal
- phps-mode-ast-imenu--index
- imenu)))))
+ (should
+ (equal
+ (phps-mode-test--hash-to-list
+ phps-mode-parser-sdt-bookkeeping
+ t)
+ expected-bookkeeping))
+
+ (when expected-imenu
+ (unless
+ (equal
+ phps-mode-parser-sdt-symbol-imenu
+ expected-imenu)
+ (message
+ "expected-imenu:\n%S\n"
+ expected-imenu)
+ (message
+ "actual-imenu:\n%S\n"
+ phps-mode-parser-sdt-symbol-imenu))
+
+ (should
+ (equal
+ phps-mode-parser-sdt-symbol-imenu
+ expected-imenu))))))
(defun phps-mode-test-ast--buffer-contents (buffer-contents name logic)
(with-temp-buffer
@@ -133,83 +131,6 @@
(funcall logic)
(message "Passed test for %S\n" name)))
-(defun phps-mode-test-ast-imenu ()
- "Run test for imenu generation."
- (message "-- Running tests for imenu generation... --\n")
-
- (phps-mode-test-ast--should-imenu
- "<?php\nclass myClass\n{\n\n public function myFunction1()\n {\n
echo \"my string with variable {$variable} inside it\";\n }\n\n public
function myFunction2()\n {\n }\n\n}"
- "Imenu generated via parser SDT for simple class"
- '(("myClass" ("myFunction1" . 44) ("myFunction2" . 153))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\ninterface myInterface {\n public function myFunctionA() {}\n
protected function myFunctionB() {}\n}\n"
- "Imenu generated via parser SDT for interface"
- '(("myInterface" . (("myFunctionA" . 51) ("myFunctionB" . 91)))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n$var =
function () {\n echo 'here';\n};"
- "Imenu generated via parser SDT for function-oriented file without
namespace"
- '(("myFunctionA" . 16) ("myFunctionB" . 42)))
-
- (phps-mode-test-ast--should-imenu
- "<?php\n\nnamespace MyNamespace;\n\nfunction aFunction() {\n /**\n *
With some contents\n */\n}\n\nclass MyClass\n{\n\n /**\n *\n
*/\n public function __construct()\n {\n if ($test) {\n }\n
}\n\n /**\n *\n */\n public function myFunction1()\n {\n
$this->addMessage(\"My random {$message} here\" . ($random > 1 ? \"A\" :
\"\") . \" was here.\");\n }\n \n /**\n *\n */\n public
function myFunction2()\n [...]
- "Passed imenu-generation via parser AST for basic object oriented file"
- '(("MyNamespace" ("aFunction" . 41) ("MyClass" ("__construct" . 160)
("myFunction1" . 261) ("myFunction2" . 433) ("myFunction3" . 513)
("myFunction4" . 583)))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\n\nnamespace MyNamespaceA\n{\n function aFunctionA() {\n
/**\n * With some contents\n */\n }\n class MyClass\n
{\n\n /**\n *\n */\n public function
__construct()\n {\n if ($test) {\n }\n
}\n\n /**\n *\n */\n public function
myFunction1()\n {\n $this->addMessage(\"My random {$message}
here\" . ($random > 1 ? \"A\" : \"\") . \" was h [...]
- "Passed imenu-generation via parser AST for advanced object oriented file"
- '(("MyNamespaceA" ("aFunctionA" . 46) ("MyClass" ("__construct" . 205)
("myFunction1" . 338) ("myFunction2" . 542) ("myFunction3" . 646)
("myFunction4" . 740))) ("aFunctionB" . 807) ("MyClass" ("__construct" . 925)
("myFunction1" . 1058) ("myFunction2" . 1262) ("myFunction3" . 1366)
("myFunction4" . 1460))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nnamespace myNamespace {\n class myClass extends myAbstract {\n
public function myFunctionA() {}\n protected function myFunctionB()
{}\n }\n}\n"
- "Imenu object-oriented file with namespace, class that extends and
functions"
- '(("myNamespace" ("myClass" ("myFunctionA" . 94) ("myFunctionB" . 138)))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA() {}\n protected function
myFunctionB() {}\n}\n"
- "Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions"
- '(("myNamespace" ("myClass" ("myFunctionA" . 108) ("myFunctionB" . 148)))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nclass myClass {}"
- "Imenu empty class"
- '(("myClass" . 13)))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nnamespace myNamespace {}"
- "Imenu empty bracketed namespace"
- '(("myNamespace" . 17)))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nnamespace myNamespace;"
- "Imenu empty namespace without brackets"
- '(("myNamespace" . 17)))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA($myArg = null) {}\n protected
function myFunctionB($myArg = 'abc') {}\n}\n"
- "Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions with optional arguments"
- '(("myNamespace" ("myClass" ("myFunctionA" . 108) ("myFunctionB" . 161)))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nnamespace myNamespace\\myNamespace2;\nclass myClass extends
myAbstract implements myInterface {\n public function myFunctionA($myArg =
null) {}\n protected function myFunctionB($myArg = 'abc') {}\n}\n"
- "Imenu object-oriented file with bracket-less namespace with multiple
levels, class that extends and implements and functions with optional arguments"
- '(("myNamespace\\myNamespace2" ("myClass" ("myFunctionA" . 121)
("myFunctionB" . 174)))))
-
- (phps-mode-test-ast--should-imenu
- "<?php\nnamespace {}"
- "Imenu empty unnamed bracketed namespace"
- nil)
-
- ;; TODO Make this test pass
- ;; (phps-mode-test-ast--should-imenu
- ;; "<?php\n\nnamespace myNamespace;\n\nif (!function_exists('myFunction'))
{\n function myFunction() {\n if (!class_exists('myClassA')) {\n
class myClassA {\n public function myMethodA()\n
{\n \n }\n }\n }\n
}\n}\n\nif (!class_exists('myClassB')) {\n class myClassB\n {\n
function myMethodB()\n {\n }\n }\n}"
- ;; "Imenu for conditionally declared function and class"
- ;; '(("myNamespace" ("myFunction" . 183) ("myClassA" ("myMethodA" . 200))
("myClassB" . ("myMethodB" . 377)))))
-
- (message "\n-- Ran tests for imenu generation. --"))
-
(defun phps-mode-test-ast-bookkeeping ()
"Run test for bookkeeping generation."
(message "-- Running tests for bookkeeping generation... --\n")
@@ -217,17 +138,20 @@
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var = 'abc';\n\nif ($var2) {\n echo 'This never
happens';\n}\nif ($var) {\n echo 'This happens';\n}"
"Bookkeeping in root level variable assignments #1"
- '((" id $var" ((8 12))) ((8 12) 1) ((27 32) 0) ((73 77) 1)))
+ '(((8 12) 1) ((27 32) 0) ((73 77) 1))
+ '(("id $var" . 8)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var = 'abc';\n\nif ($var) {\n echo 'This never
happens';\n}\nif ($var2) {\n echo 'This happens';\n}"
"Bookkeeping in root level variable assignments #2"
- '((" id $var" ((8 12))) ((8 12) 1) ((27 31) 1) ((72 77) 0)))
+ '(((8 12) 1) ((27 31) 1) ((72 77) 0))
+ '(("id $var" . 8)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var2 = 4;\n\nfunction myFunction($var)\n{\n $var3 = 3;\n
if ($var) {\n echo 'Hit';\n }\n if ($var2) {\n echo
'Miss';\n }\n if ($var3) {\n echo 'Hit';\n }\n}\n\nfunction
myFunction2($abc)\n{\n if ($var) {\n echo 'Miss';\n }\n if
($abc) {\n echo 'Hit';\n }\n}\n\nif ($var) {\n echo 'Miss';\n}\nif
($var2) {\n echo 'Hit';\n}"
"Bookkeeping in function level with variable assignments"
- '((" id $var2" ((8 13))) ((8 13) 1) (" function myFunction id $var" ((40
44))) (" function myFunction id $var3" ((52 57))) ((40 44) 1) ((157 162) 1)
((113 118) 0) ((71 75) 1) ((52 57) 1) (" function myFunction2 id $abc" ((216
220))) ((216 220) 1) ((275 279) 1) ((232 236) 0) ((316 320) 0) ((347 352) 1)))
+ '(((8 13) 1) ((40 44) 2) ((157 162) 3) ((113 118) 0) ((71 75) 2) ((52 57)
3) ((216 220) 4) ((275 279) 4) ((232 236) 0) ((316 320) 0) ((347 352) 1))
+ '(("id $var2" . 8) ("function myFunction id $var" . 40) ("function
myFunction id $var3" . 52) ("function myFunction2 id $abc" . 216)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n// Super-globals\n\nif ($_GET) {\n echo 'Hit';\n}\nif ($_POST)
{\n echo 'Hit';\n}\nif ($_COOKIE) {\n echo 'Hit';\n}\nif ($_SESSION) {\n
echo 'Hit';\n}\nif ($_REQUEST) {\n echo 'Hit';\n}\nif ($GLOBALS) {\n
echo 'Hit';\n}\nif ($_SERVER) {\n echo 'Hit';\n}\nif ($_FILES) {\n echo
'Hit';\n}\nif ($_ENV) {\n echo 'Hit';\n}\nif ($argc) {\n echo
'Hit';\n}\nif ($argv) {\n echo 'Hit';\n}\nif ($http_​response_​header) {\n
echo 'Hit';\n}"
@@ -395,7 +319,6 @@
"Run test for ast."
(message "-- Running all tests for ast... --\n")
(phps-mode-test-ast-bookkeeping)
- (phps-mode-test-ast-imenu)
(message "\n-- Ran all tests for ast. --"))
(phps-mode-test-ast)
- [elpa] externals/phps-mode eb07936ea8 036/135: added todo notes, (continued)
- [elpa] externals/phps-mode eb07936ea8 036/135: added todo notes, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 0ca63fe2b6 041/135: Passing another bookkeeping test via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e74d0fd634 010/135: SDT for inner_statement, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 8dc2235f17 017/135: Added SDT for if_stmt, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d73af7968e 033/135: SDT to 538, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 0e8923c0bd 042/135: Passed super-globals bookkeeping test via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode cc584ff4d6 061/135: Bookkeping of static class properties test passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode eefe70b999 072/135: Work on improving symbol URI calculation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ebe28c3c9d 073/135: Work on improving symbol URI generation for class method variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 61d3e7b1e0 093/135: Passing bookkeeping test but via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d16c8a4e93 099/135: Passing some tests now with integrated bookkeeping and imenu-generation,
Christian Johansson <=
- [elpa] externals/phps-mode 9a45a530d0 100/135: Passing more imenu tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 749659769c 115/135: More work on imenu generation via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 42b983bb16 045/135: More work on bookkeeping via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode cba467b26c 050/135: Added TODO items, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e1752a3aa3 064/135: Bookkeeping of variables inside simple anonymous functions, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d464cb1f01 077/135: Fixed bookkeeping of global variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1a1245f186 082/135: Passing bookkeeping test isset and empty variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 696d66d7e7 085/135: Bookkeeping of static variable inside function, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode cffad0d620 131/135: Merge branch 'feature/full-sdt', Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 249f8a2a4d 087/135: Work on bookkeeping class static variable, Christian Johansson, 2023/01/29