emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode d9115ec583 069/212: Cleaned up AST bookkeepin


From: Christian Johansson
Subject: [elpa] externals/phps-mode d9115ec583 069/212: Cleaned up AST bookkeeping tests
Date: Wed, 26 Jan 2022 01:50:50 -0500 (EST)

branch: externals/phps-mode
commit d9115ec583d8e37d5bf41d56cef0ecb84d49e09d
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Cleaned up AST bookkeeping tests
---
 test/phps-mode-test-ast.el | 640 ++++++---------------------------------------
 1 file changed, 84 insertions(+), 556 deletions(-)

diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 38b13cd274..aeccc8eaa6 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -32,6 +32,29 @@
 (require 'phps-mode-ast-bookkeeping)
 (require 'phps-mode-ast-imenu)
 
+(defun phps-mode-test-ast--should-bookkeep (buffer-contents name bookkeeping)
+  (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 (reverse 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))))))
+      (phps-mode-ast--generate)
+      (phps-mode-ast-bookkeeping--generate)
+      (should
+       (equal
+        (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
+        bookkeeping)))))
+
 (defun phps-mode-test-ast--buffer-contents (buffer-contents name logic)
   (with-temp-buffer
     ;; Setup buffer
@@ -231,647 +254,152 @@
   "Run test for bookkeeping generation."
   (message "-- Running tests for bookkeeping generation... --\n")
 
-  (phps-mode-test-ast--buffer-contents
+  (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"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $var" 1) ((8 12) 1) ((27 32) 0) ((73 77) 1))))))
+   '((" id $var" 1) ((8 12) 1) ((27 32) 0) ((73 77) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (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"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $var" 1) ((8 12) 1) ((27 31) 1) ((72 77) 0))))))
+   '((" id $var" 1) ((8 12) 1) ((27 31) 1) ((72 77) 0)))
 
-  (phps-mode-test-ast--buffer-contents
+  (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"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $var2" 1) ((8 13) 1) (" function myFunction id $var" 1) ((40 
44) 1) (" function myFunction id $var3" 1) ((52 57) 1) ((71 75) 1) ((113 118) 
0) ((157 162) 1) (" function myFunction2 id $abc" 1) ((216 220) 1) ((232 236) 
0) ((275 279) 1) ((316 320) 0) ((347 352) 1))))))
+   '((" id $var2" 1) ((8 13) 1) (" function myFunction id $var" 1) ((40 44) 1) 
(" function myFunction id $var3" 1) ((52 57) 1) ((71 75) 1) ((113 118) 0) ((157 
162) 1) (" function myFunction2 id $abc" 1) ((216 220) 1) ((232 236) 0) ((275 
279) 1) ((316 320) 0) ((347 352) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (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}"
    "Bookkeeping of super-globals"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '(((30 35) 1) ((61 67) 1) ((93 101) 1) ((127 136) 1) ((162 171) 1) 
((197 205) 1) ((231 239) 1) ((265 272) 1) ((298 303) 1) ((329 334) 1) ((360 
365) 1) ((391 414) 1))))))
+   '(((30 35) 1) ((61 67) 1) ((93 101) 1) ((127 136) 1) ((162 171) 1) ((197 
205) 1) ((231 239) 1) ((265 272) 1) ((298 303) 1) ((329 334) 1) ((360 365) 1) 
((391 414) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\nnamespace myNamespaceA {\n    $var = 123;\n    class myClassA {\n 
       private $var2 = 123;\n        function myFunctionA($var3) {\n            
$var4 = 123;\n            if ($var) {\n                echo 'Miss';\n           
 }\n            if ($var2) {\n                echo 'Miss';\n            }\n     
       if ($var3) {\n                echo 'Hit';\n            }\n            if 
($var4) {\n                echo 'Hit';\n            }\n        }\n\n        
function myFuncti [...]
    "Bookkeeping in maximum level with namespaces, classes and functions."
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index 1)
-       '((" id $var" 1) ((37 41) 1) (" namespace myNamespaceA class myClassA 
id $var2" 1) ((86 91) 1) (" namespace myNamespaceA class myClassA function 
myFunctionA id $this" 1) (" namespace myNamespaceA class myClassA function 
myFunctionA id $var3" 1) ((128 133) 1) (" namespace myNamespaceA class myClassA 
function myFunctionA id $var4" 1) ((149 154) 1) ((178 182) 0) ((245 250) 0) 
((313 318) 1) ((380 385) 1) (" namespace myNamespaceA class myClassA function 
myFunctionB id $this" 1) (" nam [...]
+   '((" id $var" 1) ((37 41) 1) (" namespace myNamespaceA class myClassA id 
$var2" 1) ((86 91) 1) (" namespace myNamespaceA class myClassA function 
myFunctionA id $this" 1) (" namespace myNamespaceA class myClassA function 
myFunctionA id $var3" 1) ((128 133) 1) (" namespace myNamespaceA class myClassA 
function myFunctionA id $var4" 1) ((149 154) 1) ((178 182) 0) ((245 250) 0) 
((313 318) 1) ((380 385) 1) (" namespace myNamespaceA class myClassA function 
myFunctionB id $this" 1) (" namespa [...]
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n// Conditional assignments\n\n$items = array(1, 2, 3);\nforeach 
($items as $item) {\n    if ($item) {\n        echo 'Hit';\n    }\n}\nforeach 
($items as $key => $value) {\n    if ($key || $value) {\n        echo 'Hit';\n  
  }\n}\nfor ($i = 0; $i < count($items); $i++) {\n    if ($i) {\n        echo 
'Hit';\n    }\n}\nif ($a = 123) {\n    if ($a) {\n        echo 'Hit';\n    
}\n}\nwhile ($b = 123) {\n    if ($a) {\n        echo 'Hit';\n    }\n}\ndo {\n  
  echo 'Hit';\n} while ( [...]
    "Bookkeeping of conditional assignments"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $items" 1) ((36 42) 1) ((70 76) 1) (" id $item" 1) ((80 85) 1) 
((97 102) 1) ((143 149) 1) (" id $key" 1) ((153 157) 1) (" id $value" 1) ((161 
167) 1) ((179 183) 1) ((187 193) 1) (" id $i" 1) ((230 232) 1) ((238 240) 1) 
((249 255) 1) ((258 260) 1) ((274 276) 1) (" id $a" 1) ((312 314) 1) ((332 334) 
1) (" id $b" 1) ((373 375) 1) ((393 395) 1) (" id $c" 1) ((457 459) 1))))))
+   '((" id $items" 1) ((36 42) 1) ((70 76) 1) (" id $item" 1) ((80 85) 1) ((97 
102) 1) ((143 149) 1) (" id $key" 1) ((153 157) 1) (" id $value" 1) ((161 167) 
1) ((179 183) 1) ((187 193) 1) (" id $i" 1) ((230 232) 1) ((238 240) 1) ((249 
255) 1) ((258 260) 1) ((274 276) 1) (" id $a" 1) ((312 314) 1) ((332 334) 1) (" 
id $b" 1) ((373 375) 1) ((393 395) 1) (" id $c" 1) ((457 459) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n// Class properties\n\nclass myParent {}\n\nclass myClass extends 
myParent {\n    private $var1 = 123;\n    protected static $var2;\n    public 
$var3;\n    var $var4;\n    function __construct() {\n        if ($this) {\n    
        echo 'Hit';\n        }\n        if ($this->var1) {\n            echo 
'Hit';\n        }\n        if (self::$var1) {\n            echo 'Miss';\n       
 }\n        if (self::$var2) {\n            echo 'Hit';\n        }\n        if 
($this->var3) {\n   [...]
    "Bookkeeping of class properties"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" class myClass id $var1" 1) ((93 98) 1) (" class myClass static id 
$var2" 1) ((127 132) 1) (" class myClass id $var3" 1) ((145 150) 1) (" class 
myClass id $var4" 1) ((160 165) 1) (" class myClass function __construct id 
$this" 1) ((208 213) 1) ((263 268) 1) ((270 274) 1) ((330 335) 0) ((392 397) 1) 
((447 452) 1) ((454 458) 1) ((508 513) 1) ((515 519) 1) ((569 574) 1) ((576 
580) 0) ((688 693) 0))))))
+   '((" class myClass id $var1" 1) ((93 98) 1) (" class myClass static id 
$var2" 1) ((127 132) 1) (" class myClass id $var3" 1) ((145 150) 1) (" class 
myClass id $var4" 1) ((160 165) 1) (" class myClass function __construct id 
$this" 1) ((208 213) 1) ((263 268) 1) ((270 274) 1) ((330 335) 0) ((392 397) 1) 
((447 452) 1) ((454 458) 1) ((508 513) 1) ((515 519) 1) ((569 574) 1) ((576 
580) 0) ((688 693) 0)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\ntry {\n    \n} catch (\\Exception $e) {\n    if ($e) {\n        
echo 'Hit';\n    }\n}\n\nif ($e) {\n    echo 'Miss';\n}\n"
    "Bookkeeping of try catch variable assignment"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $e" 1) ((39 41) 1) ((53 55) 1) ((92 94) 1))))))
+   '((" id $e" 1) ((39 41) 1) ((53 55) 1) ((92 94) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n$example = function ($test) {\n    if ($test) {\n        echo 
'Hit';\n    }\n    if ($example) {\n        echo 'Miss';\n    }\n};\n$example2 
= function ($test2) use ($example) {\n    if ($test2) {\n        echo 'Hit';\n  
  }\n    if ($example) {\n        echo 'Hit';\n    }\n    if ($example2) {\n    
    echo 'Miss';\n    }\n    if ($example3) {\n        echo 'Miss';\n    
}\n};\nif ($test) {\n    echo 'Miss';\n}\nif ($test2) {\n    echo 'Miss';\n}"
    "Bookkeeping of anonymous function variable assignments"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $example" 1) ((8 16) 1) (" anonymous function 1 id $test" 1) 
((29 34) 1) ((46 51) 1) ((89 97) 0) (" id $example2" 1) ((131 140) 1) (" 
anonymous function 2 id $test2" 1) ((153 159) 1) (" anonymous function 2 id 
$example" 1) ((166 174) 1) ((186 192) 1) ((230 238) 1) ((276 285) 0) ((324 333) 
0) ((371 376) 0) ((403 409) 0))))))
+   '((" id $example" 1) ((8 16) 1) (" anonymous function 1 id $test" 1) ((29 
34) 1) ((46 51) 1) ((89 97) 0) (" id $example2" 1) ((131 140) 1) (" anonymous 
function 2 id $test2" 1) ((153 159) 1) (" anonymous function 2 id $example" 1) 
((166 174) 1) ((186 192) 1) ((230 238) 1) ((276 285) 0) ((324 333) 0) ((371 
376) 0) ((403 409) 0)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\nclass myClass {\n    function random() {}\n    function 
__construct()\n    {\n        $this->random();\n        $this->random['abc'] = 
123;\n    }\n}"
    "Method calls should be avoided in bookkeeping"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" class myClass function random id $this" 1) (" class myClass 
function __construct id $this" 1))))))
+   '((" class myClass function random id $this" 1) (" class myClass function 
__construct id $this" 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n$items = array(1, 2, 3);\nforeach ($items as &$item) {\n    if 
($item) {\n        echo 'Hit';\n    }\n}\nforeach ($items as $key => &$item2) 
{\n    if ($item) {\n        echo 'Hit';\n    }\n}"
    "Bookkeeping of foreach reference variable declaration"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $items" 1) ((7 13) 1) ((41 47) 1) (" id $item" 1) ((52 57) 1) 
((69 74) 1) ((115 121) 1) (" id $key" 1) ((125 129) 1) (" id $item2" 1) ((134 
140) 1) ((152 157) 1))))))
+   '((" id $items" 1) ((7 13) 1) ((41 47) 1) (" id $item" 1) ((52 57) 1) ((69 
74) 1) ((115 121) 1) (" id $key" 1) ((125 129) 1) (" id $item2" 1) ((134 140) 
1) ((152 157) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n[$random, $bandom] = myValues();\nif ($random) {\n    echo 
'Hit';\n}\nif ($bandom) {\n    echo 'Hit';\n}\n"
    "Bookkeeping of variable declarations in array"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $random" 1) ((9 16) 1) (" id $bandom" 1) ((18 25) 1) ((45 52) 
1) ((78 85) 1))))))
+   '((" id $random" 1) ((9 16) 1) (" id $bandom" 1) ((18 25) 1) ((45 52) 1) 
((78 85) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n$var = 123;\n\nfunction test($abc) {\n    global $var;\n    if 
($var) {\n        echo 'Hit';\n    }\n}"
    "Bookkeeping of global variable declaration in function"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 
39) 1) (" function test id $var" 1) ((54 58) 1) ((68 72) 1))))))
+   '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 39) 1) (" 
function test id $var" 1) ((54 58) 1) ((68 72) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n$y = 1;\n$fn1 = fn($x) => $x + $y;\n$z = 1;\n$fn = fn($x2) => 
fn($y2) => $x2 * $y2 + $z;\nfn(array $x3) => $x3;\n$x4 = 4;\nstatic fn(): int 
=> $x4;\nfn($x5 = 42) => $x5;\nfn(&$x6) => $x6;\nfn&($x7) => $x7;\nfn($x8, 
...$rest) => $rest;"
    "Bookkeeping in arrow functions"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $y" 1) ((7 9) 1) (" id $fn1" 1) ((15 19) 1) (" arrow function 1 
id $x" 1) ((25 27) 1) ((32 34) 1) ((37 39) 1) (" id $z" 1) ((41 43) 1) (" id 
$fn" 1) ((49 52) 1) (" arrow function 2 id $x2" 1) ((58 61) 1) (" arrow 
function 2 arrow function 3 id $y2" 1) ((69 72) 1) ((77 80) 1) ((83 86) 1) ((89 
91) 1) (" arrow function 4 id $x3" 1) ((102 105) 1) ((110 113) 1) (" id $x4" 1) 
((115 118) 1) ((144 147) 1) (" arrow function 6 id $x5" 1) ((152 155) 1) ((165 
168) 1) (" arrow function [...]
+   '((" id $y" 1) ((7 9) 1) (" id $fn1" 1) ((15 19) 1) (" arrow function 1 id 
$x" 1) ((25 27) 1) ((32 34) 1) ((37 39) 1) (" id $z" 1) ((41 43) 1) (" id $fn" 
1) ((49 52) 1) (" arrow function 2 id $x2" 1) ((58 61) 1) (" arrow function 2 
arrow function 3 id $y2" 1) ((69 72) 1) ((77 80) 1) ((83 86) 1) ((89 91) 1) (" 
arrow function 4 id $x3" 1) ((102 105) 1) ((110 113) 1) (" id $x4" 1) ((115 
118) 1) ((144 147) 1) (" arrow function 6 id $x5" 1) ((152 155) 1) ((165 168) 
1) (" arrow function 7 i [...]
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n$z = (object) array('name' => 'random');\nif ($z->name) {\n    echo 
'Hit';\n}"
    "Bookkeeping ignoring variable properties"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       (list (list " id $z" 1) (list (list 7 9) 1) (list (list 52 54) 1))))))
+   '((" id $z" 1) ((7 9) 1) ((52 54) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\nif (!$var = false) {\n    echo 'Hit';\n}\n"
    "Bookkeeping negative conditional assignment"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       (list (list " id $var" 1) (list (list 12 16) 1))))))
+   '((" id $var" 1) ((12 16) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\nif (isset($x)) {\n    if ($x) {\n        echo 'Hit';\n        if 
(isset($i, $u)) {\n            if ($i) {\n                echo 'Hit';\n         
   }\n            if ($u) {\n                echo 'Hit';\n            }\n       
     if ($x) {\n                echo 'Hit';\n            }\n        }\n        
if ($i) {\n            echo 'Miss';\n        }\n        if ($u) {\n            
echo 'Miss';\n        }\n    }\n}\nif ($x) {\n    echo 'Miss';\n}\n\nif 
(!empty($y)) {\n    if ( [...]
    "Bookkeeping of isset() and !empty() scoped variables"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" defined 1 id $x" 1) ((18 20) 1) ((33 35) 1) (" defined 1 defined 2 
id $i" 1) (" defined 1 defined 2 id $u" 1) ((77 79) 1) ((81 83) 1) ((104 106) 
1) ((168 170) 1) ((232 234) 1) ((302 304) 0) ((355 357) 0) ((408 410) 0) (" 
defined 3 id $y" 1) ((445 447) 1) ((460 462) 1) (" defined 3 defined 4 id $k" 
1) (" defined 3 defined 4 id $L" 1) ((505 507) 1) ((519 521) 1) ((542 544) 1) 
((606 608) 1) ((670 672) 1) ((740 742) 0) ((793 795) 0) ((846 848) 0))))))
+   '((" defined 1 id $x" 1) ((18 20) 1) ((33 35) 1) (" defined 1 defined 2 id 
$i" 1) (" defined 1 defined 2 id $u" 1) ((77 79) 1) ((81 83) 1) ((104 106) 1) 
((168 170) 1) ((232 234) 1) ((302 304) 0) ((355 357) 0) ((408 410) 0) (" 
defined 3 id $y" 1) ((445 447) 1) ((460 462) 1) (" defined 3 defined 4 id $k" 
1) (" defined 3 defined 4 id $L" 1) ((505 507) 1) ((519 521) 1) ((542 544) 1) 
((606 608) 1) ((670 672) 1) ((740 742) 0) ((793 795) 0) ((846 848) 0)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\ninterface myInterface\n{\n    function myFunction1();\n    function 
myFunction2($x);\n}\n"
    "Bookkeeping variable in interface function"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" class myInterface function myFunction2 id $x" 1) ((84 86) 1))))))
+   '((" class myInterface function myFunction2 id $x" 1) ((84 86) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\nfunction myFunction1()\n{\n    return isset($a);\n}\n\nfunction 
myFunction2()\n{\n    $b = 2;\n    if ($b) {\n        echo 'Hit';\n    }\n    
if ($b) {\n        echo 'Hit';\n    }\n}\n"
    "Bookkeeping after definition condition"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" function myFunction2 id $b" 1) ((87 89) 1) ((103 105) 1) ((143 
145) 1))))))
+   '((" function myFunction2 id $b" 1) ((87 89) 1) ((103 105) 1) ((143 145) 
1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n$a = array(1, 2, 3);\nforeach ($a as $uri => $page)\n{\n    if 
(isset($pages)) {\n        if ($a) {\n            echo 'Hit';\n        }\n      
  if ($uri) {\n            echo 'Hit';\n        }\n        if ($page) {\n       
     echo 'Hit';\n        }\n    }\n}\n"
    "Bookkeeping of foreach variable inside if (isset()) block"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $a" 1) ((8 10) 1) ((38 40) 1) (" id $uri" 1) ((44 48) 1) (" id 
$page" 1) ((52 57) 1) (" defined 1 id $pages" 1) ((75 81) 1) ((98 100) 1) ((150 
154) 1) ((204 209) 1))))))
+   '((" id $a" 1) ((8 10) 1) ((38 40) 1) (" id $uri" 1) ((44 48) 1) (" id 
$page" 1) ((52 57) 1) (" defined 1 id $pages" 1) ((75 81) 1) ((98 100) 1) ((150 
154) 1) ((204 209) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\nif (isset($b)) {\n    $b = false;\n}\n$c = 2;\n\nif ($c) {\n    
echo 'Hit';\n}\n"
    "Bookkeeping of variable after isset() block"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" defined 1 id $b" 2) ((17 19) 1) ((28 30) 2) (" id $c" 1) ((42 44) 
1) ((55 57) 1))))))
+   '((" defined 1 id $b" 2) ((17 19) 1) ((28 30) 2) (" id $c" 1) ((42 44) 1) 
((55 57) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\nif (!isset($a)) {\n    if ($a) {\n        echo 'Miss';\n    }\n}"
    "Bookkeeping for variable in negative isset() conditional"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '(((18 20) 0) ((33 35) 0))))))
+   '(((18 20) 0) ((33 35) 0)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\nfunction myFunction($a, $b, $c, $d)\n{\n    global $f, $g;\n    
if (isset($f)) {\n        if (!empty($g)) {\n            if ($a) {\n            
    echo 'Hit';\n            }\n            if ($b) {\n                echo 
'Hit';\n            }\n            if ($c) {\n                echo 'Hit';\n     
       }\n            if ($d) {\n                echo 'Hit';\n            }\n   
     }\n    }\n}\n"
    "Bookkeeping variables inside nested isset() !empty() blocks"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" function myFunction id $a" 1) ((28 30) 1) (" function myFunction 
id $b" 1) ((32 34) 1) (" function myFunction id $c" 1) ((36 38) 1) (" function 
myFunction id $d" 1) ((40 42) 1) (" function myFunction id $f" 1) ((57 59) 1) 
(" function myFunction id $g" 1) ((61 63) 1) (" function myFunction defined 1 
id $f" 1) ((79 81) 1) (" function myFunction defined 1 defined 2 id $g" 1) 
((105 107) 1) ((128 130) 1) ((192 194) 1) ((256 258) 1) ((320 322) 1))))))
+   '((" function myFunction id $a" 1) ((28 30) 1) (" function myFunction id 
$b" 1) ((32 34) 1) (" function myFunction id $c" 1) ((36 38) 1) (" function 
myFunction id $d" 1) ((40 42) 1) (" function myFunction id $f" 1) ((57 59) 1) 
(" function myFunction id $g" 1) ((61 63) 1) (" function myFunction defined 1 
id $f" 1) ((79 81) 1) (" function myFunction defined 1 defined 2 id $g" 1) 
((105 107) 1) ((128 130) 1) ((192 194) 1) ((256 258) 1) ((320 322) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n$var = 123;\n\nfunction test($abc) {\n    static $var;\n    if 
($var) {\n        echo 'Hit';\n    }\n}"
    "Bookkeeping of static variable declaration in function"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 39) 1) (" 
function test id $var" 1) ((54 58) 1) ((68 72) 1))))))
+   '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 39) 1) (" 
function test id $var" 1) ((54 58) 1) ((68 72) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\nglobal $a, $b;\n\nif ($a) {\n    echo 'Hit';\n}\n\nfunction 
myFunction($c)\n{\n    global $a;\n    if ($a) {\n        echo 'Hit';\n    }\n  
  if ($b) {\n        echo 'Miss';\n    }\n}\n"
    "Bookkeeping of global variables in functional-oriented file"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $a" 1) ((15 17) 1) (" id $b" 1) ((19 21) 1) ((28 30) 1) (" 
function myFunction id $c" 1) ((73 75) 1) (" function myFunction id $a" 1) ((90 
92) 1) ((102 104) 1) ((142 144) 0))))))
+   '((" id $a" 1) ((15 17) 1) (" id $b" 1) ((19 21) 1) ((28 30) 1) (" function 
myFunction id $c" 1) ((73 75) 1) (" function myFunction id $a" 1) ((90 92) 1) 
((102 104) 1) ((142 144) 0)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\nstatic $a;\n\nif ($a) {}\n\nfunction test()\n{\n    static $a;\n  
  if ($a) {}\n}\n\nclass There\n{\n    function here()\n    {\n        static 
$a;\n        if ($a) {}\n    }\n}"
    "Bookkeeping of static variables in different scopes without namespaces"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $a" 1) ((15 17) 1) ((24 26) 1) (" function test id $a" 1) ((61 
63) 1) ((73 75) 1) (" class There function here id $this" 1) (" class There 
function here id $a" 1) ((138 140) 1) ((154 156) 1))))))
+   '((" id $a" 1) ((15 17) 1) ((24 26) 1) (" function test id $a" 1) ((61 63) 
1) ((73 75) 1) (" class There function here id $this" 1) (" class There 
function here id $a" 1) ((138 140) 1) ((154 156) 1)))
 
-  (phps-mode-test-ast--buffer-contents
-   "<?php\n\nnamespace Here\n{\n    function here()\n    {\n        static 
$a;\n        if ($a) {}\n    }\n    class There\n    {\n        public function 
Near()\n        {\n            static $a;\n            if ($a) {}\n        }\n  
  }\n}\nnamespace\n{\n    static $a;\n    if ($a) {}\n}\n"
-   "Bookkeeping of static variables in different scopes with namespaces"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" namespace Here function here id $a" 1) ((66 68) 1) ((82 84) 1) (" 
namespace Here class There function Near id $this" 1) (" namespace Here class 
There function Near id $a" 1)  ((177 179) 1) ((197 199) 1) (" id $a" 1) ((245 
247) 1) ((257 259) 1))))))
-
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\nclass There\n{\n    private $variable;\n    private \\My\\Random 
$variable2;\n    private string $variable3;\n    private static $variable4;\n   
 private static \\My\\Random $variable5;\n    private static string 
$variable6;\n    function here()\n    {\n        if ($this->variable) {}\n      
  if ($this->variable2) {}\n        if ($this->variable3) {}\n        if 
($this->variable4) {}\n        if (self::$variable4) {}\n        if 
(self::$variable5) {}\n        if (self::$varia [...]
    "Bookkeeping of typed class variables"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" class There id $variable" 1) ((33 42) 1) (" class There id 
$variable2" 1) ((67 77) 1) (" class There id $variable3" 1) ((98 108) 1) (" 
class There static id $variable4" 1) ((129 139) 1) (" class There static id 
$variable5" 1) ((171 181) 1) (" class There static id $variable6" 1) ((209 219) 
1) (" class There function here id $this" 1) ((259 264) 1) ((266 274) 1) ((291 
296) 1) ((298 307) 1) ((324 329) 1) ((331 340) 1) ((357 362) 1) ((364 373) 0) 
((396 406) 1) ((429 439) 1) ((46 [...]
+   '((" class There id $variable" 1) ((33 42) 1) (" class There id $variable2" 
1) ((67 77) 1) (" class There id $variable3" 1) ((98 108) 1) (" class There 
static id $variable4" 1) ((129 139) 1) (" class There static id $variable5" 1) 
((171 181) 1) (" class There static id $variable6" 1) ((209 219) 1) (" class 
There function here id $this" 1) ((259 264) 1) ((266 274) 1) ((291 296) 1) 
((298 307) 1) ((324 329) 1) ((331 340) 1) ((357 362) 1) ((364 373) 0) ((396 
406) 1) ((429 439) 1) ((462 472) 1)))
 
-  (phps-mode-test-ast--buffer-contents
+  (phps-mode-test-ast--should-bookkeep
    "<?php\n\n$a = $b = $c = 3;\n\nif ($a) {\n    echo 'a=',$a;\n} else {\n    
echo '$a is undefined!';\n}\nif ($b) {\n    echo 'b=',$b;\n} else {\n    echo 
'$b is undefined!';\n}\nif ($c) {\n    echo 'c=',$c;\n} else {\n    echo '$c is 
undefined!';\n}"
    "Bookkeeping of chained variable assignments"
-   (lambda()
-     (let ((parse (phps-mode-parser-parse)))
-       (message "Left-to-right with right-most derivation:\n%S\n" parse)
-       (dolist (production-number (reverse 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))))))
-     (phps-mode-ast--generate)
-     (phps-mode-ast-bookkeeping--generate)
-     (should
-      (equal
-       (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-       '((" id $a" 1) ((8 10) 1) (" id $b" 1) ((13 15) 1) (" id $c" 1) ((18 
20) 1) ((31 33) 1) ((51 53) 1) ((99 101) 1) ((119 121) 1) ((167 169) 1) ((187 
189) 1))))))
+   '((" id $a" 1) ((8 10) 1) (" id $b" 1) ((13 15) 1) (" id $c" 1) ((18 20) 1) 
((31 33) 1) ((51 53) 1) ((99 101) 1) ((119 121) 1) ((167 169) 1) ((187 189) 1)))
 
-  ;; TODO Test nullable typed class properties
+  (phps-mode-test-ast--should-bookkeep
+   "<?php\nclass There\n{\n    private $variable;\n    private ?\\My\\Random 
$variable2;\n    private string $variable3;\n    private static $variable4;\n   
 private static \\My\\Random $variable5;\n    private static ?string 
$variable6;\n    function here()\n    {\n        if ($this->variable) {}\n      
  if ($this->variable2) {}\n        if ($this->variable3) {}\n        if 
($this->variable4) {}\n        if (self::$variable4) {}\n        if 
(self::$variable5) {}\n        if (self::$var [...]
+   "Bookkeeping of nullable typed class variables"
+   '((" class There id $variable" 1) ((33 42) 1) (" class There id $variable2" 
1) ((68 78) 1) (" class There id $variable3" 1) ((99 109) 1) (" class There 
static id $variable4" 1) ((130 140) 1) (" class There static id $variable5" 1) 
((172 182) 1) (" class There static id $variable6" 1) ((211 221) 1) (" class 
There function here id $this" 1) ((261 266) 1) ((268 276) 1) ((293 298) 1) 
((300 309) 1) ((326 331) 1) ((333 342) 1) ((359 364) 1) ((366 375) 0) ((398 
408) 1) ((431 441) 1) ((464 474) 1)))
 
-  ;; TODO Test variables inside static function and method
+  ;; TODO Test variables available inside static function and method
 
   ;; TODO Test this and make sure all variables hit
   ;; class myClass { private $test = 'abc'; public function test($d) { return 
fn($d) => $this->test . $d; }} $a = new myClass(); echo $a->test('def')('ghi');



reply via email to

[Prev in Thread] Current Thread [Next in Thread]