The delorean Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The delorean Reference Manual

This is the delorean Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 04:25:53 2022 GMT+0.

Table of Contents


1 Introduction

delorean

A simple set of macros for mocking time

Usage

(deftest delorean ()
  (let ((point-in-time (local-time:now)))
    (with-frozen-clock point-in-time
      (sleep 2)
      (is (local-time:timestamp= (local-time:now) point-in-time))))


  (let ((same-time-tomorrow (local-time:timestamp+ (local-time:now) 1 :day)))
    (with-shifted-clock same-time-tomorrow
      (sleep 2)
      (is (local-time:timestamp= (local-time:now)
           (local-time:timestamp-minimize-part
            (local-time:timestamp+ same-time-tomorrow 2 :sec) :nsec)))))

  
  (let ((now (local-time:now)))
    (with-scaled-clock 2
      (sleep 2)
      (is (local-time:timestamp= (local-time:now)
            (local-time:timestamp-minimize-part
              (local-time:timestamp+ now 4 :sec) :nsec))))))

The respective clocks can be nested arbitrarily inside one-another.

Development

Development of delorean is hosted on github at https://github.com/cddr/delorean.

To my knowledge, there is currently 1 user (i.e. me) so I'm just hacking directly on master. If you start to find it useful, let me know and we can formalize the release process a little but I don't foresee lots of changes. It's a pretty simple solution to a small problem.

Check out the Makefile for the details of how to build and test the software. It's shamelessly copied from cffi (Luís Oliveira is awesome). It also includes a target to build documentation using atdoc (David Lichteblau is also awesome).

Bugs?

What bugs? No really, if you find a bug, let me know by raising a github issue.


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 delorean

Delorean is a time machine for unit tests

Author

Andy Chambers

Dependency

local-time (system).

Source

delorean.asd.

Child Component

delorean.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 delorean/delorean.asd

Source

delorean.asd.

Parent Component

delorean (system).

ASDF Systems

delorean.


Previous: , Up: Lisp   [Contents][Index]

3.1.2 delorean/delorean.lisp

Source

delorean.asd.

Parent Component

delorean (system).

Packages

delorean.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 delorean

A set of macros loosely based on travisjeffery’s timecop
library with the purpose of making it easier to test time-sensitive code

Source

delorean.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: with-frozen-clock (time &body body)

Freezes the notion of local-time’s ‘now’ function

Within body (and any code called by body), calling (now) will always return ‘time’

Package

delorean.

Source

delorean.lisp.

Macro: with-scaled-clock (scale &body body)

Accelerates (or decelarates) time by a factor indicated by ‘scale’

Package

delorean.

Source

delorean.lisp.

Macro: with-shifted-clock (to &body body)

Teleports to the time indicated by ‘to’ before executing ‘body’

Package

delorean.

Source

delorean.lisp.


Next: , Previous: , Up: Public Interface   [Contents][Index]

5.1.2 Standalone methods

Method: clock-now ((self shifted-clock))
Package

local-time.

Source

delorean.lisp.

Method: clock-now ((self frozen-clock))
Package

local-time.

Source

delorean.lisp.

Method: clock-now ((self scaled-clock))
Package

local-time.

Source

delorean.lisp.


5.1.3 Classes

Class: frozen-clock

A clock which allows time to be frozen in perpetuity

Package

delorean.

Source

delorean.lisp.

Direct superclasses

mock-clock.

Direct methods
Direct slots
Slot: frozen-time
Initargs

:frozen-time

Readers

frozen-time.

Writers

(setf frozen-time).

Class: scaled-clock

A clock which allows time to proceed faster or slower than normal

Package

delorean.

Source

delorean.lisp.

Direct superclasses

mock-clock.

Direct methods
Direct slots
Slot: scale
Initargs

:scale

Readers

scale.

Writers

(setf scale).

Class: shifted-clock

A clock which allows time to be shifted to the specified time

Package

delorean.

Source

delorean.lisp.

Direct superclasses

mock-clock.

Direct methods
Direct slots
Slot: shifted-time
Initargs

:shifted-time

Readers

shifted-time.

Writers

(setf shifted-time).


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Generic functions

Generic Reader: created-at (object)
Package

delorean.

Methods
Reader Method: created-at ((mock-clock mock-clock))

automatically generated reader method

Source

delorean.lisp.

Target Slot

created-at.

Generic Writer: (setf created-at) (object)
Package

delorean.

Methods
Writer Method: (setf created-at) ((mock-clock mock-clock))

automatically generated writer method

Source

delorean.lisp.

Target Slot

created-at.

Generic Reader: frozen-time (object)
Package

delorean.

Methods
Reader Method: frozen-time ((frozen-clock frozen-clock))

automatically generated reader method

Source

delorean.lisp.

Target Slot

frozen-time.

Generic Writer: (setf frozen-time) (object)
Package

delorean.

Methods
Writer Method: (setf frozen-time) ((frozen-clock frozen-clock))

automatically generated writer method

Source

delorean.lisp.

Target Slot

frozen-time.

Generic Reader: parent-clock (object)
Package

delorean.

Methods
Reader Method: parent-clock ((mock-clock mock-clock))

automatically generated reader method

Source

delorean.lisp.

Target Slot

parent-clock.

Generic Writer: (setf parent-clock) (object)
Package

delorean.

Methods
Writer Method: (setf parent-clock) ((mock-clock mock-clock))

automatically generated writer method

Source

delorean.lisp.

Target Slot

parent-clock.

Generic Function: parent-now (self)
Package

delorean.

Methods
Method: parent-now ((self mock-clock))
Source

delorean.lisp.

Generic Reader: scale (object)
Package

delorean.

Methods
Reader Method: scale ((scaled-clock scaled-clock))

automatically generated reader method

Source

delorean.lisp.

Target Slot

scale.

Generic Writer: (setf scale) (object)
Package

delorean.

Methods
Writer Method: (setf scale) ((scaled-clock scaled-clock))

automatically generated writer method

Source

delorean.lisp.

Target Slot

scale.

Generic Reader: shifted-time (object)
Package

delorean.

Methods
Reader Method: shifted-time ((shifted-clock shifted-clock))

automatically generated reader method

Source

delorean.lisp.

Target Slot

shifted-time.

Generic Writer: (setf shifted-time) (object)
Package

delorean.

Methods
Writer Method: (setf shifted-time) ((shifted-clock shifted-clock))

automatically generated writer method

Source

delorean.lisp.

Target Slot

shifted-time.


Previous: , Up: Internals   [Contents][Index]

5.2.2 Classes

Class: mock-clock

The base class that is extended by all mock clocks

Package

delorean.

Source

delorean.lisp.

Direct subclasses
Direct methods
Direct Default Initargs
InitargValue
:created-at(now)
:parent-clock*clock*
Direct slots
Slot: created-at
Initargs

:created-at

Readers

created-at.

Writers

(setf created-at).

Slot: parent-clock
Initargs

:parent-clock

Readers

parent-clock.

Writers

(setf parent-clock).


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
C   F   G   M   P   S   W  
Index Entry  Section

(
(setf created-at): Private generic functions
(setf created-at): Private generic functions
(setf frozen-time): Private generic functions
(setf frozen-time): Private generic functions
(setf parent-clock): Private generic functions
(setf parent-clock): Private generic functions
(setf scale): Private generic functions
(setf scale): Private generic functions
(setf shifted-time): Private generic functions
(setf shifted-time): Private generic functions

C
clock-now: Public standalone methods
clock-now: Public standalone methods
clock-now: Public standalone methods
created-at: Private generic functions
created-at: Private generic functions

F
frozen-time: Private generic functions
frozen-time: Private generic functions

G
Generic Function, (setf created-at): Private generic functions
Generic Function, (setf frozen-time): Private generic functions
Generic Function, (setf parent-clock): Private generic functions
Generic Function, (setf scale): Private generic functions
Generic Function, (setf shifted-time): Private generic functions
Generic Function, created-at: Private generic functions
Generic Function, frozen-time: Private generic functions
Generic Function, parent-clock: Private generic functions
Generic Function, parent-now: Private generic functions
Generic Function, scale: Private generic functions
Generic Function, shifted-time: Private generic functions

M
Macro, with-frozen-clock: Public macros
Macro, with-scaled-clock: Public macros
Macro, with-shifted-clock: Public macros
Method, (setf created-at): Private generic functions
Method, (setf frozen-time): Private generic functions
Method, (setf parent-clock): Private generic functions
Method, (setf scale): Private generic functions
Method, (setf shifted-time): Private generic functions
Method, clock-now: Public standalone methods
Method, clock-now: Public standalone methods
Method, clock-now: Public standalone methods
Method, created-at: Private generic functions
Method, frozen-time: Private generic functions
Method, parent-clock: Private generic functions
Method, parent-now: Private generic functions
Method, scale: Private generic functions
Method, shifted-time: Private generic functions

P
parent-clock: Private generic functions
parent-clock: Private generic functions
parent-now: Private generic functions
parent-now: Private generic functions

S
scale: Private generic functions
scale: Private generic functions
shifted-time: Private generic functions
shifted-time: Private generic functions

W
with-frozen-clock: Public macros
with-scaled-clock: Public macros
with-shifted-clock: Public macros

Jump to:   (  
C   F   G   M   P   S   W