annotate test/cedet/semantic-utest-c.el @ 112293:568ea4e08e90

* xterm.h (struct x_display_info): Remove stray semicolon. The extra semicolon didn't conform to the C standard. Problem reported by Sun cc.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 16 Jan 2011 23:27:25 -0800
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; semantic-utest-c.el --- C based parsing tests.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
3 ;; Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
105301
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
6
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
7 ;; This file is part of GNU Emacs.
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
105301
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
12 ;; (at your option) any later version.
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
105301
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
17 ;; GNU General Public License for more details.
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
105301
2f1ad455dc64 Relicense under GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 105267
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Run some C based parsing tests.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 (require 'semantic)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 (defvar semantic-utest-c-comparisons
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 '( ("testsppreplace.c" . "testsppreplaced.c")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 "List of files to parse and compare against eachother.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;; Code:
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;;###autoload
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 (defun semantic-utest-c ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 "Run parsing test for C from the test directory."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 (interactive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (dolist (fp semantic-utest-c-comparisons)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (let* ((sem (locate-library "semantic"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (sdir (file-name-directory sem))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (semantic-lex-c-nested-namespace-ignore-second nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (tags-actual
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (car fp)) sdir)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 (semantic-clear-toplevel-cache)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 (semantic-fetch-tags)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (tags-expected
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (set-buffer (find-file-noselect (expand-file-name (concat "tests/" (cdr fp)) sdir)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (semantic-clear-toplevel-cache)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 (semantic-fetch-tags))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ;; Now that we have the tags, compare them for SPP accuracy.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 (dolist (tag tags-actual)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (if (and (semantic-tag-of-class-p tag 'variable)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (semantic-tag-variable-constant-p tag))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 nil ; skip the macros.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (if (semantic-tag-similar-with-subtags-p tag (car tags-expected))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (setq tags-expected (cdr tags-expected))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (with-mode-local c-mode
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (error "Found: >> %s << Expected: >> %s <<"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (semantic-format-tag-prototype tag nil t)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (semantic-format-tag-prototype (car tags-expected) nil t)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 )))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;; Passed?
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 (message "PASSED!")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 )))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 (provide 'semantic-utest-c)
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105301
diff changeset
71
105267
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;;; semantic-utest-c.el ends here