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.
|
# The values are compared with the === operator.
|
||||||
struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value === actual.value
|
expected.value === actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Spectator::Matchers
|
||||||
# Matcher for checking that a value is in a collection of other values.
|
# Matcher for checking that a value is in a collection of other values.
|
||||||
struct CollectionMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct CollectionMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value.includes?(actual.value)
|
expected.value.includes?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are checked with the `includes?` method.
|
# The values are checked with the `includes?` method.
|
||||||
struct ContainMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct ContainMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value.all? do |item|
|
expected.value.all? do |item|
|
||||||
actual.value.includes?(item)
|
actual.value.includes?(item)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are checked with the `empty?` method.
|
# The values are checked with the `empty?` method.
|
||||||
struct EmptyMatcher < StandardMatcher
|
struct EmptyMatcher < StandardMatcher
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value.empty?
|
actual.value.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the == operator.
|
# The values are compared with the == operator.
|
||||||
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value == actual.value
|
expected.value == actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the >= operator.
|
# The values are compared with the >= operator.
|
||||||
struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value >= expected.value
|
actual.value >= expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the > operator.
|
# The values are compared with the > operator.
|
||||||
struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value > expected.value
|
actual.value > expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The set is checked with the `has_key?` method.
|
# The set is checked with the `has_key?` method.
|
||||||
struct HaveKeyMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct HaveKeyMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value.has_key?(expected.value)
|
actual.value.has_key?(expected.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Spectator::Matchers
|
||||||
# Otherwise, it expects an `Enumerable` and iterates over each item until === is true.
|
# Otherwise, it expects an `Enumerable` and iterates over each item until === is true.
|
||||||
struct HaveMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct HaveMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
if (value = actual.value).is_a?(String)
|
if (value = actual.value).is_a?(String)
|
||||||
match_string?(value)
|
match_string?(value)
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The set is checked with the `has_value?` method.
|
# The set is checked with the `has_value?` method.
|
||||||
struct HaveValueMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct HaveValueMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value.has_value?(expected.value)
|
actual.value.has_value?(expected.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the != operator.
|
# The values are compared with the != operator.
|
||||||
struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value != actual.value
|
expected.value != actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the <= operator.
|
# The values are compared with the <= operator.
|
||||||
struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value <= expected.value
|
actual.value <= expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the < operator.
|
# The values are compared with the < operator.
|
||||||
struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value < expected.value
|
actual.value < expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The `Object#nil?` method is used for this.
|
# The `Object#nil?` method is used for this.
|
||||||
struct NilMatcher < StandardMatcher
|
struct NilMatcher < StandardMatcher
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value.nil?
|
actual.value.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The `Range#includes?` method is used for this check.
|
# The `Range#includes?` method is used for this check.
|
||||||
struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value.includes?(actual.value)
|
expected.value.includes?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the `Reference#same?` method.
|
# The values are compared with the `Reference#same?` method.
|
||||||
struct ReferenceMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct ReferenceMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value.same?(actual.value)
|
expected.value.same?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The set's `#size` method is used for this check.
|
# The set's `#size` method is used for this check.
|
||||||
struct SizeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct SizeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value == actual.value.size
|
expected.value == actual.value.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The set's `#size` method is used for this check.
|
# The set's `#size` method is used for this check.
|
||||||
struct SizeOfMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct SizeOfMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
expected.value.size == actual.value.size
|
expected.value.size == actual.value.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
@truthy == !!actual.value
|
@truthy == !!actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
||||||
# The values are compared with the `Object#is_a?` method.
|
# The values are compared with the `Object#is_a?` method.
|
||||||
struct TypeMatcher(Expected) < StandardMatcher
|
struct TypeMatcher(Expected) < StandardMatcher
|
||||||
# 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)
|
private def match?(actual : TestExpression(T)) forall T
|
||||||
actual.value.is_a?(Expected)
|
actual.value.is_a?(Expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue