From: Ryan C. Thompson Date: Mon, 21 Oct 2013 23:06:13 +0000 (-0700) Subject: Add test for handling different ways of passing a function X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/ba705c61187e969a67ce59c38861154ce7144eec Add test for handling different ways of passing a function --- diff --git a/async-test.el b/async-test.el index b416c1823..b77fdd14a 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))