mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Move #eval to partial
This commit is contained in:
parent
a3ac50d661
commit
35b59854ec
2 changed files with 8 additions and 9 deletions
|
@ -24,13 +24,13 @@ module Spectator::Expectations
|
||||||
# Asserts that the `#actual` value matches some criteria.
|
# Asserts that the `#actual` value matches some criteria.
|
||||||
# The criteria is defined by the matcher passed to this method.
|
# The criteria is defined by the matcher passed to this method.
|
||||||
def to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
def to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
||||||
report(matcher.eval(self))
|
report(eval(matcher))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Asserts that the `#actual` value *does not* match some criteria.
|
# Asserts that the `#actual` value *does not* match some criteria.
|
||||||
# This is effectively the opposite of `#to`.
|
# This is effectively the opposite of `#to`.
|
||||||
def to_not(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
def to_not(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
||||||
report(matcher.eval(self, true))
|
report(eval(matcher, true))
|
||||||
end
|
end
|
||||||
|
|
||||||
# ditto
|
# ditto
|
||||||
|
@ -38,5 +38,11 @@ module Spectator::Expectations
|
||||||
def not_to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
def not_to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
||||||
to_not(matcher)
|
to_not(matcher)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Evaluates the expectation and returns it.
|
||||||
|
private def eval(matcher : Matchers::ValueMatcher(ExpectedType), negated = false) forall ExpectedType
|
||||||
|
matched = matcher.match?(self)
|
||||||
|
ValueExpectation.new(matched, negated, self, matcher)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,13 +24,6 @@ module Spectator::Matchers
|
||||||
super(@expected.to_s)
|
super(@expected.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determines whether the matcher is satisfied with the value given to it.
|
|
||||||
# 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.
|
# Determines whether the matcher is satisfied with the value given to it.
|
||||||
# True is returned if the matcher is satisfied, false otherwise.
|
# 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
|
||||||
|
|
Loading…
Reference in a new issue