mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Matched flag isn't needed (match data has it)
This commit is contained in:
parent
1e1503331e
commit
42d8eb6da3
2 changed files with 5 additions and 6 deletions
|
@ -2,13 +2,12 @@ module Spectator::Expectations
|
|||
# Ties together a partial, matcher, and their outcome.
|
||||
class Expectation
|
||||
# Populates the base portiion of the expectation with values.
|
||||
# The *matched* flag should be true if the matcher is satisfied with the partial.
|
||||
# The *negated* flag should be true if the expectation is inverted.
|
||||
# These options are mutually-exclusive in this context.
|
||||
# Don't flip the value of *matched* because *negated* is true.
|
||||
# The *match_data* is the value returned by `Spectator::Matcher#match`
|
||||
# when the expectation was evaluated.
|
||||
def initialize(@matched : Bool, @negated : Bool, @match_data : MatchData)
|
||||
# The *negated* flag and `MatchData#matched?` flag
|
||||
# are mutually-exclusive in this context.
|
||||
def initialize(@match_data : MatchData, @negated : Bool)
|
||||
end
|
||||
|
||||
# Indicates whether the expectation was satisifed.
|
||||
|
@ -16,7 +15,7 @@ module Spectator::Expectations
|
|||
# - The matcher was satisified and the expectation is not negated.
|
||||
# - The matcher wasn't satisfied and the expectation is negated.
|
||||
def satisfied?
|
||||
@matched ^ @negated
|
||||
@match_data.matched? ^ @negated
|
||||
end
|
||||
|
||||
# Text that indicates the condition that must be met for the expectation to be satisifed.
|
||||
|
|
|
@ -45,7 +45,7 @@ module Spectator::Expectations
|
|||
# Evaluates the expectation and returns it.
|
||||
private def eval(matcher, negated = false)
|
||||
match_data = matcher.match(self)
|
||||
Expectation.new(matched, negated, match_data)
|
||||
Expectation.new(match_data, negated)
|
||||
end
|
||||
|
||||
# Reports an expectation to the current harness.
|
||||
|
|
Loading…
Reference in a new issue