The delorean Reference Manual

Table of Contents

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

The delorean Reference Manual

This is the delorean Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:48:18 2018 GMT+0.


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

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.


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

2 Systems

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


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

2.1 delorean

Author

Andy Chambers

Description

Delorean is a time machine for unit tests

Dependency

local-time

Source

delorean.asd (file)

Component

delorean.lisp (file)


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

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 files   [Contents][Index]

3.1.1 delorean.asd

Location

delorean.asd

Systems

delorean (system)


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

3.1.2 delorean/delorean.lisp

Parent

delorean (system)

Location

delorean.lisp

Packages

delorean

Exported Definitions
Internal Definitions

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

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 (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

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 (file)

Macro: with-scaled-clock SCALE &body BODY

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

Package

delorean

Source

delorean.lisp (file)

Macro: with-shifted-clock TO &body BODY

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

Package

delorean

Source

delorean.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Classes

Class: frozen-clock ()

A clock which allows time to be frozen in perpetuity

Package

delorean

Source

delorean.lisp (file)

Direct superclasses

mock-clock (class)

Direct methods
  • clock-now (method)
  • frozen-time (method)
  • frozen-time (method)
Direct slots
Slot: frozen-time
Initargs

:frozen-time

Readers

frozen-time (generic function)

Writers

(setf frozen-time) (generic function)

Class: scaled-clock ()

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

Package

delorean

Source

delorean.lisp (file)

Direct superclasses

mock-clock (class)

Direct methods
  • clock-now (method)
  • scale (method)
  • scale (method)
Direct slots
Slot: scale
Initargs

:scale

Readers

scale (generic function)

Writers

(setf scale) (generic function)

Class: shifted-clock ()

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

Package

delorean

Source

delorean.lisp (file)

Direct superclasses

mock-clock (class)

Direct methods
  • clock-now (method)
  • shifted-time (method)
  • shifted-time (method)
Direct slots
Slot: shifted-time
Initargs

:shifted-time

Readers

shifted-time (generic function)

Writers

(setf shifted-time) (generic function)


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

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Generic functions

Generic Function: created-at OBJECT
Generic Function: (setf created-at) NEW-VALUE OBJECT
Package

delorean

Methods
Method: created-at (MOCK-CLOCK mock-clock)

automatically generated reader method

Source

delorean.lisp (file)

Method: (setf created-at) NEW-VALUE (MOCK-CLOCK mock-clock)

automatically generated writer method

Source

delorean.lisp (file)

Generic Function: frozen-time OBJECT
Generic Function: (setf frozen-time) NEW-VALUE OBJECT
Package

delorean

Methods
Method: frozen-time (FROZEN-CLOCK frozen-clock)

automatically generated reader method

Source

delorean.lisp (file)

Method: (setf frozen-time) NEW-VALUE (FROZEN-CLOCK frozen-clock)

automatically generated writer method

Source

delorean.lisp (file)

Generic Function: parent-clock OBJECT
Generic Function: (setf parent-clock) NEW-VALUE OBJECT
Package

delorean

Methods
Method: parent-clock (MOCK-CLOCK mock-clock)

automatically generated reader method

Source

delorean.lisp (file)

Method: (setf parent-clock) NEW-VALUE (MOCK-CLOCK mock-clock)

automatically generated writer method

Source

delorean.lisp (file)

Generic Function: parent-now SELF
Package

delorean

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

delorean.lisp (file)

Generic Function: scale OBJECT
Generic Function: (setf scale) NEW-VALUE OBJECT
Package

delorean

Methods
Method: scale (SCALED-CLOCK scaled-clock)

automatically generated reader method

Source

delorean.lisp (file)

Method: (setf scale) NEW-VALUE (SCALED-CLOCK scaled-clock)

automatically generated writer method

Source

delorean.lisp (file)

Generic Function: shifted-time OBJECT
Generic Function: (setf shifted-time) NEW-VALUE OBJECT
Package

delorean

Methods
Method: shifted-time (SHIFTED-CLOCK shifted-clock)

automatically generated reader method

Source

delorean.lisp (file)

Method: (setf shifted-time) NEW-VALUE (SHIFTED-CLOCK shifted-clock)

automatically generated writer method

Source

delorean.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Classes

Class: mock-clock ()

The base class that is extended by all mock clocks

Package

delorean

Source

delorean.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses
Direct methods
Direct slots
Slot: created-at
Initargs

:created-at

Readers

created-at (generic function)

Writers

(setf created-at) (generic function)

Slot: parent-clock
Initargs

:parent-clock

Readers

parent-clock (generic function)

Writers

(setf parent-clock) (generic function)

Direct Default Initargs
InitargValue
:created-at(local-time:now)
:parent-clocklocal-time:*clock*

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

Appendix A Indexes


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

A.1 Concepts

Jump to:   D   F   L  
Index Entry  Section

D
delorean.asd: The delorean<dot>asd file
delorean/delorean.lisp: The delorean/delorean<dot>lisp file

F
File, Lisp, delorean.asd: The delorean<dot>asd file
File, Lisp, delorean/delorean.lisp: The delorean/delorean<dot>lisp file

L
Lisp File, delorean.asd: The delorean<dot>asd file
Lisp File, delorean/delorean.lisp: The delorean/delorean<dot>lisp file

Jump to:   D   F   L  

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

A.2 Functions

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

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

C
created-at: Internal generic functions
created-at: Internal generic functions

F
frozen-time: Internal generic functions
frozen-time: Internal generic functions

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

M
Macro, with-frozen-clock: Exported macros
Macro, with-scaled-clock: Exported macros
Macro, with-shifted-clock: Exported macros
Method, (setf created-at): Internal generic functions
Method, (setf frozen-time): Internal generic functions
Method, (setf parent-clock): Internal generic functions
Method, (setf scale): Internal generic functions
Method, (setf shifted-time): Internal generic functions
Method, created-at: Internal generic functions
Method, frozen-time: Internal generic functions
Method, parent-clock: Internal generic functions
Method, parent-now: Internal generic functions
Method, scale: Internal generic functions
Method, shifted-time: Internal generic functions

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

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

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

Jump to:   (  
C   F   G   M   P   S   W  

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

A.3 Variables

Jump to:   C   F   P   S  
Index Entry  Section

C
created-at: Internal classes

F
frozen-time: Exported classes

P
parent-clock: Internal classes

S
scale: Exported classes
shifted-time: Exported classes
Slot, created-at: Internal classes
Slot, frozen-time: Exported classes
Slot, parent-clock: Internal classes
Slot, scale: Exported classes
Slot, shifted-time: Exported classes

Jump to:   C   F   P   S  

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

A.4 Data types

Jump to:   C   D   F   M   P   S  
Index Entry  Section

C
Class, frozen-clock: Exported classes
Class, mock-clock: Internal classes
Class, scaled-clock: Exported classes
Class, shifted-clock: Exported classes

D
delorean: The delorean system
delorean: The delorean package

F
frozen-clock: Exported classes

M
mock-clock: Internal classes

P
Package, delorean: The delorean package

S
scaled-clock: Exported classes
shifted-clock: Exported classes
System, delorean: The delorean system

Jump to:   C   D   F   M   P   S