From 7f2baf2c680cf82ba18c58920ff0dda609a9eacf Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Thu, 31 Aug 2023 17:13:23 +0200 Subject: [PATCH] Make phpinspect--match-sequence return nil unless entire sequence matches --- phpinspect-util.el | 4 ++-- test/test-util.el | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/phpinspect-util.el b/phpinspect-util.el index d5fb8a9..4f4e351 100644 --- a/phpinspect-util.el +++ b/phpinspect-util.el @@ -238,8 +238,8 @@ it evaluates to a non-nil value." (,match-sym (cons nil nil)) (,match-rear-sym ,match-sym)) (and (= ,sequence-length (length ,sequence)) - ,@checkers) - (cdr ,match-sym)))) + ,@checkers + (cdr ,match-sym))))) (defun phpinspect--pattern-concat (pattern1 pattern2) (let* ((pattern1-sequence-length (/ (length (phpinspect--pattern-code pattern1)) 2))) diff --git a/test/test-util.el b/test/test-util.el index 72ce39f..2e708dc 100644 --- a/test/test-util.el +++ b/test/test-util.el @@ -48,3 +48,10 @@ (should (equal '(:m "a" :m * :m "b" :f stringp :m * :m "D") (phpinspect--pattern-code result))) (should (phpinspect--pattern-match result '("a" "anything" "b" "astring" nil "D"))))) + +(ert-deftest phpinspect--pattern-match-partially () + (let ((result (phpinspect--match-sequence '((:variable "this") (:object-attrib (:word "em"))) + :m '(:variable "this") + :m '(:object-attrib (:word "not-a-match"))))) + + (should-not result)))