mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Coerce operations in match? to booleans
The compiler is merging null-doubles with these matchers. Methods that normally return a boolean instead return the instance (self). This causes a return type-mismatch. There should be a better alternative to this.
This commit is contained in:
parent
6cd410c4c7
commit
76c21d447a
19 changed files with 22 additions and 22 deletions
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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)
|
private def match_string?(value) : Bool
|
||||||
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)
|
private def match_enumerable?(value) : Bool
|
||||||
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
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue