(scheme-in-list): Add a fallback to create an error tag.
[cedet.git] / tests / cit-symref.el
blob5c1d8fda6e07437ea6cb5a5e3b7cf4b0931995e3
1 ;;; cit-symref.el ---
2 ;;
3 ;; Copyright (C) 2010 Eric M. Ludlam
4 ;;
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 ;;
7 ;; This program is free software; you can redistribute it and/or
8 ;; modify it under the terms of the GNU General Public License as
9 ;; published by the Free Software Foundation; either version 2, or (at
10 ;; your option) any later version.
12 ;; This program is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
22 ;;; Commentary:
24 ;; Test the Symref refactoring tool against this made up project.
26 ;; We can't test much in symref in the utest setup because they can't
27 ;; do the refactoring steps, so we have to do them here instead.
29 ;;; Code:
32 (defun cit-symref ()
33 "Test the symref tool."
34 (save-excursion
35 ;; Start in a C++ file.
36 (find-file (cit-file "src/main.cpp"))
38 (let* ((target (car cit-symref-operations))
39 (dest (car (cdr cit-symref-operations)))
41 ;; 7 - Run the symref tool
42 ;; Create the UI
43 (semantic-symref-symbol target)
44 (cit-symref-count '(2 3 0 0))
46 ;; expand them all
47 (semantic-symref-list-expand-all)
48 (cit-symref-count '(2 3 4 0))
50 ;; Perform a rename.
51 (semantic-symref-list-rename-open-hits dest)
52 (save-some-buffers t)
53 (cit-symref-count '(2 3 4 0))
55 ;; Create a new symref buffer!
56 (find-file (cit-file "src/main.cpp"))
57 (semantic-symref-symbol dest)
58 (cit-symref-count '(2 3 0 0))
60 ;; Compile and run the refactored code.
61 (find-file (cit-file "src/main.cpp"))
62 (cit-compile-and-wait)
63 (find-file (cit-file "src/main.cpp"))
64 (cit-run-target "./Prog")
65 )))
67 (defun cit-symref-quick-find-test ()
68 "Test symref finding something, but not the more detailed test."
69 (save-excursion
70 ;; Start in a C++ file.
71 (find-file (cit-file "src/main.cpp"))
73 ;; Force new detection for every test.
74 (setq semantic-symref-tool 'detect)
76 ;; 7 - Run the symref tool
77 ;; Create the UI
78 (semantic-symref-regexp "doSomethingPublic")
80 (cit-symref-count '(3 3 0 0))
83 (defun cit-symref-count (expected)
84 "Count the current results, and return a list of the results.
85 Argument EXPECTED is the expected result count."
86 (save-excursion
87 (goto-char (point-min))
88 (sit-for .1)
89 (let ((files 0)
90 (hits 0)
91 (res 0)
92 (other 0))
93 (while (not (eobp))
94 (beginning-of-line)
95 (cond ((looking-at "[^ ]")
96 (setq files (1+ files)))
97 ((looking-at " \\[")
98 (setq hits (1+ hits)))
99 ((looking-at " ")
100 (setq res (1+ res)))
101 (t (setq other (1+ other))))
102 (forward-line 1)
103 (end-of-line))
104 (unless (and (= files (nth 0 expected))
105 (= hits (nth 1 expected))
106 (= res (nth 2 expected))
107 (= other (nth 3 expected)))
108 (error "Symref Missmatch: %S != %S"
109 (list files hits res other)
110 expected)))))
113 (provide 'cit-symref)
115 ;;; cit-symref.el ends here