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

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

[elpa] externals/phpinspect 69f2907ebd 3/3: Add test for suggest-variabl


From: ELPA Syncer
Subject: [elpa] externals/phpinspect 69f2907ebd 3/3: Add test for suggest-variables-at-point within foreach block + fix bug
Date: Mon, 2 Sep 2024 15:58:53 -0400 (EDT)

branch: externals/phpinspect
commit 69f2907ebd6edb976f7d63f73ec42566dd30ed3e
Author: Hugo Thunnissen <devel@hugot.nl>
Commit: Hugo Thunnissen <devel@hugot.nl>

    Add test for suggest-variables-at-point within foreach block + fix bug
---
 phpinspect-suggest.el |  2 +-
 test/test-fs.el       |  2 +-
 test/test-suggest.el  | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/phpinspect-suggest.el b/phpinspect-suggest.el
index 98ebfec1b0..24e821a8a3 100644
--- a/phpinspect-suggest.el
+++ b/phpinspect-suggest.el
@@ -57,7 +57,7 @@
                      (puthash (cadr argument)
                               (phpinspect--make-variable :name (cadr argument))
                               variables))))
-                ((phpinspect-block-p potential-variable)
+                ((phpinspect-block-or-list-p potential-variable)
                  (dolist (nested-token (cdr potential-variable))
                    (push nested-token token-list))))))))
 
diff --git a/test/test-fs.el b/test/test-fs.el
index baec5c4f79..8d10b87da7 100644
--- a/test/test-fs.el
+++ b/test/test-fs.el
@@ -1,4 +1,4 @@
-;;; test-autoload.el --- Unit tests for phpinspect.el  -*- lexical-binding: t; 
-*-
+;;; test-fs.el --- Unit tests for phpinspect.el  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2021-2023 Free Software Foundation, Inc.
 
diff --git a/test/test-suggest.el b/test/test-suggest.el
new file mode 100644
index 0000000000..eee25279f5
--- /dev/null
+++ b/test/test-suggest.el
@@ -0,0 +1,46 @@
+;;; test-suggest.el --- Unit tests for phpinspect-suggest.el  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2021-2023 Free Software Foundation, Inc.
+
+;; Author: Hugo Thunnissen <devel@hugot.nl>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'phpinspect-suggest)
+(require 'phpinspect-buffer)
+(require 'ert)
+
+(require 'phpinspect-test-env
+         (expand-file-name "phpinspect-test-env.el"
+                           (file-name-directory (macroexp-file-name))))
+
+(ert-deftest phpinspect-suggest-variables-at-point-foreach ()
+  (with-temp-buffer
+    (insert "<?php foreach ($array as $key => $value) {")
+
+    (let* ((buffer (phpinspect-make-buffer :buffer (current-buffer)))
+
+          (rctx (phpinspect-get-resolvecontext
+                 (phpinspect--make-dummy-project) (phpinspect-buffer-parse-map 
buffer) (point)))
+          (variables (phpinspect-suggest-variables-at-point rctx)))
+
+      (should (length= variables 3))
+      (should (equal (list "array" "key" "value")
+                    (sort (mapcar #'phpi-var-name variables) #'string<))))))



reply via email to

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