test/cedet/ede-tests.el: New file.
[bpt/emacs.git] / test / cedet / semantic-utest-c.el
1 ;;; semantic-utest-c.el --- C based parsing tests.
2
3 ;; Copyright (C) 2008, 2009 Eric M. Ludlam
4
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6 ;; X-RCS: $Id: semantic-utest-c.el,v 1.5 2009/08/30 12:30:14 zappo Exp $
7
8 ;; This program is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation; either version 2, or (at
11 ;; your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ;; General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22
23 ;;; Commentary:
24 ;;
25 ;; Run some C based parsing tests.
26
27 (require 'semantic)
28
29 (defvar semantic-utest-c-comparisons
30 '( ("testsppreplace.c" . "testsppreplaced.c")
31 )
32 "List of files to parse and compare against eachother.")
33
34 ;;; Code:
35 ;;;###autoload
36 (defun semantic-utest-c ()
37 "Run parsing test for C from the test directory."
38 (interactive)
39 (dolist (fp semantic-utest-c-comparisons)
40 (let* ((sem (locate-library "semantic"))
41 (sdir (file-name-directory sem))
42 (semantic-lex-c-nested-namespace-ignore-second nil)
43 (tags-actual
44 (save-excursion
45 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (car fp)) sdir)))
46 (semantic-clear-toplevel-cache)
47 (semantic-fetch-tags)))
48 (tags-expected
49 (save-excursion
50 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (cdr fp)) sdir)))
51 (semantic-clear-toplevel-cache)
52 (semantic-fetch-tags))))
53 ;; Now that we have the tags, compare them for SPP accuracy.
54 (dolist (tag tags-actual)
55 (if (and (semantic-tag-of-class-p tag 'variable)
56 (semantic-tag-variable-constant-p tag))
57 nil ; skip the macros.
58 (if (semantic-tag-similar-with-subtags-p tag (car tags-expected))
59 (setq tags-expected (cdr tags-expected))
60 (with-mode-local c-mode
61 (error "Found: >> %s << Expected: >> %s <<"
62 (semantic-format-tag-prototype tag nil t)
63 (semantic-format-tag-prototype (car tags-expected) nil t)
64 )))
65 ))
66 ;; Passed?
67 (message "PASSED!")
68 )))
69
70
71 (provide 'semantic-utest-c)
72 ;;; semantic-utest-c.el ends here