1 ;;; semantic-utest-c.el --- C based parsing tests.
3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; Run some C based parsing tests.
28 (defvar semantic-utest-c-comparisons
29 '( ("testsppreplace.c" .
"testsppreplaced.c")
31 "List of files to parse and compare against eachother.")
35 (defun semantic-utest-c ()
36 "Run parsing test for C from the test directory."
38 (dolist (fp semantic-utest-c-comparisons
)
39 (let* ((sem (locate-library "semantic"))
40 (sdir (file-name-directory sem
))
41 (semantic-lex-c-nested-namespace-ignore-second nil
)
44 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (car fp
)) sdir
)))
45 (semantic-clear-toplevel-cache)
46 (semantic-fetch-tags)))
49 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (cdr fp
)) sdir
)))
50 (semantic-clear-toplevel-cache)
51 (semantic-fetch-tags))))
52 ;; Now that we have the tags, compare them for SPP accuracy.
53 (dolist (tag tags-actual
)
54 (if (and (semantic-tag-of-class-p tag
'variable
)
55 (semantic-tag-variable-constant-p tag
))
56 nil
; skip the macros.
57 (if (semantic-tag-similar-with-subtags-p tag
(car tags-expected
))
58 (setq tags-expected
(cdr tags-expected
))
59 (with-mode-local c-mode
60 (error "Found: >> %s << Expected: >> %s <<"
61 (semantic-format-tag-prototype tag nil t
)
62 (semantic-format-tag-prototype (car tags-expected
) nil t
)
70 (provide 'semantic-utest-c
)
72 ;; arch-tag: a90183e0-36ba-486e-9adb-8d37c929e6ba
73 ;;; semantic-utest-c.el ends here