Demonstrate pre-lexbind bug through registry.el ERT tests.
authorTed Zlatanov <tzz@lifelogs.com>
Tue, 5 Apr 2011 16:08:51 +0000 (11:08 -0500)
committerTed Zlatanov <tzz@lifelogs.com>
Tue, 5 Apr 2011 16:08:51 +0000 (11:08 -0500)
* (registry-lookup-breaks-before-lexbind): New method to demonstrate
pre-lexbind merge bug.
(registry-usage-test): Use it.

lisp/ChangeLog
lisp/registry.el

index f790f53..114c20e 100644 (file)
@@ -2,6 +2,9 @@
 
        * registry.el (registry-db, initialize-instance): Set up constructor
        instead of :initform arguments for the sake of older Emacsen.
+       (registry-lookup-breaks-before-lexbind): New method to demonstrate
+       pre-lexbind merge bug.
+       (registry-usage-test): Use it.
 
        * gnus-registry.el (gnus-registry-fixup-registry): New function to
        fixup the parameters that can be customized by the user between
index ef78fec..6933725 100644 (file)
@@ -147,6 +147,15 @@ Returns a alist of the key followed by the entry in a list, not a cons cell."
                (list k (gethash k data))))
            keys))))
 
+(defmethod registry-lookup-breaks-before-lexbind ((db registry-db) keys)
+  "Search for KEYS in the registry-db THIS.
+Returns a alist of the key followed by the entry in a list, not a cons cell."
+  (let ((data (oref db :data)))
+    (delq nil
+          (loop for key in keys
+                when (gethash key data)
+                collect (list key (gethash key data))))))
+
 (defmethod registry-lookup-secondary ((db registry-db) tracksym
                                       &optional create)
   "Search for TRACKSYM in the registry-db THIS.
@@ -345,6 +354,12 @@ Removes only entries without the :precious keys."
     (should (= 58 (caadr (registry-lookup db '(1 58 99)))))
     (message "Grouped individual lookup")
     (should (= 3 (length (registry-lookup db '(1 58 99)))))
+    (message "Individual lookup (breaks before lexbind)")
+    (should (= 58
+               (caadr (registry-lookup-breaks-before-lexbind db '(1 58 99)))))
+    (message "Grouped individual lookup (breaks before lexbind)")
+    (should (= 3
+               (length (registry-lookup-breaks-before-lexbind db '(1 58 99)))))
     (message "Search")
     (should (= n (length (registry-search db :all t))))
     (should (= n (length (registry-search db :member '((sender "me"))))))