3 ;; Copyright (C) 2010 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
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.
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.
33 "Test the symref tool."
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
43 (semantic-symref-symbol target
)
44 (cit-symref-count '(2 3 0 0))
47 (semantic-symref-list-expand-all)
48 (cit-symref-count '(2 3 4 0))
51 (semantic-symref-list-rename-open-hits dest
)
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")
67 (defun cit-symref-quick-find-test ()
68 "Test symref finding something, but not the more detailed test."
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
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."
87 (goto-char (point-min))
95 (cond ((looking-at "[^ ]")
96 (setq files
(1+ files
)))
98 (setq hits
(1+ hits
)))
101 (t (setq other
(1+ other
))))
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
)
113 (provide 'cit-symref
)
115 ;;; cit-symref.el ends here