branch: master
commit ba705c61187e969a67ce59c38861154ce7144eec
Author: Ryan C. Thompson <[email protected]>
Commit: Ryan C. Thompson <[email protected]>
Add test for handling different ways of passing a function
---
async-test.el | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/async-test.el b/async-test.el
index b416c18..b77fdd1 100644
--- a/async-test.el
+++ b/async-test.el
@@ -252,6 +252,36 @@ 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-start-func-value-type-test ()
+ ;; Variable
+ (set 'myfunc-var (lambda () t))
+ ;; Function symbol
+ (fset 'myfunc-fsym myfunc-var)
+ ;; Defun
+ (defun myfunc-defun () t)
+
+ (should-error (error "ERROR"))
+
+ (should (eq t (eval '(async-sandbox myfunc-var))))
+ (should-error (eval '(async-sandbox 'myfunc-var)))
+ (should-error (eval '(async-sandbox #'myfunc-var)))
+
+ (should-error (eval '(async-sandbox myfunc-fsym)))
+ (should (eq t (eval '(async-sandbox 'myfunc-fsym))))
+ (should (eq t (eval '(async-sandbox #'myfunc-fsym))))
+
+ (should-error (eval '(async-sandbox myfunc-defun)))
+ (should (eq t (eval '(async-sandbox 'myfunc-defun))))
+ (should (eq t (eval '(async-sandbox #'myfunc-defun))))
+
+ (should (eq t (eval '(async-sandbox (lambda () t)))))
+ (should (eq t (eval '(async-sandbox '(lambda () t)))))
+ (should (eq t (eval '(async-sandbox #'(lambda () t)))))
+
+ (should-error (eval '(async-sandbox (closure (t) () t))))
+ (should (eq t (eval '(async-sandbox '(closure (t) () t)))))
+ (should (eq t (eval '(async-sandbox #'(closure (t) () 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)
@@ -314,6 +344,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-start-func-value-type-test ()
+ (async-do-start-func-value-type-test))
+
(ert-deftest async-lexbind-test ()
(async-do-lexbind-test))