Fix bug #8047 with require-final-newline in binary image buffers.
[bpt/emacs.git] / test / cedet / semantic-ia-utest.el
index 92dbaba..7650291 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic-ia-utest.el --- Analyzer unit tests
 
-;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2011 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
@@ -416,6 +416,27 @@ Argument ARG specifies which set of tests to run.
 
     ))
 
+(defun semantic-symref-test-count-hits-in-tag ()
+  "Lookup in the current tag the symbol under point.
+Then count all the other references to the same symbol within the
+tag that contains point, and return that."
+  (interactive)
+  (let* ((ctxt (semantic-analyze-current-context))
+        (target (car (reverse (oref ctxt prefix))))
+        (tag (semantic-current-tag))
+        (start (current-time))
+        (Lcount 0))
+    (when (semantic-tag-p target)
+      (semantic-symref-hits-in-region
+       target (lambda (start end prefix) (setq Lcount (1+ Lcount)))
+       (semantic-tag-start tag)
+       (semantic-tag-end tag))
+      (when (interactive-p)
+       (message "Found %d occurrences of %s in %.2f seconds"
+                Lcount (semantic-tag-name target)
+                (semantic-elapsed-time start (current-time))))
+      Lcount)))
+
 (defun semantic-src-utest-buffer-refs ()
   "Run a sym-ref counting unit-test pass in the current buffer."
 
@@ -504,5 +525,4 @@ Pass ARGS to format to create the log message."
 
 (provide 'semantic-ia-utest)
 
-;; arch-tag: 03ede3fb-7ef0-4500-a7c2-bbf647957310
 ;;; semantic-ia-utest.el ends here