shard-spectator/src/spectator/test_expression.cr
Michael Miller 114bfa47c2 Genericize TestExpression and make value abstract
This seems to resolve issues with the compiler making unions of
unrelated test case types.
2019-08-09 11:12:15 -06:00

25 lines
635 B
Crystal

module Spectator
# Base type for capturing an expression from a test.
abstract struct TestExpression(T)
# User-friendly string displayed for the actual expression being tested.
# For instance, in the expectation:
# ```
# expect(foo).to eq(bar)
# ```
# This property will be "foo".
# It will be the literal string "foo",
# and not the actual value of the foo.
getter label : String
# Creates the common base of the expression.
def initialize(@label)
end
abstract def value : T
# String representation of the expression.
def to_s(io)
io << label
end
end
end