shard-spectator/src/spectator/value.cr
Michael Miller a74957204b
Introduce abstract generic value type
Sits between AbstractExpression and Value and Block.
2021-01-15 22:32:02 -07:00

22 lines
689 B
Crystal

require "./expression"
require "./label"
module Spectator
# Represents a value from a test.
# This is typically captured by an `expect` macro.
# It consists of a label and the value of the expression.
# The label should be a string recognizable by the user,
# or nil if one isn't available.
class Value(T) < Expression(T)
# Raw value of the expression.
getter value : T
# Creates the value.
# Expects the *value* of the expression and a *label* describing it.
# The *label* is usually the Crystal code evaluating to the *value*.
# It can be nil if it isn't available.
def initialize(@value : T, label : Label)
super(label)
end
end
end