emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 613fe8b 19/26: Version 1.2.0 sync with elpa


From: Rocky Bernstein
Subject: [elpa] master 613fe8b 19/26: Version 1.2.0 sync with elpa
Date: Thu, 25 May 2017 02:22:15 -0400 (EDT)

branch: master
commit 613fe8b3b47ce7120af2cce969284128170e7124
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    Version 1.2.0 sync with elpa
    
    From Stefan Monnier:
    
    * packages/test-simple/test-simple.el: Use cl-lib
    * (test-simple-msg): Let-bind inhibit-read-only directly.
    * (test-simple--ok-msg, test-simple--not-ok-msg): Rename from ok-msg and 
not-ok-msg.
---
 README.md          | 13 +++++------
 test-simple.el     | 66 ++++++++++++++++++++++++++++--------------------------
 test/test-basic.el |  2 +-
 3 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/README.md b/README.md
index dcdbf99..431e054 100644
--- a/README.md
+++ b/README.md
@@ -3,9 +3,9 @@
 *test-simple.el* is :
 
 * Simple -- no need for context macros, enclosing specifications, or required 
test tags. But if you want, you still can add custom assert failure messages or 
add notes before a group of tests.
-* Accommodates both interactive and non-interactive use:
+* Accomodates both interactive and non-interactive use:
   * For interactive use one can use `eval-last-sexp`, `eval-region`, and 
`eval-buffer`
-  * For non-interactive use run as: `emacs --batch --no-site-file --no-splash 
--load <test-lisp-code.el>`, or `test-simple-run`
+  * For non-interactive use run as: `emacs --batch --no-site-file --no-splash 
--load <test-lisp-code.el>`
 
 I use this in my [Debugger front end](https://github.com/rocky/emacs-dbgr).
 
@@ -28,7 +28,7 @@ In file `gcd.el`:
     )
 
 
-In file `gcd-tests.el` in the same directory:
+In file `test-gcd.el` in the same directory:
 
     (require 'test-simple)
     (test-simple-start) ;; Zero counters and start the stop watch.
@@ -51,23 +51,22 @@ In file `gcd-tests.el` in the same directory:
 
     (end-tests) ;; Stop the clock and print a summary
 
-Edit (with Emacs of course) `gcd-tests.el` and run `M-x eval-current-buffer`
+Edit (with Emacs of course) `test-gcd.el` and run `M-x eval-current-buffer`
 
 You should see in buffer `*test-simple*`:
 
-    gcd-tests.el
+    test-gcd.el
     ......
     0 failures in 6 assertions (0.002646 seconds)
 
 Now let's try from a command line:
 
-    $ emacs --batch --no-site-file --no-splash --load gcd-tests.el
+    $ emacs --batch --no-site-file --no-splash --load test-gcd.el
     Loading /src/external-vcs/emacs-test-simple/example/gcd.el (source)...
     *scratch*
     ......
     0 failures in 6 assertions (0.000723 seconds)
 
-
 You can run noninteractive tests inside Emacs by `test-simple-run`.
 Add the following at a test file:
 
diff --git a/test-simple.el b/test-simple.el
index 1374de2..26dbf54 100644
--- a/test-simple.el
+++ b/test-simple.el
@@ -1,12 +1,13 @@
 ;;; test-simple.el --- Simple Unit Test Framework for Emacs Lisp -*- 
lexical-binding: t -*-
 ;; Rewritten from Phil Hagelberg's behave.el by rocky
 
-;; Copyright (C) 2015 Free Software Foundation, Inc
+;; Copyright (C) 2015, 2016 Free Software Foundation, Inc
 
 ;; Author: Rocky Bernstein <address@hidden>
 ;; URL: http://github.com/rocky/emacs-test-simple
 ;; Keywords: unit-test
-;; Version: 1.1
+;; Package-Requires: ((cl-lib "0"))
+;; Version: 1.2
 
 ;; This program is free software: you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -26,7 +27,7 @@
 
 ;; test-simple.el is:
 ;;
-;; * Simple. No need for
+;; * Simple.  No need for
 ;;   - context macros,
 ;;   - enclosing specifications,
 ;;   - required test tags.
@@ -37,7 +38,7 @@
 ;;
 ;; * Accommodates both interactive and non-interactive use.
 ;;    - For interactive use, one can use `eval-last-sexp', `eval-region',
-;;      and `eval-buffer'. One can `edebug' the code.
+;;      and `eval-buffer'.  One can `edebug' the code.
 ;;    -  For non-interactive use, run:
 ;;        emacs --batch --no-site-file --no-splash --load <test-lisp-code.el>
 ;;
@@ -81,6 +82,7 @@
 
 ;;; To do:
 
+;; FIXME: Namespace is all messed up!
 ;; Main issues: more expect predicates
 
 (require 'time-date)
@@ -134,7 +136,7 @@ If bpr is not installed, fall back to `compile'."
   "Variable to store testing information for a buffer.")
 
 (defun note (description &optional test-info)
-  "Adds a name to a group of tests."
+  "Add a name to a group of tests."
   (if (getenv "USE_TAP")
     (test-simple-msg (format "# %s" description) 't)
     (if (> test-simple-verbosity 0)
@@ -155,9 +157,9 @@ If bpr is not installed, fall back to `compile'."
 
 ;;;###autoload
 (defun test-simple-clear (&optional test-info test-start-msg)
-  "Initializes and resets everything to run tests. You should run
-this before running any assertions. Running more than once clears
-out information from the previous run."
+  "Initialize and reset everything to run tests.
+You should run this before running any assertions.  Running more than once
+clears out information from the previous run."
 
   (interactive)
 
@@ -194,9 +196,9 @@ out information from the previous run."
          (list error-condition '(assert-t t)))))
 
 (defun assert-op (op expected actual &optional fail-message test-info)
-  "expectation is that ACTUAL should be equal to EXPECTED."
+  "Expectation is that ACTUAL should be equal to EXPECTED."
   (unless test-info (setq test-info test-simple-info))
-  (incf (test-info-assert-count test-info))
+  (cl-incf (test-info-assert-count test-info))
   (if (not (funcall op actual expected))
       (let* ((fail-message
              (if fail-message
@@ -208,26 +210,26 @@ out information from the previous run."
              (if (boundp 'test-info)
                  (test-info-description test-info)
                "unset")))
-       (add-failure (format "assert-%s" op) test-info-mess
-                    (concat fail-message expect-message)))
-    (ok-msg fail-message)))
+       (test-simple--add-failure (format "assert-%s" op) test-info-mess
+                                  (concat fail-message expect-message)))
+    (test-simple--ok-msg fail-message)))
 
 (defun assert-equal (expected actual &optional fail-message test-info)
-  "expectation is that ACTUAL should be equal to EXPECTED."
+  "Expectation is that ACTUAL should be equal to EXPECTED."
   (assert-op 'equal expected actual fail-message test-info))
 
 (defun assert-eq (expected actual &optional fail-message test-info)
-  "expectation is that ACTUAL should be EQ to EXPECTED."
+  "Expectation is that ACTUAL should be EQ to EXPECTED."
   (assert-op 'eql expected actual fail-message test-info))
 
 (defun assert-eql (expected actual &optional fail-message test-info)
-  "expectation is that ACTUAL should be EQL to EXPECTED."
+  "Expectation is that ACTUAL should be EQL to EXPECTED."
   (assert-op 'eql expected actual fail-message test-info))
 
 (defun assert-matches (expected-regexp actual &optional fail-message test-info)
-  "expectation is that ACTUAL should match EXPECTED-REGEXP."
+  "Expectation is that ACTUAL should match EXPECTED-REGEXP."
   (unless test-info (setq test-info test-simple-info))
-  (incf (test-info-assert-count test-info))
+  (cl-incf (test-info-assert-count test-info))
   (if (not (string-match expected-regexp actual))
       (let* ((fail-message
              (if fail-message
@@ -240,8 +242,8 @@ out information from the previous run."
              (if (boundp 'test-info)
                  (test-info-description test-info)
                "unset")))
-       (add-failure "assert-equal" test-info-mess
-                    (concat expect-message fail-message)))
+       (test-simple--add-failure "assert-equal" test-info-mess
+                                  (concat expect-message fail-message)))
     (progn (test-simple-msg ".") t)))
 
 (defun assert-t (actual &optional fail-message test-info)
@@ -252,7 +254,7 @@ out information from the previous run."
   "expectation is that ACTUAL is nil. FAIL-MESSAGE is an optional
 additional message to be displayed."
   (unless test-info (setq test-info test-simple-info))
-  (incf (test-info-assert-count test-info))
+  (cl-incf (test-info-assert-count test-info))
   (if actual
       (let* ((fail-message
              (if fail-message
@@ -262,17 +264,19 @@ additional message to be displayed."
              (if (boundp 'test-simple-info)
                  (test-info-description test-simple-info)
                "unset")))
-       (add-failure "assert-nil" test-info-mess fail-message test-info))
-    (ok-msg fail-message)))
+       (test-simple--add-failure "assert-nil" test-info-mess
+                                  fail-message test-info))
+    (test-simple--ok-msg fail-message)))
 
-(defun add-failure(type test-info-msg fail-msg &optional test-info)
+(defun test-simple--add-failure (type test-info-msg fail-msg
+                                      &optional test-info)
   (unless test-info (setq test-info test-simple-info))
-  (incf (test-info-failure-count test-info))
+  (cl-incf (test-info-failure-count test-info))
   (let ((failure-msg
         (format "\nDescription: %s, type %s\n%s" test-info-msg type fail-msg))
        )
     (save-excursion
-      (not-ok-msg)
+      (test-simple--not-ok-msg fail-msg)
       (test-simple-msg failure-msg 't)
       (unless noninteractive
        (if test-simple-debug-on-error
@@ -281,7 +285,7 @@ additional message to be displayed."
          )))))
 
 (defun end-tests (&optional test-info)
-  "Give a tally of the tests run"
+  "Give a tally of the tests run."
   (interactive)
   (unless test-info (setq test-info test-simple-info))
   (test-simple-describe-failures test-info)
@@ -299,15 +303,13 @@ additional message to be displayed."
 
 (defun test-simple-msg(msg &optional newline)
   (switch-to-buffer "*test-simple*")
-  (let ((old-read-only inhibit-read-only))
-    (setq inhibit-read-only 't)
+  (let ((inhibit-read-only t))
     (insert msg)
     (if newline (insert "\n"))
-    (setq inhibit-read-only old-read-only)
     (switch-to-buffer nil)
   ))
 
-(defun ok-msg(fail-message &optional test-info)
+(defun test-simple--ok-msg (fail-message &optional test-info)
   (unless test-info (setq test-info test-simple-info))
   (let ((msg (if (getenv "USE_TAP")
                 (if (equal fail-message "")
@@ -319,7 +321,7 @@ additional message to be displayed."
       (test-simple-msg msg))
   't)
 
-(defun not-ok-msg(&optional test-info)
+(defun test-simple--not-ok-msg (_fail-message &optional test-info)
   (unless test-info (setq test-info test-simple-info))
   (let ((msg (if (getenv "USE_TAP")
                 (format "not ok %d\n" (test-info-assert-count test-info))
diff --git a/test/test-basic.el b/test/test-basic.el
index f14a385..723779a 100644
--- a/test/test-basic.el
+++ b/test/test-basic.el
@@ -22,7 +22,7 @@
 (assert-t (memq 'test-simple features) "'test-simple provided")
 
 (assert-nil nil "assert-nil failure test")
-(assert-nil nil "Knights if ni")
+(assert-nil nil "Knights of ni")
 (assert-equal 5 (+ 1 4) "assert-equal")
 (assert-raises error (error "you should not see this") "assert-raises")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]