[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b6d990d 075/187: Add lexbind test
From: |
Michael Albinus |
Subject: |
[elpa] master b6d990d 075/187: Add lexbind test |
Date: |
Wed, 30 Dec 2015 11:49:47 +0000 |
branch: master
commit b6d990d7ebf037ff5319bf1738fbb11ce9dc6f71
Author: Ryan C. Thompson <address@hidden>
Commit: Ryan C. Thompson <address@hidden>
Add lexbind test
---
async-test.el | 58 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/async-test.el b/async-test.el
index a5e83e9..b416c18 100644
--- a/async-test.el
+++ b/async-test.el
@@ -131,26 +131,6 @@
(lambda (result)
(message "Async process done: %s" result))))
-(defun async-test-7 ()
- (interactive)
- (message "Starting async-test-7...")
- (eval
- '(progn
- (print
- (mapcar #'async-get
- (cl-loop repeat 2 collect
- (async-start (lambda () t)))))
- (print
- (mapcar #'async-get
- (cl-loop repeat 2 collect
- (async-start '(lambda () t)))))
- (print
- (mapcar #'async-get
- (cl-loop repeat 2 collect
- (async-start `(lambda () ,(* 150 2)))))))
- t)
- (message "Finished async-test-7 successfully."))
-
(defsubst async-file-contents (file)
"Return the contents of FILE, as a string."
(with-temp-buffer
@@ -272,6 +252,41 @@ Return the name of the directory."
(if (file-directory-p temp-dir) (delete-directory temp-dir t))
(if (file-directory-p temp-dir2) (delete-directory temp-dir2 t)))))
+(defun async-do-lexbind-test ()
+ ;; The `cl-loop' macro creates some lexical variables, and in this
+ ;; case one of those variables (the one that collects the result)
+ ;; gets set to a list of process objects, which are unprintable. If
+ ;; `lexical-binding' is non-nil, this unprintable value is
+ ;; incorporated into the closures created by `lambda' within the
+ ;; loop. Closure prevention avoids the error from this unprintable
+ ;; lexical value in these examples.
+ (eval
+ '(progn
+ (mapcar #'async-get
+ (cl-loop repeat 2 collect
+ (async-start (lambda () t))))
+ (mapcar #'async-get
+ (cl-loop repeat 2 collect
+ (async-start '(lambda () t))))
+ (mapcar #'async-get
+ (cl-loop repeat 2 collect
+ (async-start #'(lambda () t))))
+ (mapcar #'async-get
+ (cl-loop repeat 2 collect
+ (async-start `(lambda () ,(* 150 2))))))
+ t)
+ ;; However closure prevention also (obviously) prevents creation of
+ ;; lexical closures, leading to an error in this case.
+ (should
+ (eq 6
+ (eval
+ '(let ((x 1)
+ (y 2)
+ (z 3))
+ (async-sandbox (lambda () (+ x y z))))
+ t)
+ )))
+
(ert-deftest async-copy-directory-lisp-sync-1 ()
(async-do-copy-directory-test t nil nil :synchronously t))
(ert-deftest async-copy-directory-lisp-sync-2 ()
@@ -299,6 +314,9 @@ Return the name of the directory."
(ert-deftest async-copy-directory-native-4 ()
(async-do-copy-directory-test t t t :use-native-commands t))
+(ert-deftest async-lexbind-test ()
+ (async-do-lexbind-test))
+
(provide 'async-test)
;;; async-test.el ends here
- [elpa] master 8d38306 063/187: * helm-async.el: Untabify and reindent., (continued)
- [elpa] master 8d38306 063/187: * helm-async.el: Untabify and reindent., Michael Albinus, 2015/12/30
- [elpa] master c029934 066/187: * helm-async.el: Add comments about incompatibility with dired-async.el and async-file.el., Michael Albinus, 2015/12/30
- [elpa] master fb8f10b 065/187: * helm-async.el (dired-create-files): Handle `dired-recursive-copies' when async too., Michael Albinus, 2015/12/30
- [elpa] master bcffaeb 067/187: * helm-async.el (dired-create-file): Revert changes in fb8f10b., Michael Albinus, 2015/12/30
- [elpa] master 8e05e02 070/187: Prevent accidental creation of lexical closures., Michael Albinus, 2015/12/30
- [elpa] master 9c02acd 069/187: Add test for #17., Michael Albinus, 2015/12/30
- [elpa] master 5ef546a 071/187: Have test file add its own directory to load path, Michael Albinus, 2015/12/30
- [elpa] master 242ae73 068/187: * helm-async.el: Fix error handling., Michael Albinus, 2015/12/30
- [elpa] master 93b05a9 073/187: More robust evaluation and closure-protection of start-func, Michael Albinus, 2015/12/30
- [elpa] master ba705c6 076/187: Add test for handling different ways of passing a function, Michael Albinus, 2015/12/30
- [elpa] master b6d990d 075/187: Add lexbind test,
Michael Albinus <=
- [elpa] master f6d7a74 074/187: Merge pull request #18 from DarwinAwardWinner/lexbind-fix, Michael Albinus, 2015/12/30
- [elpa] master 9b5bb5c 072/187: Add more comprehensive testing for anti-closure feature, Michael Albinus, 2015/12/30
- [elpa] master 204750d 081/187: Revert "* helm-async.el: Fix error handling.", Michael Albinus, 2015/12/30
- [elpa] master b05c63a 083/187: Don't rely on async.el being in load-path., Michael Albinus, 2015/12/30
- [elpa] master 374f514 079/187: Complete the docstring for "async--get-function", Michael Albinus, 2015/12/30
- [elpa] master 9704eb8 080/187: Merge pull request #21 from DarwinAwardWinner/lexbind-fix, Michael Albinus, 2015/12/30
- [elpa] master 4a7b07b 084/187: Merge pull request #23 from DarwinAwardWinner/no-load-path-fix, Michael Albinus, 2015/12/30
- [elpa] master 2a532d3 077/187: Replace closure prevention with closure sanitation, Michael Albinus, 2015/12/30
- [elpa] master f18c735 078/187: Merge pull request #19 from DarwinAwardWinner/lexbind-fix, Michael Albinus, 2015/12/30
- [elpa] master 3f751fb 082/187: Revert master back to 242ae73, Michael Albinus, 2015/12/30