help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to debug functions depending on (current-time)?


From: Pascal J. Bourguignon
Subject: Re: How to debug functions depending on (current-time)?
Date: Wed, 15 Jul 2015 22:47:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Marcin Borkowski <mbork@mbork.pl> writes:

> Hi all,
>
> I have a bunch of functions depending on (current-time), and I'm
> wondering how to test/debug them.  Is it safe to (temporarily) redefine
> `current-time'?  Maybe it's better to do that in a separate Emacs
> instance?  I could of course change their source code for the time of
> debugging, but this still lefts the problem of testing (esp. automatic
> testing) open.

Any problem in programming can be solved by one more level of
indirection.


(defvar *my-current-time-function* 'current-time)
(defun my-current-time-function () (funcall *my-current-time-function*))

(defvar *test-time* 0)
(when testing
  (let ((*my-current-time-function* (lambda () (incf *test-time*))))
    (test)))

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk


reply via email to

[Prev in Thread] Current Thread [Next in Thread]