emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master ffbb468: Add obarray-size and fix tests accordingly


From: Stefan Monnier
Subject: [Emacs-diffs] master ffbb468: Add obarray-size and fix tests accordingly. Use obarrayp in cedet.
Date: Thu, 16 Mar 2017 12:31:16 -0400 (EDT)

branch: master
commit ffbb46849990bf4bf952e01b78c9a1a0ca0d4432
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    Add obarray-size and fix tests accordingly.  Use obarrayp in cedet.
    
    * lisp/obarray.el (obarray-size): New function.
    
    * lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-symbol)
    (semantic-lex-spp-save-table, semantic-lex-spp-macros):
    * lisp/cedet/semantic/bovine/c.el (semantic-c-describe-environment):
    Use obarrayp.
    
    * test/lisp/obarray-tests.el (obarray-make-default-test)
    (obarray-make-with-size-test): Use it.
---
 lisp/cedet/semantic/bovine/c.el |  2 +-
 lisp/cedet/semantic/lex-spp.el  | 14 +++++++-------
 lisp/obarray.el                 |  4 ++++
 test/lisp/obarray-tests.el      |  6 ++++--
 4 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el
index bef4b17..3200a5c 100644
--- a/lisp/cedet/semantic/bovine/c.el
+++ b/lisp/cedet/semantic/bovine/c.el
@@ -2253,7 +2253,7 @@ actually in their parent which is not accessible.")
          (princ "      Your project symbol map is also derived from the EDE 
object:\n      ")
          (princ (object-print ede-object)))
        (princ "\n\n")
-       (if (arrayp semantic-lex-spp-project-macro-symbol-obarray)
+       (if (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
            (let ((macros nil))
              (mapatoms
               #'(lambda (symbol)
diff --git a/lisp/cedet/semantic/lex-spp.el b/lisp/cedet/semantic/lex-spp.el
index 8d6467e..cb33e48 100644
--- a/lisp/cedet/semantic/lex-spp.el
+++ b/lisp/cedet/semantic/lex-spp.el
@@ -147,13 +147,13 @@ The search priority is:
    ;; Do the check of the various tables.
    (or
     ;; DYNAMIC
-    (and (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
+    (and (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
         (intern-soft name semantic-lex-spp-dynamic-macro-symbol-obarray))
     ;; PROJECT
-    (and (arrayp semantic-lex-spp-project-macro-symbol-obarray)
+    (and (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
         (intern-soft name semantic-lex-spp-project-macro-symbol-obarray))
     ;; SYSTEM
-    (and (arrayp semantic-lex-spp-macro-symbol-obarray)
+    (and (obarrayp semantic-lex-spp-macro-symbol-obarray)
         (intern-soft name semantic-lex-spp-macro-symbol-obarray))
     ;; ...
     )))
@@ -291,7 +291,7 @@ REPLACEMENT a string that would be substituted in for NAME."
   "Return a list of spp macros and values.
 The return list is meant to be saved in a semanticdb table."
   (let (macros)
-    (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons (cons (symbol-name symbol)
@@ -304,17 +304,17 @@ The return list is meant to be saved in a semanticdb 
table."
   "Return a list of spp macros as Lisp symbols.
 The value of each symbol is the replacement stream."
   (let (macros)
-    (when (arrayp semantic-lex-spp-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons symbol macros)))
        semantic-lex-spp-macro-symbol-obarray))
-    (when (arrayp semantic-lex-spp-project-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-project-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons symbol macros)))
        semantic-lex-spp-project-macro-symbol-obarray))
-    (when (arrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
+    (when (obarrayp semantic-lex-spp-dynamic-macro-symbol-obarray)
       (mapatoms
        #'(lambda (symbol)
           (setq macros (cons symbol macros)))
diff --git a/lisp/obarray.el b/lisp/obarray.el
index aaffe00..a463185 100644
--- a/lisp/obarray.el
+++ b/lisp/obarray.el
@@ -37,6 +37,10 @@
         (make-vector size 0)
       (signal 'wrong-type-argument '(size 0)))))
 
+(defun obarray-size (obarray)
+  "Return the number of slots of OBARRAY."
+  (length obarray))
+
 (defun obarrayp (object)
   "Return t if OBJECT is an obarray."
   (and (vectorp object)
diff --git a/test/lisp/obarray-tests.el b/test/lisp/obarray-tests.el
index 9a2d65d..4908b88 100644
--- a/test/lisp/obarray-tests.el
+++ b/test/lisp/obarray-tests.el
@@ -43,14 +43,16 @@
 (ert-deftest obarray-make-default-test ()
   (let ((table (obarray-make)))
     (should (obarrayp table))
-    (should (equal (make-vector 59 0) table))))
+    (should (eq (obarray-size table) obarray-default-size))))
 
 (ert-deftest obarray-make-with-size-test ()
+  ;; FIXME: Actually, `wrong-type-argument' is not the right error to signal,
+  ;; so we shouldn't enforce this misbehavior in tests!
   (should-error (obarray-make -1) :type 'wrong-type-argument)
   (should-error (obarray-make 0) :type 'wrong-type-argument)
   (let ((table (obarray-make 1)))
     (should (obarrayp table))
-    (should (equal (make-vector 1 0) table))))
+    (should (eq (obarray-size table) 1))))
 
 (ert-deftest obarray-get-test ()
   (let ((table (obarray-make 3)))



reply via email to

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