]> code.delx.au - gnu-emacs/blob - test/manual/cedet/semantic-utest-c.el
Merge from origin/emacs-25
[gnu-emacs] / test / manual / cedet / semantic-utest-c.el
1 ;;; semantic-utest-c.el --- C based parsing tests.
2
3 ;; Copyright (C) 2008-2016 Free Software Foundation, Inc.
4
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6
7 ;; This file is part of GNU Emacs.
8
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.
13
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.
18
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/>.
21
22 ;;; Commentary:
23 ;;
24 ;; Run some C based parsing tests.
25
26 (require 'semantic)
27
28 (defvar semantic-utest-c-comparisons
29 '( ("testsppreplace.c" . "testsppreplaced.c")
30 )
31 "List of files to parse and compare against each other.")
32
33 ;;; Code:
34 ;;;###autoload
35 (defun semantic-utest-c ()
36 "Run parsing test for C from the test directory."
37 (interactive)
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)
42 (tags-actual
43 (save-excursion
44 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (car fp)) sdir)))
45 (semantic-clear-toplevel-cache)
46 (semantic-fetch-tags)))
47 (tags-expected
48 (save-excursion
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)
63 )))
64 ))
65 ;; Passed?
66 (message "PASSED!")
67 )))
68
69
70 (provide 'semantic-utest-c)
71
72 ;;; semantic-utest-c.el ends here