X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/322b7dab59b98b5d8625d2cd29e48f1ce605f769..5244bc019bf7376caff3bb198ff674e0ad9fb0e6:/lisp/url/url-future.el diff --git a/lisp/url/url-future.el b/lisp/url/url-future.el index ac85a3cec4..db074807e1 100644 --- a/lisp/url/url-future.el +++ b/lisp/url/url-future.el @@ -1,6 +1,6 @@ ;;; url-future.el --- general futures facility for url.el -;; Copyright (C) 2011 Free Software Foundation, Inc. +;; Copyright (C) 2011-2012 Free Software Foundation, Inc. ;; Author: Teodor Zlatanov ;; Keywords: data @@ -36,14 +36,13 @@ ;; So, to get the value: ;; (when (url-future-completed-p future) (url-future-value future)) -;; See the ERT tests and the code for futher details. +;; See `url-future-tests' and the code below for further details. ;;; Code: -(eval-when-compile (require 'cl)) -(eval-when-compile (require 'ert)) +(eval-when-compile (require 'cl-lib)) -(defstruct url-future callback errorback status value) +(cl-defstruct url-future callback errorback status value) (defmacro url-future-done-p (url-future) `(url-future-status ,url-future)) @@ -95,32 +94,5 @@ (signal 'error 'url-future-already-done) (url-future-finish url-future 'cancel))) -(ert-deftest url-future-test () - (let* (saver - (text "running future") - (good (make-url-future :value (lambda () (format text)) - :callback (lambda (f) (set 'saver f)))) - (bad (make-url-future :value (lambda () (/ 1 0)) - :errorback (lambda (&rest d) (set 'saver d)))) - (tocancel (make-url-future :value (lambda () (/ 1 0)) - :callback (lambda (f) (set 'saver f)) - :errorback (lambda (&rest d) - (set 'saver d))))) - (should (equal good (url-future-call good))) - (should (equal good saver)) - (should (equal text (url-future-value good))) - (should (url-future-completed-p good)) - (should-error (url-future-call good)) - (setq saver nil) - (should (equal bad (url-future-call bad))) - (should-error (url-future-call bad)) - (should (equal saver (list bad '(arith-error)))) - (should (url-future-errored-p bad)) - (setq saver nil) - (should (equal (url-future-cancel tocancel) tocancel)) - (should-error (url-future-call tocancel)) - (should (null saver)) - (should (url-future-cancelled-p tocancel)))) - (provide 'url-future) ;;; url-future.el ends here