Revert "Coerce operations in match? to booleans"

This reverts commit 76c21d447a.

Should no longer be needed since mocks and doubles should indirectly leak into StandardMatcher types.
This commit is contained in:
Michael Miller 2019-11-16 15:15:53 -07:00
parent d9d30c57d0
commit a8e0f46645
19 changed files with 22 additions and 22 deletions

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(expected.value === actual.value) expected.value === actual.value
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -14,7 +14,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!expected.value.includes?(actual.value) expected.value.includes?(actual.value)
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!expected.value.all? do |item| expected.value.all? do |item|
actual.value.includes?(item) actual.value.includes?(item)
end end
end end

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!actual.value.empty? actual.value.empty?
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(expected.value == actual.value) expected.value == actual.value
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(actual.value >= expected.value) actual.value >= expected.value
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(actual.value > expected.value) actual.value > expected.value
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!actual.value.has_key?(expected.value) actual.value.has_key?(expected.value)
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -23,17 +23,17 @@ module Spectator::Matchers
# Checks if a `String` matches the expected values. # Checks if a `String` matches the expected values.
# The `includes?` method is used for this check. # The `includes?` method is used for this check.
private def match_string?(value) : Bool private def match_string?(value)
!!expected.value.all? do |item| expected.value.all? do |item|
value.includes?(item) value.includes?(item)
end end
end end
# Checks if an `Enumerable` matches the expected values. # Checks if an `Enumerable` matches the expected values.
# The `===` operator is used on every item. # The `===` operator is used on every item.
private def match_enumerable?(value) : Bool private def match_enumerable?(value)
array = value.to_a array = value.to_a
!!expected.value.all? do |item| expected.value.all? do |item|
array.any? do |element| array.any? do |element|
item === element item === element
end end

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!actual.value.has_value?(expected.value) actual.value.has_value?(expected.value)
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(expected.value != actual.value) expected.value != actual.value
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(actual.value <= expected.value) actual.value <= expected.value
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(actual.value < expected.value) actual.value < expected.value
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!actual.value.nil? actual.value.nil?
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -27,7 +27,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!expected.value.includes?(actual.value) expected.value.includes?(actual.value)
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!expected.value.same?(actual.value) expected.value.same?(actual.value)
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(expected.value == actual.value.size) expected.value == actual.value.size
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!(expected.value.size == actual.value.size) expected.value.size == actual.value.size
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.

View file

@ -13,7 +13,7 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it. # Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T private def match?(actual : TestExpression(T)) : Bool forall T
!!actual.value.is_a?(Expected) actual.value.is_a?(Expected)
end end
# Message displayed when the matcher isn't satisifed. # Message displayed when the matcher isn't satisifed.