Merge from emacs-24; up to 2012-12-11T09:51:12Z!dmantipov@yandex.ru
[bpt/emacs.git] / lisp / emacs-lisp / testcover.el
index 705be16..f6bd26e 100644 (file)
@@ -1,6 +1,6 @@
 ;;;; testcover.el -- Visual code-coverage tool
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2013 Free Software Foundation, Inc.
 
 ;; Author: Jonathan Yavner <jyavner@member.fsf.org>
 ;; Maintainer: Jonathan Yavner <jyavner@member.fsf.org>
@@ -8,10 +8,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 
 ;;; Commentary:
@@ -30,7 +28,7 @@
 ;; * Use `testcover-mark-all' to add overlay "splotches" to the Lisp file's
 ;;   buffer to show where coverage is lacking.  Normally, a red splotch
 ;;   indicates the form was never evaluated; a brown splotch means it always
-;;   evaluted to the same value.
+;;   evaluated to the same value.
 ;; * Use `testcover-next-mark' (bind it to a key!) to jump to the next spot
 ;;   that has a splotch.
 
@@ -222,7 +220,7 @@ non-nil, byte-compiles each function after instrumenting."
 (defun testcover-reinstrument (form)
   "Reinstruments FORM to use testcover instead of edebug.  This
 function modifies the list that FORM points to.  Result is nil if
-FORM should return multiple vlues, t if should always return same
+FORM should return multiple values, t if should always return same
 value, 'maybe if either is acceptable."
   (let ((fun (car-safe form))
        id val)
@@ -272,9 +270,9 @@ value, 'maybe if either is acceptable."
       (setq id (nth 2 form))
       (setcdr form (nthcdr 2 form))
       (setq val (testcover-reinstrument (nth 2 form)))
-      (if (eq val t)
-         (setcar form 'testcover-1value)
-       (setcar form 'testcover-after))
+      (setcar form (if (eq val t)
+                       'testcover-1value
+                     'testcover-after))
       (when val
        ;;1-valued or potentially 1-valued
        (aset testcover-vector id '1value))
@@ -361,9 +359,9 @@ value, 'maybe if either is acceptable."
                                              ,(nth 3 (cadr form))))
        t)
        (t
-       (if (eq (car (cadr form)) 'edebug-after)
-           (setq id (car (nth 3 (cadr form))))
-         (setq id (car (cadr form))))
+       (setq id (car (if (eq (car (cadr form)) 'edebug-after)
+                          (nth 3 (cadr form))
+                        (cadr form))))
        (let ((testcover-1value-functions
               (cons id testcover-1value-functions)))
          (testcover-reinstrument (cadr form))))))
@@ -381,9 +379,9 @@ value, 'maybe if either is acceptable."
                                   ,(nth 3 (cadr form))))
        'maybe)
        (t
-       (if (eq (car (cadr form)) 'edebug-after)
-           (setq id (car (nth 3 (cadr form))))
-         (setq id (car (cadr form))))
+       (setq id (car (if (eq (car (cadr form)) 'edebug-after)
+                          (nth 3 (cadr form))
+                        (cadr form))))
        (let ((testcover-noreturn-functions
               (cons id testcover-noreturn-functions)))
          (testcover-reinstrument (cadr form))))))
@@ -432,7 +430,7 @@ FUN should be `testcover-reinstrument' for compositional functions,
   "Turn off instrumentation of all macros and functions in FILENAME."
   (interactive "fStop covering file: ")
   (let ((buf (find-file-noselect filename)))
-    (eval-buffer buf t)))
+    (eval-buffer buf)))
 
 
 ;;;=========================================================================
@@ -449,6 +447,12 @@ binding `testcover-vector' to the code-coverage vector for TESTCOVER-SYM
 (defun testcover-after (idx val)
   "Internal function for coverage testing.  Returns VAL after installing it in
 `testcover-vector' at offset IDX."
+  (declare (gv-expander (lambda (do)
+                          (gv-letplace (getter setter) val
+                            (funcall do getter
+                                     (lambda (store)
+                                       `(progn (testcover-after ,idx ,getter)
+                                               ,(funcall setter store))))))))
   (cond
    ((eq (aref testcover-vector idx) 'unknown)
     (aset testcover-vector idx val))
@@ -511,7 +515,7 @@ eliminated by adding more test cases."
       (set-buffer-modified-p changed))))
 
 (defun testcover-mark-all (&optional buffer)
-  "Mark all forms in BUFFER that did not get completley tested during
+  "Mark all forms in BUFFER that did not get completely tested during
 coverage tests.  This function creates many overlays."
   (interactive "bMark forms in buffer: ")
   (if buffer
@@ -536,5 +540,4 @@ coverage tests.  This function creates many overlays."
   (goto-char (next-overlay-change (point)))
   (end-of-line))
 
-;; arch-tag: 72324a4a-4a2e-4142-9249-cc56d6757588
 ;; testcover.el ends here.