1 ;;; semantic-utest.el --- Tests for semantic's parsing system.
3 ;;; Copyright (C) 2003-2004, 2007-2011 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
24 ;; Semantic's parsing and partial parsing system is pretty complex.
25 ;; These unit tests attempt to emulate semantic's partial reparsing
26 ;; and full reparsing system, and anything else I may feel the urge
27 ;; to write a test for.
31 (load-file "cedet-utests.el")
33 (defvar semantic-utest-temp-directory
(if (fboundp 'temp-directory
)
35 temporary-file-directory
)
36 "Temporary directory to use when creating files.")
38 (defun semantic-utest-fname (name)
39 "Create a filename for NAME in /tmp."
40 (expand-file-name name semantic-utest-temp-directory
))
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45 (defvar semantic-utest-C-buffer-contents
46 "/* Test file for C language for Unit Tests */
59 float funp1(char arg11, char arg12);
61 char fun2(int arg_21, int arg_22) /*1*/
63 struct mystruct1 *ms1 = malloc(sizeof(struct mystruct1));
65 char sv = calc_sv(var1);
69 } else if (arg_21 == 0) {
71 } else if (arg_22 == 0) {
77 printf(\"SV = %d\\n\", sv);
85 "Contents of a C buffer initialized by this unit test.
86 Be sure to change `semantic-utest-C-name-contents' when you
87 change this variable.")
89 (defvar semantic-utest-C-h-buffer-contents
90 "/* Test file for C language header file for Unit Tests */
95 "Contents of a C header file buffer initialized by this unit test.")
97 (defvar semantic-utest-C-filename
(semantic-utest-fname "sutest.c")
98 "File to open and erase during this test for C.")
100 (defvar semantic-utest-C-filename-h
101 (concat (file-name-sans-extension semantic-utest-C-filename
)
103 "Header file filename for C")
106 (defvar semantic-utest-C-name-contents
109 nil
(overlay 48 66 "sutest.c"))
110 ("sutest.h" include nil nil
(overlay 67 86 "sutest.c"))
115 (reparse-symbol classsubparts
)
116 (overlay 109 120 "sutest.c"))
119 (reparse-symbol classsubparts
)
120 (overlay 123 135 "sutest.c"))
123 (reparse-symbol classsubparts
)
124 (overlay 138 151 "sutest.c")))
126 nil
(overlay 88 154 "sutest.c"))
129 nil
(overlay 156 165 "sutest.c"))
131 (:prototype-flag t
:arguments
134 (reparse-symbol arg-sub-list
)
135 (overlay 179 190 "sutest.c"))
138 (reparse-symbol arg-sub-list
)
139 (overlay 191 202 "sutest.c")))
141 nil
(overlay 167 203 "sutest.c"))
146 (reparse-symbol arg-sub-list
)
147 (overlay 215 226 "sutest.c"))
150 (reparse-symbol arg-sub-list
)
151 (overlay 227 238 "sutest.c")))
153 nil
(overlay 205 566 "sutest.c")))
154 "List of expected tag names for C.")
157 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
158 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
159 ;; Data for Python tests
161 (defvar semantic-utest-Python-buffer-contents
173 ; "pyhon test case. notice that python is indentation sensitive
176 (defvar semantic-utest-Python-name-contents
180 (reparse-symbol function_parameters
)
181 (overlay 10 11 "tst.py"))
183 (reparse-symbol function_parameters
)
184 (overlay 12 13 "tst.py"))
186 (reparse-symbol function_parameters
)
187 (overlay 14 15 "tst.py"))))
188 nil
(overlay 1 31 "tst.py"))
192 (reparse-symbol function_parameters
)
193 (overlay 41 42 "tst.py"))
195 (reparse-symbol function_parameters
)
196 (overlay 43 44 "tst.py"))
198 (reparse-symbol function_parameters
)
199 (overlay 45 46 "tst.py"))))
200 nil
(overlay 32 65 "tst.py")))
202 "List of expected tag names for Python.")
206 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
208 ;; Data for Java tests
210 (defvar semantic-utest-Java-buffer-contents
213 void fun1(int a,int b){
217 void fun2(int a,int b){ //1
225 (defvar semantic-utest-Java-name-contents
232 (reparse-symbol formal_parameters
)
233 (overlay 30 35 "JavaTest.java"))
236 (reparse-symbol formal_parameters
)
237 (overlay 36 41 "JavaTest.java")))
239 (reparse-symbol class_member_declaration
)
240 (overlay 20 61 "JavaTest.java"))
245 (reparse-symbol formal_parameters
)
246 (overlay 75 80 "JavaTest.java"))
249 (reparse-symbol formal_parameters
)
250 (overlay 81 86 "JavaTest.java")))
252 (reparse-symbol class_member_declaration
)
253 (overlay 65 110 "JavaTest.java")))
255 nil
(overlay 2 113 "JavaTest.java")))
256 "List of expected tag names for Java."
260 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
262 ;; Data for Javascript tests
264 (defvar semantic-utest-Javascript-buffer-contents
270 function fun2(a,b){ //1
277 (defvar semantic-utest-Javascript-name-contents
281 (reparse-symbol FormalParameterList
)
282 (overlay 15 16 "tst.js"))
284 (reparse-symbol FormalParameterList
)
285 (overlay 18 19 "tst.js"))))
286 nil
(overlay 1 39 "tst.js"))
290 (reparse-symbol FormalParameterList
)
291 (overlay 55 56 "tst.js"))
293 (reparse-symbol FormalParameterList
)
294 (overlay 57 58 "tst.js"))))
295 nil
(overlay 41 82 "tst.js")))
297 "List of expected tag names for Javascript.")
301 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
303 ;; Data for Makefile tests
305 (defvar semantic-utest-Makefile-buffer-contents
318 (defvar semantic-utest-Makefile-name-contents
319 '(("t1" function nil nil
(overlay 1 9 "Makefile"))
323 nil
(overlay 18 28 "Makefile")))
324 "List of expected tag names for Makefile.")
327 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
328 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
329 ;; Data for Scheme tests
331 (defvar semantic-utest-Scheme-buffer-contents
339 (defvar semantic-utest-Scheme-name-contents
341 (:default-value
("2"))
342 nil
(overlay 3 18 "tst.scm"))
344 (:default-value
("3"))
345 nil
(overlay 21 55 "tst.scm")))
348 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
349 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
350 ;; Data for Html tests
352 (defvar semantic-utest-Html-buffer-contents
362 (defvar semantic-utest-Html-name-contents
365 (("hello" section nil nil
(overlay 21 24 "tst.html"))))
366 nil
(overlay 10 15 "tst.html")))
370 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
372 ;; Data for PHP tests
374 (defvar semantic-utest-PHP-buffer-contents
381 function fun2($arg1){
382 $output = \"argument to fun2: \" . $arg1;
387 public function fun1($a, $b){
391 public function fun2($a, $b){
398 (defvar semantic-utest-PHP-name-contents
399 '(("fun1" function nil
400 nil
(overlay 9 45 "phptest.php"))
402 (:arguments
(("$arg1" variable nil
(reparse-symbol formal_parameters
) (overlay 61 66 "phptest.php"))))
404 (overlay 47 132 "phptest.php"))
406 (:members
(("fun1" function
407 (:typemodifiers
("public") :arguments
408 (("$a" variable nil
(reparse-symbol formal_parameters
) (overlay 174 176 "phptest.php"))
409 ("$b" variable nil
(reparse-symbol formal_parameters
) (overlay 178 180 "phptest.php"))))
412 (overlay 153 204 "phptest.php"))
415 (:typemodifiers
("public") :arguments
416 (("$a" variable nil
(reparse-symbol formal_parameters
) (overlay 230 232 "phptest.php"))
417 ("$b" variable nil
(reparse-symbol formal_parameters
) (overlay 234 236 "phptest.php"))
420 (overlay 209 260 "phptest.php"))) :type
"class")
422 (overlay 135 262 "phptest.php"))
424 "Expected results from the PHP Unit test"
427 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
428 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
429 ;; Data for Csharp C# tests
431 (defvar semantic-utest-Csharp-buffer-contents
434 int fun1(int a, int b) {
436 int fun2(int a, int b) {
441 (defvar semantic-utest-Csharp-name-contents
448 (reparse-symbol formal_parameters
)
449 (overlay 30 35 "tst.cs"))
452 (reparse-symbol formal_parameters
)
453 (overlay 37 42 "tst.cs")))
455 (reparse-symbol class_member_declaration
)
456 (overlay 21 61 "tst.cs"))
461 (reparse-symbol formal_parameters
)
462 (overlay 73 78 "tst.cs"))
465 (reparse-symbol formal_parameters
)
466 (overlay 80 85 "tst.cs")))
468 (reparse-symbol class_member_declaration
)
469 (overlay 64 104 "tst.cs")))
471 nil
(overlay 1 106 "tst.cs")))
475 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
476 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
480 (defun semantic-utest-makebuffer (filename contents
)
481 "Create a buffer for FILENAME for use in a unit test.
482 Pre-fill the buffer with CONTENTS."
483 (let ((buff (semantic-find-file-noselect filename
)))
485 (setq buffer-offer-save nil
)
486 (font-lock-mode -
1) ;; Font lock has issues in Emacs 23
487 (toggle-read-only -
1) ;; In case /tmp doesn't exist.
490 ;(semantic-fetch-tags) ;JAVE could this go here?
491 (set-buffer-modified-p nil
)
496 (defun semantic-utest-C ()
497 "Run semantic's C unit test."
500 (let ((buff (semantic-utest-makebuffer semantic-utest-C-filename semantic-utest-C-buffer-contents
))
501 (buff2 (semantic-utest-makebuffer semantic-utest-C-filename-h semantic-utest-C-h-buffer-contents
))
503 (semantic-fetch-tags)
506 ;; Turn off a range of modes
507 (semantic-idle-scheduler-mode -
1)
509 ;; Turn on some modes
510 (semantic-highlight-edits-mode 1)
512 ;; Update tags, and show it.
513 (semantic-fetch-tags)
515 (switch-to-buffer buff
)
519 ;;(message "First parsing test.")
520 (semantic-utest-verify-names semantic-utest-C-name-contents
)
522 ;;(message "Invalid tag test.")
523 (semantic-utest-last-invalid semantic-utest-C-name-contents
'("fun2") "/\\*1\\*/" "/* Deleted this line */")
524 (semantic-utest-verify-names semantic-utest-C-name-contents
)
526 (set-buffer-modified-p nil
)
528 ;; (kill-buffer buff)
529 ;; (kill-buffer buff2)
531 (message "All C tests passed.")
537 (defun semantic-utest-generic (testname filename contents name-contents names-removed killme insertme
)
538 "Generic unit test according to template.
539 Should work for languages withouth .h files, python javascript java.
540 TESTNAME is the name of the test.
541 FILENAME is the name of the file to create.
542 CONTENTS is the contents of the file to test.
543 NAME-CONTENTS is the list of names that should be in the contents.
544 NAMES-REMOVED is the list of names that gets removed in the removal step.
545 KILLME is the name of items to be killed.
546 INSERTME is the text to be inserted after the deletion."
548 (let ((buff (semantic-utest-makebuffer filename contents
))
550 ;; Turn off a range of modes
551 (semantic-idle-scheduler-mode -
1)
553 ;; Turn on some modes
554 (semantic-highlight-edits-mode 1)
556 ;; Update tags, and show it.
557 (semantic-fetch-tags)
558 (switch-to-buffer buff
)
562 ;;(message "First parsing test %s." testname)
563 (semantic-utest-verify-names name-contents
)
565 ;;(message "Invalid tag test %s." testname)
566 (semantic-utest-last-invalid name-contents names-removed killme insertme
)
567 (semantic-utest-verify-names name-contents
)
569 (set-buffer-modified-p nil
)
571 ;; (kill-buffer buff)
573 (message "All %s tests passed." testname
)
576 (defun semantic-utest-Python()
578 (if (fboundp 'python-mode
)
579 (semantic-utest-generic "Python" (semantic-utest-fname "pytest.py") semantic-utest-Python-buffer-contents semantic-utest-Python-name-contents
'("fun2") "#1" "#deleted line")
580 (message "Skilling Python test: NO major mode."))
584 (defun semantic-utest-Javascript()
586 (if (fboundp 'javascript-mode
)
587 (semantic-utest-generic "Javascript" (semantic-utest-fname "javascripttest.js") semantic-utest-Javascript-buffer-contents semantic-utest-Javascript-name-contents
'("fun2") "//1" "//deleted line")
588 (message "Skipping JavaScript test: NO major mode."))
591 (defun semantic-utest-Java()
593 ;; If JDE is installed, it might mess things up depending on the version
594 ;; that was installed.
595 (let ((auto-mode-alist '(("\\.java\\'" . java-mode
))))
596 (semantic-utest-generic "Java" (semantic-utest-fname "JavaTest.java") semantic-utest-Java-buffer-contents semantic-utest-Java-name-contents
'("fun2") "//1" "//deleted line")
599 (defun semantic-utest-Makefile()
601 (semantic-utest-generic "Makefile" (semantic-utest-fname "Makefile") semantic-utest-Makefile-buffer-contents semantic-utest-Makefile-name-contents
'("fun2") "#1" "#deleted line")
604 (defun semantic-utest-Scheme()
606 (semantic-utest-generic "Scheme" (semantic-utest-fname "tst.scm") semantic-utest-Scheme-buffer-contents semantic-utest-Scheme-name-contents
'("fun2") ";1" ";deleted line")
610 (defun semantic-utest-Html()
612 ;; Disable html-helper auto-fill-in mode.
613 (let ((html-helper-build-new-buffer nil
))
614 (semantic-utest-generic "HTML" (semantic-utest-fname "tst.html") semantic-utest-Html-buffer-contents semantic-utest-Html-name-contents
'("fun2") "<!--1-->" "<!--deleted line-->")
617 (defun semantic-utest-PHP()
619 (if (fboundp 'php-mode
)
620 (semantic-utest-generic "PHP" (semantic-utest-fname "phptest.php") semantic-utest-PHP-buffer-contents semantic-utest-PHP-name-contents
'("fun1") "fun2" "%^@")
621 (message "Skipping PHP Test. No php-mode loaded."))
624 ;look at http://mfgames.com/linux/csharp-mode
625 (defun semantic-utest-Csharp() ;; hmm i dont even know how to edit a scharp file. need a csharp mode implementation i suppose
627 (if (fboundp 'csharp-mode
)
628 (semantic-utest-generic "C#" (semantic-utest-fname "csharptest.cs") semantic-utest-Csharp-buffer-contents semantic-utest-Csharp-name-contents
'("fun2") "//1" "//deleted line")
629 (message "Skipping C# test. No csharp-mode loaded."))
632 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
635 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
638 ;-export([hello_world/0]).
641 ; io:format("Hello World ~n").
642 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
643 ;(defun semantic-utest-Erlang()
645 ; (semantic-utest-generic "Erlang" (semantic-utest-fname "tst.erl") semantic-utest-Erlang-buffer-contents semantic-utest-Erlang-name-contents '("fun2") "//1" "//deleted line")
648 ;;texi is also supported
649 ;(defun semantic-utest-Texi()
651 ; (semantic-utest-generic "texi" (semantic-utest-fname "tst.texi") semantic-utest-Texi-buffer-contents semantic-utest-Texi-name-contents '("fun2") "//1" "//deleted line")
654 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
657 (defun semantic-utest-main()
660 (cedet-utest-log-start "multi-lang parsing")
661 (cedet-utest-log " * C tests...")
663 (cedet-utest-log " * Python tests...")
664 (semantic-utest-Python)
665 (cedet-utest-log " * Java tests...")
666 (semantic-utest-Java)
667 (cedet-utest-log " * Javascript tests...")
668 (semantic-utest-Javascript)
669 (cedet-utest-log " * Makefile tests...")
670 (semantic-utest-Makefile)
671 (cedet-utest-log " * Scheme tests...")
672 (semantic-utest-Scheme)
673 (cedet-utest-log " * Html tests...")
674 (semantic-utest-Html)
675 (cedet-utest-log " * PHP tests...")
677 (cedet-utest-log " * Csharp tests...")
678 (semantic-utest-Csharp)
680 (cedet-utest-log-shutdown "multi-lang parsing")
683 ;;; Buffer contents validation
685 (defun semantic-utest-match-attributes (attr1 attr2 skipnames
)
686 "Compare attribute lists ATTR1 and ATTR2.
687 Argument SKIPNAMES is a list of names that may be child nodes to skip."
689 (while (and res attr1 attr2
)
693 (cond ((and (listp (car attr1
))
694 (semantic-tag-p (car (car attr1
))))
695 ;; Compare the list of tags...
696 (semantic-utest-taglists-equivalent-p
697 (car attr2
) (car attr1
) skipnames
)
700 (equal (car attr1
) (car attr2
)))))
703 (error "TAG INTERNAL DIFF: %S %S"
704 (car attr1
) (car attr2
)))
706 (setq attr1
(cdr attr1
)
710 (defun semantic-utest-equivalent-tag-p (tag1 tag2 skipnames
)
711 "Determine if TAG1 and TAG2 are the same.
712 SKIPNAMES includes lists of possible child nodes that should be missing."
713 (and (equal (semantic-tag-name tag1
) (semantic-tag-name tag2
))
714 (semantic-tag-of-class-p tag1
(semantic-tag-class tag2
))
715 (semantic-utest-match-attributes
716 (semantic-tag-attributes tag1
) (semantic-tag-attributes tag2
)
720 (defun semantic-utest-taglists-equivalent-p (table names skipnames
)
721 "Compare TABLE and NAMES, where skipnames allow list1 to be different.
722 SKIPNAMES is a list of names that should be skipped in the NAMES list."
723 (let ((SN skipnames
))
725 (setq names
(remove (car SN
) names
))
727 (while (and names table
)
728 (if (not (semantic-utest-equivalent-tag-p (car names
)
731 (error "Expected %s, found %s"
732 (semantic-format-tag-prototype (car names
))
733 (semantic-format-tag-prototype (car table
))))
734 (setq names
(cdr names
)
736 (when names
(error "Items forgotten: %S"
737 (mapcar 'semantic-tag-name names
)
739 (when table
(error "Items extra: %S"
740 (mapcar 'semantic-tag-name table
)))
743 (defun semantic-utest-verify-names (name-contents &optional skipnames
)
744 "Verify the names of the test buffer from NAME-CONTENTS.
745 Argument SKIPNAMES is a list of names that should be skipped
746 when analyzing the file.
748 JAVE this thing would need to be recursive to handle java and csharp"
749 (let ((names name-contents
)
750 (table (semantic-fetch-tags))
752 (semantic-utest-taglists-equivalent-p table names skipnames
)
755 ;;;;;;;;;;;;;;;;;;;;;;;;
756 ; JAVE redefine a new validation function
757 ; is not quite as good as the old one yet
758 (defun semantic-utest-verify-names-jave (name-contents &optional skipnames
)
759 "JAVE version of `semantic-utest-verify-names'.
760 NAME-CONTENTS is a sample of the tags buffer to test against.
761 SKIPNAMES is a list of names to remove from NAME-CONTENTS"
762 (assert (semantic-utest-verify-names-2 name-contents
(semantic-fetch-tags))
766 (defun semantic-utest-verify-names-2 (l1 l2
)
767 (cond ( (and (consp l1
) (equal (car l1
) 'overlay
))
772 (and (semantic-utest-verify-names-2 (car l1
) (car l2
)) (semantic-utest-verify-names-2 (cdr l1
) (cdr l2
))))
773 (t (error "internal error"))))
779 ;;; Kill indicator line
781 (defvar semantic-utest-last-kill-text nil
782 "The text from the last kill.")
784 (defvar semantic-utest-last-kill-pos nil
785 "The position of the last kill.")
787 (defun semantic-utest-kill-indicator ( killme insertme
)
788 "Kill the line with KILLME on it and insert INSERTME in its place."
789 (goto-char (point-min))
790 ; (re-search-forward (concat "/\\*" indicator "\\*/")); JAVE this isnt generic enough for different lagnuages
791 (re-search-forward killme
)
793 (setq semantic-utest-last-kill-pos
(point))
794 (setq semantic-utest-last-kill-text
795 (buffer-substring (point) (point-at-eol)))
796 (delete-region (point) (point-at-eol))
801 (defun semantic-utest-unkill-indicator ()
802 "Unkill the last indicator."
803 (goto-char semantic-utest-last-kill-pos
)
804 (delete-region (point) (point-at-eol))
805 (insert semantic-utest-last-kill-text
)
812 (defun semantic-utest-last-invalid (name-contents names-removed killme insertme
)
813 "Make the last fcn invalid."
814 (semantic-utest-kill-indicator killme insertme
)
815 ; (semantic-utest-verify-names name-contents names-removed); verify its gone ;new validator doesnt handle skipnames yet
816 (semantic-utest-unkill-indicator);put back killed stuff
822 ;"#<overlay from \\([0-9]+\\) to \\([0-9]+\\) in \\([^>]*\\)>"
823 ;#<overlay from \([0-9]+\) to \([0-9]+\) in \([^>]*\)>
824 ;(overlay \1 \2 "\3")
828 ;; these are some unit tests for cedet that I got from Eric and modified a bit for:
832 ;; I tried to generalize the structure of the tests a bit to make it easier to add languages
835 ;; Many items in the checklist look like:
837 ;; M-x global-semantic-highlight-edits-mode RET
838 ;; - Edit a file. See the highlight of newly inserted text.
839 ;; - Customize `semantic-edits-verbose-flag' to be non-nil.
840 ;; - Wait for the idle scheduler, it should clean up the edits.
841 ;; - observe messages from incremental parser. Do they relate
843 ;; - M-x bovinate RET - verify your changes are reflected.
845 ;; It's all about watching the behavior. Timers go off, things get
846 ;; cleaned up, you type in new changes, etc. An example I tried to
847 ;; do is below, but covers only 1 language, and not very well at that.
848 ;; I seem to remember seeing a unit test framework going by one of the
849 ;; lists. I'm not sure if that would help.
851 ;; Another that might be automatable:
853 ;; M-x semantic-analyze-current-context RET
854 ;; - Do this in different contexts in your language
855 ;; files. Verify that reasonable results are returned
856 ;; such as identification of assignments, function arguments, etc.
858 ;; Anyway, those are some ideas. Any effort you put it will be helpful!
867 ;;; semantic-utest.el ends here