1 ;;; semantic-utest-c.el --- C based parsing tests.
3 ;; Copyright (C) 2008, 2009 Eric M. Ludlam
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 $
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.
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.
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.
25 ;; Run some C based parsing tests.
29 (defvar semantic-utest-c-comparisons
30 '( ("testsppreplace.c" .
"testsppreplaced.c")
32 "List of files to parse and compare against eachother.")
36 (defun semantic-utest-c ()
37 "Run parsing test for C from the test directory."
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
)
45 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (car fp
)) sdir
)))
46 (semantic-clear-toplevel-cache)
47 (semantic-fetch-tags)))
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
)
71 (provide 'semantic-utest-c
)
72 ;;; semantic-utest-c.el ends here