Remove unecessary type restrictions

This commit is contained in:
Michael Miller 2019-01-28 10:04:17 -07:00
parent 592d13d0d4
commit 61a3e6b113
15 changed files with 45 additions and 45 deletions

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
expected === partial.actual expected === partial.actual
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to semantically equal #{label} (using ===)" "Expected #{partial.label} to semantically equal #{label} (using ===)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not semantically equal #{label} (using ===)" "Expected #{partial.label} to not semantically equal #{label} (using ===)"
end end
end end

View file

@ -7,14 +7,14 @@ module Spectator::Matchers
abstract struct ConditionMatcher < Matcher abstract struct ConditionMatcher < Matcher
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the matcher is satisfied, false otherwise. # True is returned if the matcher is satisfied, false otherwise.
abstract def match?(partial : ValueExpectationPartial(ActualType)) : Bool forall ActualType abstract def match?(partial) : Bool
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
abstract def message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType abstract def message(partial) : String
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
abstract def negated_message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType abstract def negated_message(partial) : String
end end
end end

View file

@ -11,19 +11,19 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual.empty? partial.actual.empty?
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be empty" "Expected #{partial.label} to be empty"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be empty" "Expected #{partial.label} to not be empty"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual == expected partial.actual == expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to equal #{label} (using ==)" "Expected #{partial.label} to equal #{label} (using ==)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not equal #{label} (using ==)" "Expected #{partial.label} to not equal #{label} (using ==)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual >= expected partial.actual >= expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be greater than or equal to #{label} (using >=)" "Expected #{partial.label} to be greater than or equal to #{label} (using >=)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be greater than or equal to #{label} (using >=)" "Expected #{partial.label} to not be greater than or equal to #{label} (using >=)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual > expected partial.actual > expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be greater than #{label} (using >)" "Expected #{partial.label} to be greater than #{label} (using >)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be greater than #{label} (using >)" "Expected #{partial.label} to not be greater than #{label} (using >)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual != expected partial.actual != expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to not equal #{label} (using !=)" "Expected #{partial.label} to not equal #{label} (using !=)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to equal #{label} (using !=)" "Expected #{partial.label} to equal #{label} (using !=)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual <= expected partial.actual <= expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be less than or equal to #{label} (using <=)" "Expected #{partial.label} to be less than or equal to #{label} (using <=)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be less than or equal to #{label} (using <=)" "Expected #{partial.label} to not be less than or equal to #{label} (using <=)"
end end
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual < expected partial.actual < expected
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be less than #{label} (using <)" "Expected #{partial.label} to be less than #{label} (using <)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be less than #{label} (using <)" "Expected #{partial.label} to not be less than #{label} (using <)"
end end
end end

View file

@ -11,19 +11,19 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual.nil? partial.actual.nil?
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be nil" "Expected #{partial.label} to be nil"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be nil" "Expected #{partial.label} to not be nil"
end end
end end

View file

@ -8,19 +8,19 @@ module Spectator::Matchers
struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
@expected.includes?(partial.actual) @expected.includes?(partial.actual)
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be in #{label}" "Expected #{partial.label} to be in #{label}"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be in #{label}" "Expected #{partial.label} to not be in #{label}"
end end

View file

@ -6,19 +6,19 @@ module Spectator::Matchers
struct RegexMatcher(ExpectedType) < ValueMatcher(ExpectedType) struct RegexMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
!!(partial.actual =~ expected) !!(partial.actual =~ expected)
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to match #{label} (using =~)" "Expected #{partial.label} to match #{label} (using =~)"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not match #{label} (using =~)" "Expected #{partial.label} to not match #{label} (using =~)"
end end
end end

View file

@ -18,20 +18,20 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
# Cast value to truthy value and compare. # Cast value to truthy value and compare.
@expected == !!partial.actual @expected == !!partial.actual
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be #{label}" "Expected #{partial.label} to be #{label}"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be #{label}" "Expected #{partial.label} to not be #{label}"
end end

View file

@ -12,19 +12,19 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise. # True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType def match?(partial) : Bool
partial.actual.is_a?(Expected) partial.actual.is_a?(Expected)
end end
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def message(partial) : String
"Expected #{partial.label} to be a #{label}" "Expected #{partial.label} to be a #{label}"
end end
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType def negated_message(partial) : String
"Expected #{partial.label} to not be a #{label}" "Expected #{partial.label} to not be a #{label}"
end end
end end

View file

@ -26,14 +26,14 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it. # Determines whether the matcher is satisfied with the value given to it.
# True is returned if the matcher is satisfied, false otherwise. # True is returned if the matcher is satisfied, false otherwise.
abstract def match?(partial : ValueExpectationPartial(ActualType)) : Bool forall ActualType abstract def match?(partial) : Bool
# Describes the condition that satisfies the matcher. # Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
abstract def message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType abstract def message(partial) : String
# Describes the condition that won't satsify the matcher. # Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user. # This is informational and displayed to the end-user.
abstract def negated_message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType abstract def negated_message(partial) : String
end end
end end