X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/17af2991b5bd71ed2d3d69fd4467e1fc8a31d8d1..d1f18ec0920105223d2aecfd838f8b19921e6340:/test/cedet/cedet-utests.el diff --git a/test/cedet/cedet-utests.el b/test/cedet/cedet-utests.el index 2556c111ee..aab07d4947 100644 --- a/test/cedet/cedet-utests.el +++ b/test/cedet/cedet-utests.el @@ -1,6 +1,6 @@ ;;; cedet-utests.el --- Run all unit tests in the CEDET suite. -;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. +;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Eric M. Ludlam @@ -40,14 +40,6 @@ ("ezimage associations" . ezimage-image-association-dump) ("ezimage images" . ezimage-image-dump) - ;; Workging interactive tests. - ("working: wait-for-keypress" . - (lambda () - (if (cedet-utest-noninteractive) - (message " ** Skipping test in noninteractive mode.") - (working-wait-for-keypress)))) - ;("working: sleep" . working-verify-sleep) - ;; Pulse ("pulse interactive test" . (lambda () (pulse-test t))) @@ -97,21 +89,12 @@ ("srecode: templates" . srecode-utest-template-output) ("srecode: show maps" . srecode-get-maps) ("srecode: getset" . srecode-utest-getset-output) - - ;; - ;; COGRE - ;; - ("cogre: graph" . cogre-utest) - ("cogre: periodic & ascii" . cogre-periodic-utest) - ("cogre: conversion/export tests" . cogre-export-utest) - ("cogre: uml-quick-class" . cogre-utest-quick-class) ) "Alist of all the tests in CEDET we should run.") (defvar cedet-running-master-tests nil "Non-nil when CEDET-utest is running all the tests.") -;;;###autoload (defun cedet-utest (&optional exit-on-error) "Run the CEDET unittests. EXIT-ON-ERROR causes the test suite to exit on an error, instead @@ -253,7 +236,7 @@ Argument START and END bound the time being calculated." (defun cedet-utest-log-shutdown (title &optional errorcondition) "Shut-down a larger test suite. TITLE is the section that is done. -ERRORCONDITION is some error that may have occured durinig testing." +ERRORCONDITION is some error that may have occurred during testing." (let ((endtime (current-time)) ) (cedet-utest-log-shutdown-msg title cedet-utest-log-timer endtime) @@ -386,7 +369,148 @@ The rest of the ARGS are used to fill in FORMAT with `format'." (cedet-utest-show-log-end) ) +;;; Inversion tests + +(defun inversion-unit-test () + "Test inversion to make sure it can identify different version strings." + (interactive) + (let ((c1 (inversion-package-version 'inversion)) + (c1i (inversion-package-incompatibility-version 'inversion)) + (c2 (inversion-decode-version "1.3alpha2")) + (c3 (inversion-decode-version "1.3beta4")) + (c4 (inversion-decode-version "1.3 beta5")) + (c5 (inversion-decode-version "1.3.4")) + (c6 (inversion-decode-version "2.3alpha")) + (c7 (inversion-decode-version "1.3")) + (c8 (inversion-decode-version "1.3pre1")) + (c9 (inversion-decode-version "2.4 (patch 2)")) + (c10 (inversion-decode-version "2.4 (patch 3)")) + (c11 (inversion-decode-version "2.4.2.1")) + (c12 (inversion-decode-version "2.4.2.2")) + ) + (if (not (and + (inversion-= c1 c1) + (inversion-< c1i c1) + (inversion-< c2 c3) + (inversion-< c3 c4) + (inversion-< c4 c5) + (inversion-< c5 c6) + (inversion-< c2 c4) + (inversion-< c2 c5) + (inversion-< c2 c6) + (inversion-< c3 c5) + (inversion-< c3 c6) + (inversion-< c7 c6) + (inversion-< c4 c7) + (inversion-< c2 c7) + (inversion-< c8 c6) + (inversion-< c8 c7) + (inversion-< c4 c8) + (inversion-< c2 c8) + (inversion-< c9 c10) + (inversion-< c10 c11) + (inversion-< c11 c12) + ;; Negatives + (not (inversion-< c3 c2)) + (not (inversion-< c4 c3)) + (not (inversion-< c5 c4)) + (not (inversion-< c6 c5)) + (not (inversion-< c7 c2)) + (not (inversion-< c7 c8)) + (not (inversion-< c12 c11)) + ;; Test the tester on inversion + (not (inversion-test 'inversion inversion-version)) + ;; Test that we throw an error + (inversion-test 'inversion "0.0.0") + (inversion-test 'inversion "1000.0") + )) + (error "Inversion tests failed") + (message "Inversion tests passed.")))) + +;;; cedet-files unit test + +(defvar cedet-files-utest-list + '( + ( "/home/me/src/myproj/src/foo.c" . "!home!me!src!myproj!src!foo.c" ) + ( "c:/work/myproj/foo.el" . "!drive_c!work!myproj!foo.el" ) + ( "//windows/proj/foo.java" . "!!windows!proj!foo.java" ) + ( "/home/me/proj!bang/foo.c" . "!home!me!proj!!bang!foo.c" ) + ) + "List of different file names to test. +Each entry is a cons cell of ( FNAME . CONVERTED ) +where FNAME is some file name, and CONVERTED is what it should be +converted into.") + +(defun cedet-files-utest () + "Test out some file name conversions." + (interactive) + (let ((idx 0)) + (dolist (FT cedet-files-utest-list) + + (setq idx (+ idx 1)) + + (let ((dir->file (cedet-directory-name-to-file-name (car FT) t)) + (file->dir (cedet-file-name-to-directory-name (cdr FT) t)) + ) + + (unless (string= (cdr FT) dir->file) + (error "Failed: %d. Found: %S Wanted: %S" + idx dir->file (cdr FT)) + ) + + (unless (string= file->dir (car FT)) + (error "Failed: %d. Found: %S Wanted: %S" + idx file->dir (car FT))))))) + +;;; pulse test + +(defun pulse-test (&optional no-error) + "Test the lightening function for pulsing a line. +When optional NO-ERROR don't throw an error if we can't run tests." + (interactive) + (if (or (not pulse-flag) (not (pulse-available-p))) + (if no-error + nil + (error (concat "Pulse test only works on versions of Emacs" + " that support pulsing"))) + ;; Run the tests + (when (interactive-p) + (message " Pulse one line.") + (read-char)) + (pulse-momentary-highlight-one-line (point)) + (when (interactive-p) + (message " Pulse a region.") + (read-char)) + (pulse-momentary-highlight-region (point) + (save-excursion + (condition-case nil + (forward-char 30) + (error nil)) + (point))) + (when (interactive-p) + (message " Pulse line a specific color.") + (read-char)) + (pulse-momentary-highlight-one-line (point) 'modeline) + (when (interactive-p) + (message " Pulse a pre-existing overlay.") + (read-char)) + (let* ((start (point-at-bol)) + (end (save-excursion + (end-of-line) + (when (not (eobp)) + (forward-char 1)) + (point))) + (o (make-overlay start end)) + ) + (pulse-momentary-highlight-overlay o) + (if (overlay-buffer o) + (delete-overlay o) + (error "Non-temporary overlay was deleted!")) + ) + (when (interactive-p) + (message "Done!")))) (provide 'cedet-utests) +;; arch-tag: ace16290-4119-4df0-b33c-8c6b809f420d ;;; cedet-utests.el ends here