emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob 7178c194d58c52751fc5438710ce9e14eff07e7e 2257 bytes (raw)
name: lisp/org-test.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 
;; org-test.el --- Unit tests for org.el
;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.

;; This file contains some unorganized unit tests.  
;; TODO: replace with proper test when we decide on a framework

(require 'org)

(defmacro with-current-time-as (decoded-time &rest body)
  "Executes the body with current time set to decoded-time.

   This macro is not comprehensive and does only enough to make
   the tests pass.  TODO: replace this with something proper, eg
   a mock once we decide what framework we should use."
  (let ((float-time (float-time (apply 'encode-time (eval decoded-time))))
        (float-time-function (symbol-function 'float-time)))
    `(flet ((decode-time () ,decoded-time)
            (float-time (&optional specified-time)
              (if specified-time
                (funcall ,float-time-function specified-time)
              ,float-time)))
       ,@body)))

(with-current-time-as '(0 7 21 16 11 2008 0 nil 0)
  (assert (= 1226793600.0 (org-time-today)))
  (assert (= 1226793600.0 (org-matcher-time "<today>")))
  (assert (= 1226880000.0 (org-matcher-time "<tomorrow>")))
  (assert (= 1226869620.0 (org-matcher-time "<now>")))

  (assert (equal
           '("+tag1+tag2-tag3" and
             (progn
               (setq org-cached-props nil)
               (and (not (member "tag3" tags-list))
                    (member "tag2" tags-list)
                    (member "tag1" tags-list)))
             t)
           (org-make-tags-matcher "+tag1+tag2-tag3")))

  (assert (equal
           '("+SCHEDULED=\"<now>\"" and
             (progn
               (setq org-cached-props nil)
               (org-time= (or (org-cached-entry-get nil "SCHEDULED") "")
                          1226869620.0))
             t)
           (org-make-tags-matcher "+SCHEDULED=\"<now>\"")))

  ;; FIXME: this test fails because of a bug in org-make-tags-matcher
  (assert (equal
           '("+SCHEDULED=\"<2008-11-16 Wed 21:07>\"" and
             (progn
               (setq org-cached-props nil)
               (org-time= (or (org-cached-entry-get nil "SCHEDULED") "")
                          1226869620.0)))
           t)
           (org-make-tags-matcher "+SCHEDULED=\"<2008-11-16 Wed 21:07>\"")))




debug log:

solving 7178c19 ...
found 7178c19 in https://list.orgmode.org/orgmode/3c12eb8d0811161413u7fc704aajb6f5347578be6045@mail.gmail.com/

applying [1/1] https://list.orgmode.org/orgmode/3c12eb8d0811161413u7fc704aajb6f5347578be6045@mail.gmail.com/
diff --git a/lisp/org-test.el b/lisp/org-test.el
new file mode 100644
index 0000000..7178c19

1:10: trailing whitespace.
;; This file contains some unorganized unit tests.  
Checking patch lisp/org-test.el...
1:64: new blank line at EOF.
+
Applied patch lisp/org-test.el cleanly.
warning: 2 lines add whitespace errors.

index at:
100644 7178c194d58c52751fc5438710ce9e14eff07e7e	lisp/org-test.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).