Skip Menu |

This queue is for tickets about the Time-Mock CPAN distribution.

Report information
The Basics
Id: 49543
Status: open
Priority: 0/
Queue: Time-Mock

People
Owner: Nobody in particular
Requestors: CWW [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • v0.0.1
  • v0.0.2
Fixed in: (no value)



Subject: Time::Mock should have a way to un-mock itself
It seems like Time::Mock should have an obvious, explicit way to un-mock itself. For example, if I execute "Time::Mock->offset(SESSION_LIFETIME + 1);", then I'd like to be able to execute something like "Time::Mock->reset()" after I'm done testing my expired session. That would make time() work like it always did, until the next time I call a Time::Mock function. As it is, I'm resetting the clock by executing "Time::Mock->offset(0);", and I don't find that to be very intuitive or safe. Its behavior is also ill-defined: reading the documentation, I'm not necessarily certain whether offset(0) will set the time back to the time at which the module was imported or to the current system time. Thanks for the great work. Before I found your module, I tried using Test::MockObject on CORE, and that didn't work very well. :)
Subject: Re: [rt.cpan.org #49543] Time::Mock should have a way to un-mock itself
Date: Wed, 9 Sep 2009 00:22:09 -0700
To: bug-Time-Mock [...] rt.cpan.org
From: Eric Wilhelm <enobacon [...] gmail.com>
Hi Colin, # from Colin Wetherbee via RT # on Tuesday 08 September 2009 23:40: Show quoted text
>It seems like Time::Mock should have an obvious, explicit way to > un-mock itself.
Subject to the standard caveats about already-running sleeps and alarms, of course. Show quoted text
>For example, if I execute "Time::Mock->offset(SESSION_LIFETIME + 1);", >then I'd like to be able to execute something like > "Time::Mock->reset()" after I'm done testing my expired session. >  That would make time() work like it always did, until the next time > I call a Time::Mock function.
Would you expect that to also reset the throttle? Show quoted text
>As it is, I'm resetting the clock by executing > "Time::Mock->offset(0);", and I don't find that to be very intuitive > or safe.  Its behavior is also ill-defined: reading the > documentation, I'm not necessarily certain whether offset(0) will set > the time back to the time at which the module was imported or to the > current system time.
Calling offset(0) is perfectly safe -- it just brings you back to now. Time always marches forward (well, I haven't tried throttle(-1) :-D .) It sounds like the documentation could use some work. I've made some changes here. Please let me know if these would help. http://svn.scratchcomputing.com/Time-Mock/trunk/lib/Time/Mock.pm Thanks, Eric