mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Type annotations for #match?
This commit is contained in:
parent
c4b886cad2
commit
898ddcb616
20 changed files with 20 additions and 20 deletions
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the === operator.
|
||||
struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value === actual.value
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module Spectator::Matchers
|
|||
# Matcher for checking that a value is in a collection of other values.
|
||||
struct CollectionMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value.includes?(actual.value)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are checked with the `includes?` method.
|
||||
struct ContainMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value.all? do |item|
|
||||
actual.value.includes?(item)
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are checked with the `empty?` method.
|
||||
struct EmptyMatcher < StandardMatcher
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value.empty?
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the == operator.
|
||||
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value == actual.value
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the >= operator.
|
||||
struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value >= expected.value
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the > operator.
|
||||
struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value > expected.value
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The set is checked with the `has_key?` method.
|
||||
struct HaveKeyMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value.has_key?(expected.value)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module Spectator::Matchers
|
|||
# Otherwise, it expects an `Enumerable` and iterates over each item until === is true.
|
||||
struct HaveMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
if (value = actual.value).is_a?(String)
|
||||
match_string?(value)
|
||||
else
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The set is checked with the `has_value?` method.
|
||||
struct HaveValueMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value.has_value?(expected.value)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the != operator.
|
||||
struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value != actual.value
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the <= operator.
|
||||
struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value <= expected.value
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the < operator.
|
||||
struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value < expected.value
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The `Object#nil?` method is used for this.
|
||||
struct NilMatcher < StandardMatcher
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value.nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The `Range#includes?` method is used for this check.
|
||||
struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value.includes?(actual.value)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the `Reference#same?` method.
|
||||
struct ReferenceMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value.same?(actual.value)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The set's `#size` method is used for this check.
|
||||
struct SizeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value == actual.value.size
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The set's `#size` method is used for this check.
|
||||
struct SizeOfMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
expected.value.size == actual.value.size
|
||||
end
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
@truthy == !!actual.value
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The values are compared with the `Object#is_a?` method.
|
||||
struct TypeMatcher(Expected) < StandardMatcher
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual)
|
||||
private def match?(actual : TestExpression(T)) forall T
|
||||
actual.value.is_a?(Expected)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue