2018-08-31 03:07:14 +00:00
|
|
|
module Spectator
|
2018-11-16 16:48:35 +00:00
|
|
|
# Base class that represents the outcome of running an example.
|
|
|
|
# Sub-classes contain additional information specific to the type of result.
|
2018-09-15 19:25:11 +00:00
|
|
|
abstract class Result
|
2018-11-16 16:48:35 +00:00
|
|
|
# Example that was run that this result is for.
|
2018-08-31 03:07:14 +00:00
|
|
|
getter example : Example
|
2018-11-16 16:48:35 +00:00
|
|
|
|
|
|
|
# Constructs the base of the result.
|
2019-02-18 06:01:43 +00:00
|
|
|
# The *example* should refer to the example that was run
|
2018-11-16 16:48:35 +00:00
|
|
|
# and that this result is for.
|
2018-12-10 18:16:43 +00:00
|
|
|
def initialize(@example)
|
2018-08-31 03:07:14 +00:00
|
|
|
end
|
2019-02-17 21:24:02 +00:00
|
|
|
|
|
|
|
# Calls the corresponding method for the type of result.
|
|
|
|
# This is used to avoid placing if or case-statements everywhere based on type.
|
2019-02-18 06:01:43 +00:00
|
|
|
# Each sub-class implements this method by calling the correct method on *interface*.
|
2019-02-17 21:24:02 +00:00
|
|
|
abstract def call(interface)
|
2019-02-21 04:00:22 +00:00
|
|
|
|
|
|
|
# Calls the corresponding method for the type of result.
|
|
|
|
# This is used to avoid placing if or case-statements everywhere based on type.
|
|
|
|
# Each sub-class implements this method by calling the correct method on *interface*.
|
|
|
|
# This variation takes a block, which is passed the result.
|
|
|
|
# The value returned from the block will be returned by this method.
|
|
|
|
abstract def call(interface, &block : Result -> _)
|
2018-08-31 03:07:14 +00:00
|
|
|
end
|
|
|
|
end
|