[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/assess 4bf702a08a 43/95: Re-order to put macros first.
From: |
ELPA Syncer |
Subject: |
[elpa] externals/assess 4bf702a08a 43/95: Re-order to put macros first. |
Date: |
Tue, 19 Jul 2022 15:57:32 -0400 (EDT) |
branch: externals/assess
commit 4bf702a08adb4b99f590716cb4c721c273ccaae8
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>
Re-order to put macros first.
---
assess.el | 264 ++++++++++++++++++++++++++--------------------------
test/assess-test.el | 4 +
2 files changed, 136 insertions(+), 132 deletions(-)
diff --git a/assess.el b/assess.el
index 5695066ca3..82c43a7584 100644
--- a/assess.el
+++ b/assess.el
@@ -102,6 +102,138 @@
'error)
;; #+end_src
+;; ** Buffer creation
+
+;; For tests, it is often better to use temporary buffers, as it is much less
+;; affected by the existing state of Emacs, and much less likely to affect
future
+;; state; this is particularly the case where tests are being developed as the
+;; developer may be trying to change or write test files at the same time as
+;; Emacs is trying to use them for testing.
+
+;; Emacs really only provides a single primitive `with-temp-buffer' for this
+;; situation, and that only creates a single temporary buffer at a time.
Nesting
+;; of these forms sometimes works, but fails if we need to operate on two
buffers
+;; at once.
+
+;; So, we provide an environment for restoring the buffer list. This allows any
+;; creation of buffers we need for testing, followed by clean up afterwards.
For
+;; example, a trivial usage would be to remove buffers explicitly created.
+
+;; #+begin_src elisp
+;; (assess-with-preserved-buffer-list
+;; (get-buffer-create "a")
+;; (get-buffer-create "b")
+;; (get-buffer-create "c"))
+;; #+end_src
+
+;; Any buffer created in this scope is removed, whether this is as a direct or
+;; indirect result of the function. For example, this usage creates a ~*Help*~
+;; buffer which then gets removed again.
+
+;; #+begin_src elisp
+;; (assess-with-preserved-buffer-list
+;; (describe-function 'self-insert-command))
+;; #+end_src
+
+;; This does not prevent changes to existing buffers of course. If ~*Help*~ is
+;; already open before evaluation, it will remain open afterwards but with
+;; different content.
+
+;; Sometimes, it is useful to create several temporary buffers at once.
+;; `assess-with-temp-buffers' provides an easy mechanism for doing this, as
+;; well as evaluating content in these buffers. For example, this returns true
+;; (actually three killed buffers which were live when the `mapc' form runs).
+
+;; #+begin_src elisp
+;; (assess-with-temp-buffers
+;; (a b c)
+;; (mapc #'buffer-live-p (list a b c)))
+;; #+end_src
+
+;; While this creates two buffers, puts "hellogoodbye" into one and "goodbye"
+;; into the other, then compares the contents of these buffers with `assess='.
+
+;; #+begin_src elisp
+;; (assess-with-temp-buffers
+;; ((a (insert "hello")
+;; (insert "goodbye"))
+;; (b (insert "goodbye")))
+;; (assess= a b))
+;; #+end_src
+
+;; Finally, we provide a simple mechanism for converting any assess type into a
+;; buffer. The following form, for example, returns the contents of the
~.emacs~
+;; file.
+
+;; #+begin_src elisp
+;; (assess-as-temp-buffer
+;; (assess-file "~/.emacs")
+;; (buffer-string))
+;; #+end_src
+
+;; ** Implementation
+
+;; #+begin_src emacs-lisp
+(defmacro assess-with-preserved-buffer-list (&rest body)
+ "Evaluate BODY, but delete any buffers that have been created."
+ (declare (debug t))
+ `(let ((before-buffer-list
+ (buffer-list)))
+ (unwind-protect
+ (progn
+ ,@body)
+ (--map
+ (kill-buffer it)
+ (-difference (buffer-list)
+ before-buffer-list)))))
+
+(defun assess--temp-buffer-let-form (item)
+ (if (not (listp item))
+ (assess--temp-buffer-let-form
+ (list item))
+ `(,(car item)
+ (with-current-buffer
+ (generate-new-buffer " *assess-with-temp-buffers*")
+ ,@(cdr item)
+ (current-buffer)))))
+;; #+end_src
+
+;; The implementation of `assess-with-temp-buffers' currently uses
+;; `assess-with-preserved-buffer-list' to remove buffers which means that it
+;; will also delete any buffers created by the user; this may be a mistake, and
+;; it might be better to delete the relevant buffers explicitly.
+
+;; #+begin_src emacs-lisp
+(defmacro assess-with-temp-buffers (varlist &rest body)
+ "Bind variables in varlist to temp buffers, then eval BODY.
+
+VARLIST is of the same form as a `let' binding. Each element is a
+symbol or a list (symbol valueforms). Each symbol is bound to a
+buffer generated with `generate-new-buffer'. VALUEFORMS are
+evaluated with the buffer current. Any buffers created inside
+this form (and not just by this form!) are unconditionally killed
+at the end of the form."
+ (declare (indent 1)
+ (debug let))
+ (let ((let-form
+ (-map
+ #'assess--temp-buffer-let-form
+ varlist)))
+ `(assess-with-preserved-buffer-list
+ (let ,let-form
+ ,@body))))
+
+(defmacro assess-as-temp-buffer (x &rest body)
+ "Insert X in a type-appropriate way into a temp buffer and eval
+BODY there.
+
+See `assess-to-string' for the meaning of type-appropriate."
+ (declare (indent 1) (debug t))
+ `(with-temp-buffer
+ (insert (assess-to-string ,x))
+ ,@body))
+;; #+end_src
+
;; ** Types
;; Many tests on files or buffers actually end up being string comparision.
@@ -354,138 +486,6 @@ automatically. See `assess=' for more information."
(put 'assess= 'ert-explainer 'assess-explain=)
;; #+end_src
-;; ** Buffer creation
-
-;; For tests, it is often better to use temporary buffers, as it is much less
-;; affected by the existing state of Emacs, and much less likely to affect
future
-;; state; this is particularly the case where tests are being developed as the
-;; developer may be trying to change or write test files at the same time as
-;; Emacs is trying to use them for testing.
-
-;; Emacs really only provides a single primitive `with-temp-buffer' for this
-;; situation, and that only creates a single temporary buffer at a time.
Nesting
-;; of these forms sometimes works, but fails if we need to operate on two
buffers
-;; at once.
-
-;; So, we provide an environment for restoring the buffer list. This allows any
-;; creation of buffers we need for testing, followed by clean up afterwards.
For
-;; example, a trivial usage would be to remove buffers explicitly created.
-
-;; #+begin_src elisp
-;; (assess-with-preserved-buffer-list
-;; (get-buffer-create "a")
-;; (get-buffer-create "b")
-;; (get-buffer-create "c"))
-;; #+end_src
-
-;; Any buffer created in this scope is removed, whether this is as a direct or
-;; indirect result of the function. For example, this usage creates a ~*Help*~
-;; buffer which then gets removed again.
-
-;; #+begin_src elisp
-;; (assess-with-preserved-buffer-list
-;; (describe-function 'self-insert-command))
-;; #+end_src
-
-;; This does not prevent changes to existing buffers of course. If ~*Help*~ is
-;; already open before evaluation, it will remain open afterwards but with
-;; different content.
-
-;; Sometimes, it is useful to create several temporary buffers at once.
-;; `assess-with-temp-buffers' provides an easy mechanism for doing this, as
-;; well as evaluating content in these buffers. For example, this returns true
-;; (actually three killed buffers which were live when the `mapc' form runs).
-
-;; #+begin_src elisp
-;; (assess-with-temp-buffers
-;; (a b c)
-;; (mapc #'buffer-live-p (list a b c)))
-;; #+end_src
-
-;; While this creates two buffers, puts "hellogoodbye" into one and "goodbye"
-;; into the other, then compares the contents of these buffers with `assess='.
-
-;; #+begin_src elisp
-;; (assess-with-temp-buffers
-;; ((a (insert "hello")
-;; (insert "goodbye"))
-;; (b (insert "goodbye")))
-;; (assess= a b))
-;; #+end_src
-
-;; Finally, we provide a simple mechanism for converting any assess type into a
-;; buffer. The following form, for example, returns the contents of the
~.emacs~
-;; file.
-
-;; #+begin_src elisp
-;; (assess-as-temp-buffer
-;; (assess-file "~/.emacs")
-;; (buffer-string))
-;; #+end_src
-
-;; ** Implementation
-
-;; #+begin_src emacs-lisp
-(defmacro assess-with-preserved-buffer-list (&rest body)
- "Evaluate BODY, but delete any buffers that have been created."
- (declare (debug t))
- `(let ((before-buffer-list
- (buffer-list)))
- (unwind-protect
- (progn
- ,@body)
- (--map
- (kill-buffer it)
- (-difference (buffer-list)
- before-buffer-list)))))
-
-(defun assess--temp-buffer-let-form (item)
- (if (not (listp item))
- (assess--temp-buffer-let-form
- (list item))
- `(,(car item)
- (with-current-buffer
- (generate-new-buffer " *assess-with-temp-buffers*")
- ,@(cdr item)
- (current-buffer)))))
-;; #+end_src
-
-;; The implementation of `assess-with-temp-buffers' currently uses
-;; `assess-with-preserved-buffer-list' to remove buffers which means that it
-;; will also delete any buffers created by the user; this may be a mistake, and
-;; it might be better to delete the relevant buffers explicitly.
-
-;; #+begin_src emacs-lisp
-(defmacro assess-with-temp-buffers (varlist &rest body)
- "Bind variables in varlist to temp buffers, then eval BODY.
-
-VARLIST is of the same form as a `let' binding. Each element is a
-symbol or a list (symbol valueforms). Each symbol is bound to a
-buffer generated with `generate-new-buffer'. VALUEFORMS are
-evaluated with the buffer current. Any buffers created inside
-this form (and not just by this form!) are unconditionally killed
-at the end of the form."
- (declare (indent 1)
- (debug let))
- (let ((let-form
- (-map
- #'assess--temp-buffer-let-form
- varlist)))
- `(assess-with-preserved-buffer-list
- (let ,let-form
- ,@body))))
-
-(defmacro assess-as-temp-buffer (x &rest body)
- "Insert X in a type-appropriate way into a temp buffer and eval
-BODY there.
-
-See `assess-to-string' for the meaning of type-appropriate."
- (declare (indent 1) (debug t))
- `(with-temp-buffer
- (insert (assess-to-string ,x))
- ,@body))
-;; #+end_src
-
;; ** Opening files
;; Opening files presents a particular problem for testing, particularly if we
diff --git a/test/assess-test.el b/test/assess-test.el
index 11defd1b2d..59e86e7342 100644
--- a/test/assess-test.el
+++ b/test/assess-test.el
@@ -472,4 +472,8 @@ This also tests the advice on string=."
"bar" 'font-lock-type-face))
(should-not
(assess-face-at= "def" 'python-mode "def" nil)))
+
+;; https://github.com/phillord/assess/issues/5
+(ert-deftest issue-5-test-example ()
+ (should-not (assess-indentation= 'fundamental-mode "foo" "bar")))
;; #+end_src
- [elpa] externals/assess 216adb069c 47/95: Add assess-call.el, (continued)
- [elpa] externals/assess 216adb069c 47/95: Add assess-call.el, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 07bd7f8915 58/95: Doc fixes, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 739661405b 59/95: Add assess-robot.el and tests, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 9521b07480 71/95: Fix and Publish documentation statically, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 5aee8d7500 81/95: Mark some tests as failed on earlier emacs, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 0a3e94477a 78/95: Support all of Emacs 24 series, ELPA Syncer, 2022/07/19
- [elpa] externals/assess e5b0415126 85/95: Update README and release number, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 7a3189a587 86/95: Remove types and replace with convertors, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 5bac045b27 94/95: Update version, ELPA Syncer, 2022/07/19
- [elpa] externals/assess ac8ff1f928 39/95: Change all file names to assess., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 4bf702a08a 43/95: Re-order to put macros first.,
ELPA Syncer <=
- [elpa] externals/assess e9344a55df 45/95: Move from ert to assess-discover, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 7409b103a3 46/95: Update .gitignore, ELPA Syncer, 2022/07/19
- [elpa] externals/assess e1b7740df5 55/95: Add unwind-protect to assess-call functions, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 2335b8bd69 63/95: Remove old call-capture variable, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 61771edab7 67/95: Move cask to melpa-stable, ELPA Syncer, 2022/07/19
- [elpa] externals/assess e2e5f1cbbd 69/95: Merge pull request #6 from NicolasPetton/master, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 70c6d8c57d 70/95: Fix a few typos, ELPA Syncer, 2022/07/19
- [elpa] externals/assess bafab950e7 68/95: Fix typos, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 47ce039423 77/95: Avoid font-lock-ensure for older Emacs, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 4a71be3ba5 38/95: Change all references to sisyphus to assess, ELPA Syncer, 2022/07/19