* [PATCH] Added org-test.el that contains some unit tests.
@ 2008-11-16 22:13 Piotr Zielinski
0 siblings, 0 replies; only message in thread
From: Piotr Zielinski @ 2008-11-16 22:13 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 276 bytes --]
This is file is really provisional to get us started with unit tests.
It tests some changes made recently by me, and exposes a bug
org-make-tags-matcher. Please feel free to rewrite/reorganize it, and
port it to a unit test framework when we decide which one to use.
Piotr
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0007-Added-org-test.el-that-contains-some-unit-tests.patch --]
[-- Type: text/x-patch; name=0007-Added-org-test.el-that-contains-some-unit-tests.patch, Size: 3144 bytes --]
From 244885b51f6c85e4a3f72af83587ec2d6490df8a Mon Sep 17 00:00:00 2001
From: Piotr Zielinski <piotr.zielinski@gmail.com>
Date: Sun, 16 Nov 2008 22:01:47 +0000
Subject: [PATCH] Added org-test.el that contains some unit tests.
This is file is really provisional to get us started with unit tests.
It tests some changes made recently by me, and exposes a bug
org-make-tags-matcher. Please feel free to rewrite/reorganize it, and
port it to a unit test framework when we decide which one to use.
---
lisp/org-test.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
create mode 100644 lisp/org-test.el
diff --git a/lisp/org-test.el b/lisp/org-test.el
new file mode 100644
index 0000000..7178c19
--- /dev/null
+++ b/lisp/org-test.el
@@ -0,0 +1,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>\"")))
+
+
+
--
1.5.2.5
[-- Attachment #3: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-16 22:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-16 22:13 [PATCH] Added org-test.el that contains some unit tests Piotr Zielinski
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).