Class Double

Class for creating test doubles.

For full description see test doubles. This class follows the pattern from Lua classes.

Metamethods

Double:__index (key) Lookup of missing class members.
Double:__call (...) Get arguments for a functionlike call.

Methods

Double:create (...) Create a new instance.
Double:_init (...) Initialize a new instance.
Double:dispatch (...) Dispatch arguments
Double:setName (name) Set identifying name
Double:hasName () Has set name.
Double:setLevel (level) Set stack level.
Double:hasLevel () Has set level.
Double:setOnEmpty (func) Set on empty fallback.
Double:hasOnEmpty () Has set empty fallback.
Double:isEmpty () Is the list of values empty.
Double:depth () What is the depth of the internal values list.
Double:layout () Get the layout of the values list.
Double:add (...) Add value(s) to the list of values.
Double:remove (num) Remove value from the list of values.
Double:stub () Return a stub function for the object.
Double:hasStub () Has set stub function.
Double:export () Export a list of all the contents.
Double:flush () Flush all the contents.


Metamethods

Double:__index (key)
Lookup of missing class members.

Parameters:

Returns:

any

Raises:

on wrong arguments
Double:__call (...)
Get arguments for a functionlike call.

Parameters:

  • ... vararg pass on to dispatch

Returns:

self

Methods

Double:create (...)
Create a new instance.

Parameters:

  • ... vararg forwarded to _init()

Returns:

self
Double:_init (...)
Initialize a new instance.

Parameters:

  • ... vararg shifted into the values list

Returns:

self
Double:dispatch (...)
Dispatch arguments

Parameters:

  • ... vararg argumnts to be stored for later retrieval

Returns:

self

Raises:

on wrong arguments
Double:setName (name)
Set identifying name

Parameters:

  • name nil or string used for error reports treturn self

Raises:

on wrong arguments
Double:hasName ()
Has set name. treturn boolean
Double:setLevel (level)
Set stack level.

Parameters:

  • level nil or number where to start reporting treturn self

Raises:

on wrong arguments
Double:hasLevel ()
Has set level. treturn boolean
Double:setOnEmpty (func)
Set on empty fallback.

Parameters:

  • func nil or function fallback to be used in place of precomputed values treturn self

Raises:

on wrong arguments
Double:hasOnEmpty ()
Has set empty fallback. treturn boolean
Double:isEmpty ()
Is the list of values empty. Note that the internal structure is non-empty even if a nil is shifted into the values list.

Returns:

boolean whether the internal values list has length zero
Double:depth ()
What is the depth of the internal values list. Note that the internal structure has a depth even if a nil is shifted into the values list.

Returns:

number how deep is the internal structure
Double:layout ()
Get the layout of the values list. This method is used for testing to inspect which types of objects exists in the values list.

Returns:

table description of the internal structure
Double:add (...)
Add value(s) to the list of values.

Parameters:

  • ...

Returns:

self facilitate chaining
Double:remove (num)
Remove value from the list of values.

Parameters:

  • num

Returns:

any item that can be put on the internal structure
Double:stub ()
Return a stub function for the object. Each call to the returned closure will remove one case of values from the internal structure.

Returns:

closure
Double:hasStub ()
Has set stub function. treturn boolean
Double:export ()
Export a list of all the contents.

Returns:

table list of values
Double:flush ()
Flush all the contents. Note that this clears the internal storage.

Returns:

table list of values
generated by LDoc 1.4.6