annotate test/cedet/semantic-utest-c.el @ 105273:b9edaeacd0e7

* org-agenda.el (org-agenda-restore-windows-after-quit): Fix typo in docstring.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 29 Sep 2009 02:19:06 +0000
parents c99cf31de3f2
children 2f1ad455dc64
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
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;; Copyright (C) 2008, 2009 Eric M. Ludlam
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>
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; X-RCS: $Id: semantic-utest-c.el,v 1.1.2.1 2009/09/20 04:00:16 cyd Exp $
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; This program is free software; you can redistribute it and/or
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; modify it under the terms of the GNU General Public License as
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; published by the Free Software Foundation; either version 2, or (at
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; your option) any later version.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; This program is distributed in the hope that it will be useful, but
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; General Public License for more details.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; along with this program; see the file COPYING. If not, write to
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; Boston, MA 02110-1301, USA.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;; Commentary:
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; Run some C based parsing tests.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 (require 'semantic)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 (defvar semantic-utest-c-comparisons
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 '( ("testsppreplace.c" . "testsppreplaced.c")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 )
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 "List of files to parse and compare against eachother.")
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;; Code:
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;;;###autoload
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 (defun semantic-utest-c ()
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 "Run parsing test for C from the test directory."
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (interactive)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (dolist (fp semantic-utest-c-comparisons)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (let* ((sem (locate-library "semantic"))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (sdir (file-name-directory sem))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (semantic-lex-c-nested-namespace-ignore-second nil)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (tags-actual
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 (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
46 (semantic-clear-toplevel-cache)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (semantic-fetch-tags)))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (tags-expected
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (save-excursion
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (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
51 (semantic-clear-toplevel-cache)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (semantic-fetch-tags))))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;; Now that we have the tags, compare them for SPP accuracy.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (dolist (tag tags-actual)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (if (and (semantic-tag-of-class-p tag 'variable)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 (semantic-tag-variable-constant-p tag))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 nil ; skip the macros.
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (if (semantic-tag-similar-with-subtags-p tag (car tags-expected))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (setq tags-expected (cdr tags-expected))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 (with-mode-local c-mode
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (error "Found: >> %s << Expected: >> %s <<"
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (semantic-format-tag-prototype tag nil t)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 (semantic-format-tag-prototype (car tags-expected) nil t)
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 ))
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 ;; Passed?
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 (message "PASSED!")
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
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (provide 'semantic-utest-c)
c99cf31de3f2 Add CEDET tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;;; semantic-utest-c.el ends here