Flip operands of != in case expected has custom logic

This commit is contained in:
Michael Miller 2019-08-11 12:40:27 -06:00
parent e1a119639f
commit 5dfcad3cb4

View file

@ -26,7 +26,7 @@ module Spectator::Matchers
# Actually performs the test against the expression. # Actually performs the test against the expression.
def match(actual : TestExpression(T)) : MatchData forall T def match(actual : TestExpression(T)) : MatchData forall T
before, after = change(actual) before, after = change(actual)
if before != expected if expected != before
FailedMatchData.new("#{expression.label} was not initially #{expected}", FailedMatchData.new("#{expression.label} was not initially #{expected}",
expected: expected.inspect, expected: expected.inspect,
actual: before.inspect, actual: before.inspect,
@ -46,7 +46,7 @@ module Spectator::Matchers
# A successful match with `#match` should normally fail for this method, and vice-versa. # A successful match with `#match` should normally fail for this method, and vice-versa.
def negated_match(actual : TestExpression(T)) : MatchData forall T def negated_match(actual : TestExpression(T)) : MatchData forall T
before, after = change(actual) before, after = change(actual)
if before != expected if expected != before
FailedMatchData.new("#{expression.label} was not initially #{expected}", FailedMatchData.new("#{expression.label} was not initially #{expected}",
expected: expected.inspect, expected: expected.inspect,
actual: before.inspect actual: before.inspect