]> code.delx.au - gnu-emacs-elpa/commitdiff
Add test for handling different ways of passing a function
authorRyan C. Thompson <rct@thompsonclan.org>
Mon, 21 Oct 2013 23:06:13 +0000 (16:06 -0700)
committerRyan C. Thompson <rct@thompsonclan.org>
Tue, 22 Oct 2013 00:13:15 +0000 (17:13 -0700)
async-test.el

index b416c18230a783376ad7d507c852972c426dbe6d..b77fdd14a03b02bc83c16df85a6a3cdbe6e181fb 100644 (file)
@@ -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))