mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Adopt ValueMatcher to new Expectation type
This commit is contained in:
parent
06ced9f799
commit
718f24aef3
1 changed files with 9 additions and 2 deletions
|
@ -3,7 +3,7 @@ require "./matcher"
|
||||||
module Spectator::Matchers
|
module Spectator::Matchers
|
||||||
# Category of matcher that uses a value.
|
# Category of matcher that uses a value.
|
||||||
# Matchers of this type expect that a SUT applies to the value in some way.
|
# Matchers of this type expect that a SUT applies to the value in some way.
|
||||||
# Sub-types must implement `#match`, `#message`, and `#negated_message`.
|
# Sub-types must implement `#match?`, `#message`, and `#negated_message`.
|
||||||
# Those methods accept a `ValueExpectationPartial` to work with.
|
# Those methods accept a `ValueExpectationPartial` to work with.
|
||||||
abstract struct ValueMatcher(ExpectedType) < Matcher
|
abstract struct ValueMatcher(ExpectedType) < Matcher
|
||||||
# Expected value.
|
# Expected value.
|
||||||
|
@ -25,7 +25,14 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determines whether the matcher is satisfied with the value given to it.
|
# Determines whether the matcher is satisfied with the value given to it.
|
||||||
# True is returned if the match was successful, false otherwise.
|
# An `Expectation` is returned containing all match information.
|
||||||
|
def eval(partial : ValueExpectationPartial(ActualType), negated = false) : Expectation forall ActualType
|
||||||
|
matched = match?(partial)
|
||||||
|
ValueExpectation.new(matched, negated, partial, self)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Determines whether the matcher is satisfied with the value given to it.
|
||||||
|
# True is returned if the matcher is satisfied, false otherwise.
|
||||||
abstract def match?(partial : ValueExpectationPartial(ActualType)) : Bool forall ActualType
|
abstract def match?(partial : ValueExpectationPartial(ActualType)) : Bool forall ActualType
|
||||||
|
|
||||||
# Describes the condition that satisfies the matcher.
|
# Describes the condition that satisfies the matcher.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue