From 05006be0d97dce3bc47952d7b88de596bb6b324f Mon Sep 17 00:00:00 2001 From: zappo Date: Sun, 18 Apr 2010 00:33:36 +0000 Subject: [PATCH] Semantic Symref testing. --- test/manual/cedet/cit-symref.el | 99 +++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 test/manual/cedet/cit-symref.el diff --git a/test/manual/cedet/cit-symref.el b/test/manual/cedet/cit-symref.el new file mode 100644 index 00000000000..e24ae485798 --- /dev/null +++ b/test/manual/cedet/cit-symref.el @@ -0,0 +1,99 @@ +;;; cit-symref.el --- +;; +;; Copyright (C) 2010 Eric M. Ludlam +;; +;; Author: Eric M. Ludlam +;; X-RCS: $Id: cit-symref.el,v 1.1 2010-04-18 00:33:36 zappo Exp $ +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: +;; +;; Test the Symref refactoring tool against this made up project. +;; +;; We can't test much in symref in the utest setup because they can't +;; do the refactoring steps, so we have to do them here instead. + +;;; Code: + + +(defun cit-symref () + "Test the symref tool." + ;; Start in a C++ file. + (find-file (cit-file "src/main.cpp")) + + (let* ((target (car cit-symref-operations)) + (dest (car (cdr cit-symref-operations))) + ) + ;; 7 - Run the symref tool + ;; Create the UI + (semantic-symref-symbol target) + (cit-symref-count '(2 3 0 0)) + + ;; expand them all + (semantic-symref-list-expand-all) + (cit-symref-count '(2 3 4 0)) + + ;; Perform a rename. + (semantic-symref-list-rename-open-hits dest) + (save-some-buffers t) + (cit-symref-count '(2 3 4 0)) + + ;; Create a new symref buffer! + (find-file (cit-file "src/main.cpp")) + (semantic-symref-symbol dest) + (cit-symref-count '(2 3 0 0)) + + ;; Compile and run the refactored code. + (find-file (cit-file "src/main.cpp")) + (cit-compile-and-wait) + (find-file (cit-file "src/main.cpp")) + (cit-run-target "./Prog") + )) + +(defun cit-symref-count (expected) + "Count the current results, and return a list of the results. +Argument EXPECTED is the expected result count." + (save-excursion + (goto-char (point-min)) + (sit-for 0) + (let ((files 0) + (hits 0) + (res 0) + (other 0)) + (while (not (eobp)) + (beginning-of-line) + (cond ((looking-at "[^ ]") + (setq files (1+ files))) + ((looking-at " \\[") + (setq hits (1+ hits))) + ((looking-at " ") + (setq res (1+ res))) + (t (setq other (1+ other)))) + (forward-line 1) + (end-of-line)) + (unless (and (= files (nth 0 expected)) + (= hits (nth 1 expected)) + (= res (nth 2 expected)) + (= other (nth 3 expected))) + (error "Symref Missmatch: %S != %S" + (list files hits res other) + expected))))) + + +(provide 'cit-symref) + +;;; cit-symref.el ends here -- 2.39.2