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*. def initialize(@value : T, label : Label) super(label) end # Creates the value. # Expects the *value* of the expression. # It can be nil if it isn't available. # A label is generated by calling `#inspect` on the *value*. def initialize(@value : T) super(@value.inspect) end end end