semantic-utest-c.el 2.4 KB

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